feat(ecs): per-component enable/disable + inspector rework
Add `active` flag to the 8 behavior components (Unity enabled / UE SetActive semantics; structural Id/Name/Transform excluded). Consumers skip disabled components: renderer (mesh/light/anim), primary camera election, physics reconciliation (body/constraint/character destroyed and rebuilt on toggle), scripts keep instance but stop ticking. Inspector: component headers now carry an enable checkbox and a remove button, Add-Component menu greys out attached entries, and conflict hints added (RigidBody <-> CharacterController mutual exclusion, Joint requires RigidBody, Animation requires MeshRenderer, unregistered script name). Scenes persist Active per component (default true).
This commit is contained in:
@@ -328,6 +328,7 @@ namespace Engine
|
||||
u32 collectedCount = 0;
|
||||
scene.Each<TransformComponent, LightComponent>(
|
||||
[&](Entity, TransformComponent& t, LightComponent& light) {
|
||||
if (!light.active) return; // 组件禁用 = 不参与光照
|
||||
if (collectedCount >= kMaxLights) return;
|
||||
|
||||
auto& dst = collected[collectedCount++];
|
||||
@@ -392,6 +393,7 @@ namespace Engine
|
||||
m_EntitySkinBase.clear();
|
||||
scene.Each<MeshRendererComponent, AnimationComponent>(
|
||||
[&](Entity entity, MeshRendererComponent& mr, AnimationComponent& anim) {
|
||||
if (!anim.active) return; // 组件禁用 = 暂停采样(播放头不动)
|
||||
const Model* model = assets.GetModel(mr.model);
|
||||
if (!model || !model->HasAnimations()) return;
|
||||
const auto& clips = model->GetClips();
|
||||
@@ -513,6 +515,7 @@ namespace Engine
|
||||
|
||||
scene.Each<TransformComponent, MeshRendererComponent>(
|
||||
[&](Entity entity, TransformComponent& t, MeshRendererComponent& mr) {
|
||||
if (!mr.active) return; // 组件禁用 = 不渲染不拾取
|
||||
Model* model = assets.GetModel(mr.model);
|
||||
if (!model) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user