Skip to content

Commit

Permalink
remove simplemesh
Browse files Browse the repository at this point in the history
  • Loading branch information
junjie020 committed Mar 8, 2024
1 parent df49e06 commit e138e50
Show file tree
Hide file tree
Showing 37 changed files with 101 additions and 68 deletions.
1 change: 0 additions & 1 deletion pkg/ant.asset/package.ecs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import_feature "ant.material"

component "material".type "lua"
component "mesh".type "lua"
component "simplemesh".type "lua"

component "procedural_mesh"
component "owned_mesh_buffer"
20 changes: 10 additions & 10 deletions pkg/ant.entity/entity.lua
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ local function simple_render_entity_data(material, mesh, scene, uniforms, hide,
data = {
scene = scene or {},
material = material,
simplemesh = imesh.init_mesh(mesh, true),
mesh_result = imesh.init_mesh(mesh, true),
render_layer= render_layer,
visible_state= visible_state,
on_ready = function(e)
Expand Down Expand Up @@ -108,7 +108,7 @@ local function grid_mesh_entity_data(materialpath, vb, ib, render_layer)
material = materialpath,
visible_state= "main_view",
render_layer= render_layer,
simplemesh = imesh.init_mesh(create_dynamic_mesh("p3|c40niu", vb, ib), true), --create_mesh({"p3|c40niu", vb}, ib)
mesh_result = imesh.init_mesh(create_dynamic_mesh("p3|c40niu", vb, ib), true), --create_mesh({"p3|c40niu", vb}, ib)
},
}
end
Expand Down Expand Up @@ -240,7 +240,7 @@ function ientity.create_prim_plane_entity(materialpath, scene, color, hide, rend
material = materialpath,
visible_state= hide and "" or "main_view",
render_layer= render_layer,
simplemesh = create_mesh({"p3|n3", plane_vb}, nil, {{-0.5, 0, -0.5}, {0.5, 0, 0.5}}),
mesh_result = create_mesh({"p3|n3", plane_vb}, nil, {{-0.5, 0, -0.5}, {0.5, 0, 0.5}}),
on_ready = function (e)
imaterial.set_property(e, "u_color", math3d.vector(color))
end
Expand Down Expand Up @@ -372,7 +372,7 @@ function ientity.create_screen_axis_entity(screen_3dobj, scene, color)
scene = scene or {},
material = "/pkg/ant.resources/materials/line.material",
render_layer= "translucent",
simplemesh = imesh.init_mesh(mesh, true),
mesh_result = imesh.init_mesh(mesh, true),
visible_state= "main_view",
}
}
Expand Down Expand Up @@ -485,7 +485,7 @@ function ientity.create_skybox(material)
},
skybox = {},
owned_mesh_buffer = true,
simplemesh = get_skybox_mesh(),
mesh_result = get_skybox_mesh(),
}
}
end
Expand Down Expand Up @@ -553,7 +553,7 @@ function ientity.create_procedural_sky(settings)
visible_state = "main_view",
owned_mesh_buffer = true,
render_layer = "background",
simplemesh = create_sky_mesh(32, 32),
mesh_result = create_sky_mesh(32, 32),
}
}
end
Expand All @@ -566,7 +566,7 @@ function ientity.create_gamma_test_entity()
data = {
material = "/pkg/ant.resources/materials/gamma_test.material",
render_layer = "translucent",
simplemesh = {
mesh_result = {
ib = {
start = 0,
num = 6,
Expand Down Expand Up @@ -700,7 +700,7 @@ function ientity.create_arrow_entity(headratio, color, material, scene)
"ant.render|simplerender",
},
data = {
simplemesh = arrow_mesh(headratio),
mesh_result = arrow_mesh(headratio),
material = material,
visible_state = "main_view",
scene = scene or {},
Expand Down Expand Up @@ -761,7 +761,7 @@ function ientity.create_quad_lines_entity(scene, material, quadnum, width, hide,
data = {
scene = scene or {},
visible_state = hide and "" or "main_view",
simplemesh = create_mesh(create_vertex_buffer(), create_index_buffer()),
mesh_result = create_mesh(create_vertex_buffer(), create_index_buffer()),
material = material,
render_layer = render_layer,
on_ready = on_ready,
Expand All @@ -774,7 +774,7 @@ function ientity.create_quad_entity(material, srt, rect, uvrect)
policy = {"ant.render|simplerender",},
data = {
material = material,
simplemesh = ientity.quad_mesh(rect, true, uvrect),
mesh_result = ientity.quad_mesh(rect, true, uvrect),
owned_mesh_buffer = true,
visible_state = "main_view",
scene = srt,
Expand Down
2 changes: 1 addition & 1 deletion pkg/ant.grid/grid.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ local function create_grid_entity(grid_params, grid_color, grid_render_layer, gr
},
data = {
scene = grid_srt,
simplemesh = DEFAULT_GRID_MESH and DEFAULT_GRID_MESH or get_quad_mesh(),
mesh_result = DEFAULT_GRID_MESH or get_quad_mesh(),
material = DEFAULT_GRID_MATERIAL,
visible_state = "main_view|selectable",
render_layer = grid_render_layer,
Expand Down
2 changes: 1 addition & 1 deletion pkg/ant.landform/plane_terrain.lua
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ local function create_plane_entity(gid, size, xypos, mesh, material, render_laye
},
data = {
scene = {s = {size, 1, size}, t = {xypos.x, 0, xypos.y}},
simplemesh = assert(mesh),
mesh_result = assert(mesh),
material = material,
visible_state = "main_view|selectable",
render_layer = render_layer,
Expand Down
2 changes: 1 addition & 1 deletion pkg/ant.landform/road.lua
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ local function create_road_obj(gid, render_layer, buffer, dimaterial, cs_materia
},
data = {
scene = {},
simplemesh = assert(ROAD_MESH),
mesh_result = assert(ROAD_MESH),
material = dimaterial,
visible_state = "main_view|selectable",
road = {
Expand Down
2 changes: 1 addition & 1 deletion pkg/ant.landform/stone_mountain_system.lua
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ local function create_sm_entity(gid, indices, mountain_material, cs_material, me
},
data = {
scene = {},
simplemesh = MERGE_MESH,
mesh_result = MERGE_MESH,
material = mountain_material,
visible_state = "main_view|cast_shadow",
stonemountain = {
Expand Down
2 changes: 1 addition & 1 deletion pkg/ant.landform/translucent_plane_system.lua
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ local function create_tp_entity(info, render_layer, tile_size, material)
},
data = {
scene = {s = {info.w, 1, info.h}, t = {info.x, 0, info.y}},
simplemesh = mesh,
mesh_result = mesh,
material = material,
visible_state = "main_view|selectable",
render_layer = render_layer,
Expand Down
2 changes: 1 addition & 1 deletion pkg/ant.objcontroller/pickup/pickup_debug.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ local function create_view_buffer_entity()
},
data = {
owned_mesh_buffer = true,
simplemesh = m,
mesh_result = m,
material = "/pkg/ant.resources/materials/texquad.material",
visible_state = "main_view",
render_layer = "translucent",
Expand Down
2 changes: 1 addition & 1 deletion pkg/ant.polyline/polyline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ local function add_polylines(polymesh, line_width, color, material, srt, render_
color = math3d.ref(math3d.vector(color)),
},
scene = {s = srt.s, r = srt.r, t = srt.t, parent = srt.parent},
simplemesh = polymesh,
mesh_result = polymesh,
material = material,
visible_state= hide and "" or "main_view|velocity_queue",
render_layer= render_layer or "background",
Expand Down
13 changes: 13 additions & 0 deletions pkg/ant.render/2d/render2d.ecs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
component "viewrect".type "lua"
component "texturequad"

policy "render2d"
.include_policy "ant.render|render_object"
.include_policy "ant.scene|scene_object"
.include_policy "ant.render|material"
.component_opt "render_layer"
.component_opt "mesh_result"
.component "visible_state"

system "render_system2d"
.implement "2d/render_system2d.lua"
18 changes: 18 additions & 0 deletions pkg/ant.render/2d/render_system2d.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
local ecs = ...
local world = ecs.world
local w = world.w

local render_sys2d = ecs.system "render_system2d"

function render_sys2d:component_init()
for e in w:select "INIT viewrect:in simplemesh:out" do

end
end


function render_sys2d:entity_init()
for e in w:select "INIT viewrect:in render_object:update simplemesh:out" do

end
end
2 changes: 1 addition & 1 deletion pkg/ant.render/blur_scene/blur_scene.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ local function create_blend_scene_entity(material)
},
data = {
blend_scene = true,
simplemesh = irender.full_quad(),
mesh_result = irender.full_quad(),
material = material,
visible_state = queue,
scene = {},
Expand Down
2 changes: 1 addition & 1 deletion pkg/ant.render/postprocess/fsr.lua
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ local function create_fsr_resolve_entity(ratio)
"ant.render|simplerender",
},
data = {
simplemesh = to_mesh_buffer(vb, irender.quad_ib()),
mesh_result = to_mesh_buffer(vb, irender.quad_ib()),
material = "/pkg/ant.resources/materials/postprocess/fsr_resolve.material",
visible_state = "fsr_resolve_queue",
fsr_resolve_drawer = true,
Expand Down
2 changes: 1 addition & 1 deletion pkg/ant.render/postprocess/fxaa.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function fxaasys:init()
"ant.render|simplerender",
},
data = {
simplemesh = irender.full_quad(),
mesh_result = irender.full_quad(),
material = "/pkg/ant.resources/materials/postprocess/fxaa.material",
visible_state = "",
scene = {},
Expand Down
4 changes: 2 additions & 2 deletions pkg/ant.render/postprocess/pyramid_sample.lua
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ local function create_drawers(ps)
ds[i].drawer = world:create_entity{
policy = {"ant.render|simplerender",},
data = {
simplemesh = irender.full_quad(),
mesh_result = irender.full_quad(),
material = "/pkg/ant.resources/materials/postprocess/downsample.material",
visible_state = "",
scene = {},
Expand All @@ -123,7 +123,7 @@ local function create_drawers(ps)
us[i].drawer = world:create_entity{
policy = {"ant.render|simplerender",},
data = {
simplemesh = irender.full_quad(),
mesh_result = irender.full_quad(),
material = "/pkg/ant.resources/materials/postprocess/upsample.material",
visible_state = "",
scene = {},
Expand Down
8 changes: 4 additions & 4 deletions pkg/ant.render/postprocess/swapchain.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ function sc_sys:init()
"ant.render|simplerender",
},
data = {
simplemesh = irender.full_quad(),
material = "/pkg/ant.resources/materials/postprocess/swapchain.material",
visible_state = "swapchain_queue",
scene = {},
mesh_result = irender.full_quad(),
material = "/pkg/ant.resources/materials/postprocess/swapchain.material",
visible_state= "swapchain_queue",
scene = {},
}
}
end
Expand Down
8 changes: 4 additions & 4 deletions pkg/ant.render/postprocess/taa.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function taasys:init()
"ant.render|simplerender",
},
data = {
simplemesh = irender.full_quad(),
mesh_result = irender.full_quad(),
material = "/pkg/ant.resources/materials/postprocess/taa.material",
visible_state = "taa_queue",
taa_drawer = true,
Expand All @@ -60,7 +60,7 @@ function taasys:init()
},
data = {
owned_mesh_buffer = true,
simplemesh = fullquad,
mesh_result = fullquad,
material = "/pkg/ant.resources/materials/postprocess/taa_first_frame.material",
visible_state = "taa_queue",
taa_first_frame_drawer = true,
Expand All @@ -72,7 +72,7 @@ function taasys:init()
"ant.render|simplerender",
},
data = {
simplemesh = irender.full_quad(),
mesh_result = irender.full_quad(),
material = "/pkg/ant.resources/materials/postprocess/taa_copy.material",
visible_state = "taa_copy_queue",
taa_copy_drawer = true,
Expand All @@ -85,7 +85,7 @@ function taasys:init()
"ant.render|simplerender",
},
data = {
simplemesh = irender.full_quad(),
mesh_result = irender.full_quad(),
material = "/pkg/ant.resources/materials/postprocess/taa_copy.material",
visible_state = "taa_present_queue",
taa_present_drawer = true,
Expand Down
2 changes: 1 addition & 1 deletion pkg/ant.render/postprocess/tonemapping.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function tm_sys:init()
"ant.render|simplerender",
},
data = {
simplemesh = irender.full_quad(),
mesh_result = irender.full_quad(),
material = drawer_material,
visible_state = "",
tonemapping_drawer=true,
Expand Down
3 changes: 1 addition & 2 deletions pkg/ant.render/render_system/render_system.ecs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ policy "simplerender"
.include_policy "ant.scene|scene_object"
.include_policy "ant.scene|bounding"
.component_opt "render_layer"
.component_opt "mesh_result"
.component "mesh_result"
.component "material"
.component "simplemesh"
.component "visible_state"

system "submit_render_system"
Expand Down
8 changes: 2 additions & 6 deletions pkg/ant.render/render_system/render_system.lua
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,6 @@ function render_sys:component_init()
for e in w:select "INIT mesh:in mesh_result?update" do
e.mesh_result = assetmgr.resource(e.mesh)
end

for e in w:select "INIT simplemesh:update mesh_result?update" do
e.mesh_result = e.simplemesh
end
end

local function read_mat_varyings(varyings)
Expand Down Expand Up @@ -371,8 +367,8 @@ local function clear_render_object(ro)
end

function render_sys:entity_remove()
for e in w:select "REMOVED owned_mesh_buffer simplemesh:in" do
imesh.delete_mesh(e.simplemesh)
for e in w:select "REMOVED owned_mesh_buffer mesh_result:in" do
imesh.delete_mesh(e.mesh_result)
end

for e in w:select "REMOVED render_object:update filter_material:in" do
Expand Down
6 changes: 3 additions & 3 deletions pkg/ant.render/shadow/shadow_debug.lua
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ function shadowdebug_sys:init_world()
"ant.render|simplerender",
},
data = {
simplemesh = imesh.init_mesh(ientity.quad_mesh(mu.rect2ndc({x=0, y=0, w=fbw, h=fbh}, irq.view_rect "main_queue")), true),
mesh_result = imesh.init_mesh(ientity.quad_mesh(mu.rect2ndc({x=0, y=0, w=fbw, h=fbh}, irq.view_rect "main_queue")), true),
material = "/pkg/ant.resources/materials/texquad.material",
visible_state = "main_queue",
scene = {},
Expand All @@ -210,7 +210,7 @@ local function draw_lines(lines)
return world:create_entity{
policy = {"ant.render|simplerender"},
data = {
simplemesh = ientity.create_mesh{"p3|c40", lines,},
mesh_result = ientity.create_mesh{"p3|c40", lines,},
material = "/pkg/ant.resources/materials/line.material",
scene = {},
render_layer = "translucent",
Expand Down Expand Up @@ -241,7 +241,7 @@ local function draw_box(points, M)
world:create_entity{
policy = {"ant.render|simplerender"},
data = {
simplemesh = ientity.create_mesh(
mesh_result = ientity.create_mesh(
{"p3|c40", s,},
{
0, 4, 1, 5,
Expand Down
3 changes: 1 addition & 2 deletions pkg/ant.sky/skybox.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ local ientity = ecs.require "ant.entity|entity"
local skybox_sys = ecs.system "skybox_system"

function skybox_sys:component_init()
for e in w:select "INIT skybox:in simplemesh:out mesh_result:out owned_mesh_buffer?out" do
for e in w:select "INIT skybox:in mesh_result:out owned_mesh_buffer?out" do
local vb, ib = geo.box(1, true, false)
local m = ientity.create_mesh({"p3", vb}, ib)
e.simplemesh = m
e.mesh_result = m
e.owned_mesh_buffer = true
end
Expand Down
6 changes: 3 additions & 3 deletions pkg/ant.starsky/starsky.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ local function get_tex_ratio(vr, texinfo)
end

function starsky_system:component_init()
for e in w:select "INIT starsky simplemesh:out mesh_result:out" do
for e in w:select "INIT starsky mesh_result:out owned_mesh_buffer?out" do
local mq = w:first "main_queue render_target:in camera_ref:in"
local vr = mq.render_target.view_rect
local texinfo = assetmgr.resource("/pkg/vaststars.resources/textures/sky/star_sky.texture").texinfo
local twb, thb, twe, the = get_tex_ratio(vr, texinfo)
e.simplemesh = ientity.create_mesh{
e.mesh_result = ientity.create_mesh{
"p2|t2", {
-1.0, 1.0, twb, thb,
1.0, 1.0, twe, thb,
-1.0,-1.0, twb, the,
1.0,-1.0, twe, the,
}
}
e.mesh_result = e.simplemesh
e.owned_mesh_buffer = true
end
end
Loading

0 comments on commit e138e50

Please sign in to comment.