addRender #2
File diff suppressed because one or more lines are too long
@ -217,6 +217,9 @@ class SelectionSystem:
|
||||
return task.cont
|
||||
self._last_selection_box_update = current_time
|
||||
|
||||
#检查目标节点是否已被删除
|
||||
self.checkAndClearIfTargetDeleted()
|
||||
|
||||
if not self.selectionBox or not self.selectionBoxTarget:
|
||||
return task.done # 结束任务
|
||||
|
||||
@ -648,6 +651,9 @@ class SelectionSystem:
|
||||
return task.cont
|
||||
self._last_gizmo_update = current_time
|
||||
|
||||
#检查目标节点是否已被删除
|
||||
self.checkAndClearIfTargetDeleted()
|
||||
|
||||
if not self.gizmo or not self.gizmoTarget:
|
||||
return task.done
|
||||
|
||||
@ -1507,3 +1513,10 @@ class SelectionSystem:
|
||||
def hasSelection(self):
|
||||
"""检查是否有选中的节点"""
|
||||
return self.selectedNode is not None
|
||||
|
||||
def checkAndClearIfTargetDeleted(self):
|
||||
if self.gizmoTarget and self.gizmoTarget.isEmpty():
|
||||
self.clearGizmo()
|
||||
|
||||
if self.selectionBoxTarget and self.selectionBoxTarget.isEmpty():
|
||||
self.clearSelectionBox()
|
||||
|
||||
@ -630,7 +630,8 @@ class SceneManager:
|
||||
cNode.addSolid(cSphere)
|
||||
|
||||
# 将碰撞节点附加到模型上
|
||||
#cNodePath = model.attachNewNode(cNode)
|
||||
cNodePath = model.attachNewNode(cNode)
|
||||
#cNodePath.hide()
|
||||
# cNodePath.show() # 取消注释可以显示碰撞体,用于调试
|
||||
|
||||
# ==================== 场景树管理 ====================
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
from PyQt5.QtWidgets import QTreeWidget, QTreeWidgetItem, QMenu
|
||||
from PyQt5.QtCore import Qt
|
||||
from PyQt5.sip import delete
|
||||
from panda3d.core import GeomNode, ModelRoot
|
||||
|
||||
|
||||
@ -22,13 +23,15 @@ class InterfaceManager:
|
||||
|
||||
# 更新场景树
|
||||
self.world.scene_manager.updateSceneTree()
|
||||
#self.syncVisibilityDownward()
|
||||
|
||||
def onTreeItemClicked(self, item, column):
|
||||
"""处理树形控件项目点击事件"""
|
||||
if not item:
|
||||
self.world.selection.updateSelection(None)
|
||||
return
|
||||
|
||||
self.world.property_panel.updatePropertyPanel(item)
|
||||
|
||||
# 获取节点对象
|
||||
nodePath = item.data(0, Qt.UserRole)
|
||||
if nodePath:
|
||||
@ -37,7 +40,7 @@ class InterfaceManager:
|
||||
self.world.selection.updateSelection(nodePath)
|
||||
|
||||
# 更新属性面板
|
||||
self.world.property_panel.updatePropertyPanel(item)
|
||||
#self.world.property_panel.updatePropertyPanel(item)
|
||||
|
||||
print(f"树形控件点击: {item.text(0)}")
|
||||
else:
|
||||
@ -78,6 +81,9 @@ class InterfaceManager:
|
||||
if self.isModelOrChild(item):
|
||||
deleteAction = menu.addAction("删除")
|
||||
deleteAction.triggered.connect(lambda: self.deleteNode(nodePath, item))
|
||||
else:
|
||||
deleteAction = menu.addAction("删除")
|
||||
deleteAction.triggered.connect(lambda: self.deleteNode(nodePath, item))
|
||||
|
||||
# 显示菜单
|
||||
menu.exec_(self.treeWidget.viewport().mapToGlobal(position))
|
||||
@ -95,12 +101,33 @@ class InterfaceManager:
|
||||
try:
|
||||
# 从场景中移除
|
||||
self.world.property_panel.removeActorForModel(nodePath)
|
||||
|
||||
if hasattr(nodePath,'getPythonTag'):
|
||||
light_object = nodePath.getPythonTag('rp_light_object')
|
||||
if light_object and hasattr(self.world,'render_pipeline'):
|
||||
self.world.render_pipeline.remove_light(light_object)
|
||||
|
||||
if hasattr(self.world,'selection'):
|
||||
if self.world.selection.selectedNode == nodePath:
|
||||
self.world.selection.clearSelectionBox()
|
||||
self.world.selection.clearGizmo()
|
||||
self.world.selection.selectedNode = None
|
||||
self.world.selection.selectedObject = None
|
||||
|
||||
if nodePath in self.world.Spotlight:
|
||||
self.world.Spotlight.remove(nodePath)
|
||||
if nodePath in self.world.Pointlight:
|
||||
self.world.Pointlight.remove(nodePath)
|
||||
|
||||
nodePath.removeNode()
|
||||
|
||||
if hasattr(self.world,'selection'):
|
||||
self.world.selection.checkAndClearIfTargetDeleted()
|
||||
|
||||
# 如果是模型根节点,从模型列表中移除
|
||||
if item.parent().text(0) == "模型":
|
||||
if nodePath in self.world.models:
|
||||
self.world.models.remove(nodePath)
|
||||
#if item.parent().text(0) == "模型":
|
||||
if nodePath in self.world.models:
|
||||
self.world.models.remove(nodePath)
|
||||
|
||||
# 从树形控件中移除
|
||||
parentItem = item.parent()
|
||||
|
||||
@ -143,10 +143,15 @@ class PropertyPanelManager:
|
||||
eff = parent_eff and user
|
||||
node.setPythonTag("effective_visible", eff)
|
||||
|
||||
if eff:
|
||||
node.show()
|
||||
else:
|
||||
#特殊处理:检查是否为碰撞体节点
|
||||
|
||||
if node.getName().startswith("modelCollision_"):
|
||||
node.hide()
|
||||
else:
|
||||
if eff:
|
||||
node.show()
|
||||
else:
|
||||
node.hide()
|
||||
|
||||
for child in node.getChildren():
|
||||
q.append((child, eff))
|
||||
@ -157,6 +162,11 @@ class PropertyPanelManager:
|
||||
# 用我们自己维护的可见性接口,而不是直接 show/hide
|
||||
visible = (state == Qt.Checked)
|
||||
self._setUserVisible(model, visible)
|
||||
|
||||
collision_nodes = model.findAllMatches("**/modelCollision_*")
|
||||
for collision_node in collision_nodes:
|
||||
collision_node.hide()
|
||||
|
||||
except Exception as e:
|
||||
print(f"切换模型可见性失败: {str(e)}")
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user