Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
aimoonchen committed Jan 18, 2024
1 parent f537816 commit 54a2513
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 54 deletions.
4 changes: 3 additions & 1 deletion tools/editor/pkg/tools.editor/camera/camera_manager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ function camera_mgr.set_second_camera(cameraref, show)
end

function camera_mgr.on_target(eid, show)
if not eid then return end
local e <close> = world:entity(eid, "camera?in")
if not e.camera then
return
end
irq.set_camera("second_view", eid)
local qe = w:first("second_view render_target:in camera_ref?in")
irq.set_camera(qe, eid)
irq.set_visible("second_view", show)
end

Expand Down
14 changes: 4 additions & 10 deletions tools/editor/pkg/tools.editor/gui_system.lua
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ local event_showground = world:sub {"ShowGround"}
local event_showterrain = world:sub {"ShowTerrain"}
local event_savehitch = world:sub {"SaveHitch"}
local event_gizmo = world:sub {"Gizmo"}
local create_animation_event = world:sub {"CreateAnimation"}
local light_gizmo = ecs.require "gizmo.light"
local patch_event = world:sub {"PatchEvent"}

Expand Down Expand Up @@ -145,12 +144,10 @@ local function on_target(old, new)
light_gizmo.on_target()
end
end
if new then
light_gizmo.on_target(new)
camera_mgr.on_target(new, true)
keyframe_view.on_target(new)
anim_view.on_target(new)
end
light_gizmo.on_target(new)
camera_mgr.on_target(new, true)
keyframe_view.on_target(new)
anim_view.on_target(new)
world:pub {"UpdateAABB", new}
end

Expand Down Expand Up @@ -360,9 +357,6 @@ function m:handle_event()
for _, enable in event_savehitch:unpack() do
prefab_mgr.save_hitch = enable
end
for _, at, target in create_animation_event:unpack() do
keyframe_view.create_target_animation(at, target)
end
for _, eid, path, value in patch_event:unpack() do
prefab_mgr:do_patch(eid, path, value)
end
Expand Down
26 changes: 13 additions & 13 deletions tools/editor/pkg/tools.editor/prefab_manager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -267,18 +267,18 @@ function m:create(what, config)
local new_entity = world:create_entity(tmp)
self:add_entity(new_entity, parent_eid, template)
return new_entity
elseif config.type == "cube(prefab)" then
m:add_prefab("/pkg/tools.editor/resource/cube.prefab")
elseif config.type == "cone(prefab)" then
m:add_prefab("/pkg/tools.editor/resource/cone.prefab")
elseif config.type == "cylinder(prefab)" then
m:add_prefab("/pkg/tools.editor/resource/cylinder.prefab")
elseif config.type == "sphere(prefab)" then
m:add_prefab("/pkg/tools.editor/resource/sphere.prefab")
elseif config.type == "torus(prefab)" then
m:add_prefab("/pkg/tools.editor/resource/torus.prefab")
elseif config.type == "plane(prefab)" then
m:add_prefab("/pkg/tools.editor/resource/plane.prefab")
-- elseif config.type == "cube(prefab)" then
-- m:add_prefab("/pkg/tools.editor/resource/cube.prefab")
-- elseif config.type == "cone(prefab)" then
-- m:add_prefab("/pkg/tools.editor/resource/cone.prefab")
-- elseif config.type == "cylinder(prefab)" then
-- m:add_prefab("/pkg/tools.editor/resource/cylinder.prefab")
-- elseif config.type == "sphere(prefab)" then
-- m:add_prefab("/pkg/tools.editor/resource/sphere.prefab")
-- elseif config.type == "torus(prefab)" then
-- m:add_prefab("/pkg/tools.editor/resource/torus.prefab")
-- elseif config.type == "plane(prefab)" then
-- m:add_prefab("/pkg/tools.editor/resource/plane.prefab")
end
elseif what == "light" then
if config.type == "directional" or config.type == "point" or config.type == "spot" then
Expand All @@ -304,7 +304,7 @@ function m:create(what, config)
local tmp = utils.deep_copy(template)
tmp.data.on_ready = function (e)
w:extend(e, "timeline:in")
e.timeline.eid_map = self.current_prefab.tag
e.timeline.eid_map = self.current_prefab and self.current_prefab.tag or {}
end
local new_entity = world:create_entity(tmp)
self:add_entity(new_entity, nil, template)
Expand Down
3 changes: 3 additions & 0 deletions tools/editor/pkg/tools.editor/widget/animation_view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,9 @@ function m.on_target(eid)
stop_timeline()
edit_timeline = nil
timeline_eid = nil
if not eid then
return
end
local e <close> = world:entity(eid, "timeline?in")
if e.timeline then
if not e.timeline.eid_map then
Expand Down
25 changes: 9 additions & 16 deletions tools/editor/pkg/tools.editor/widget/keyframe_view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -955,15 +955,15 @@ local function play_animation(current)
else
for _, anim in ipairs(current.target_anims) do
if anim.modifier then
if current_anim.type == "srt" then
if not target_map[anim.target_name] then
target_map[anim.target_name] = prefab_mgr:get_eid_by_name(anim.target_name)
end
current_target = target_map[anim.target_name]
imodifier.set_target(anim.modifier, current_target)
elseif current_anim.type == "mtl" then
imodifier.set_target(anim.modifier, current_target)
end
-- if current_anim.type == "srt" then
-- if not target_map[anim.target_name] then
-- target_map[anim.target_name] = prefab_mgr:get_eid_by_name(anim.target_name)
-- end
-- current_target = target_map[anim.target_name]
-- imodifier.set_target(anim.modifier, current_target)
-- elseif current_anim.type == "mtl" then
-- imodifier.set_target(anim.modifier, current_target)
-- end
imodifier.start(anim.modifier, {loop = ui_loop[1]})
end
end
Expand Down Expand Up @@ -1444,13 +1444,6 @@ function m.on_eid_delete(eid)
end

function m.on_target(target_eid)
if current_target == target_eid then
return
end
local e <close> = world:entity(target_eid, "scene?in render_object?in")
if not e.scene and not e.render_object then
return
end
current_target = target_eid
end

Expand Down
5 changes: 0 additions & 5 deletions tools/editor/pkg/tools.editor/widget/material_view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ end
local default_setting = read_datalist_file "/pkg/ant.settings/default/graphic_settings.ant"

local function load_material_file(mf)
-- if string.find(mf, ".glb|") then
-- mf = mf .. "/source.ant"
-- end

-- return read_datalist_file(mf)
return read_datalist_file(mf .. "/source.ant")
end

Expand Down
18 changes: 9 additions & 9 deletions tools/editor/pkg/tools.editor/widget/scene_view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,12 @@ local geom_type = {
"sphere",
"torus",
"plane",
"cube(prefab)",
"cone(prefab)",
"cylinder(prefab)",
"sphere(prefab)",
"torus(prefab)",
"plane(prefab)",
-- "cube(prefab)",
-- "cone(prefab)",
-- "cylinder(prefab)",
-- "sphere(prefab)",
-- "torus(prefab)",
-- "plane(prefab)",
}
local collider_type = {
"sphere",
Expand Down Expand Up @@ -298,9 +298,9 @@ function m.show()
if imgui.widget.MenuItem("Camera") then
world:pub { "Create", "camera"}
end
if imgui.widget.MenuItem("Slot") then
world:pub { "Create", "slot"}
end
-- if imgui.widget.MenuItem("Slot") then
-- world:pub { "Create", "slot"}
-- end
if imgui.widget.MenuItem("Timeline") then
world:pub { "Create", "timeline"}
end
Expand Down

0 comments on commit 54a2513

Please sign in to comment.