修改默认添加尾迹组件
This commit is contained in:
parent
82938b4f52
commit
14dbd31886
@ -114,7 +114,8 @@ Entity* EntitiesManager::CreateMesh(const QString& mesh) {
|
||||
SceneComponent* conponent = ComponentFactory::Create("MeshComponent", nullptr);
|
||||
conponent->SetAttribute("mesh", mesh.toStdString().c_str());
|
||||
conponent->AttachEntity(entity);
|
||||
// Also add PathComponent so the entity has a path attribute by default
|
||||
|
||||
// Also add PathComponent so the entity has a path attribute by default.
|
||||
SceneComponent* rootComponent = entity->GetRootComponent();
|
||||
if (rootComponent) {
|
||||
SceneComponent* pathComponent = ComponentFactory::Create("PathComponent", rootComponent);
|
||||
@ -134,6 +135,26 @@ Entity* EntitiesManager::CreateMesh(const QString& mesh) {
|
||||
}
|
||||
}
|
||||
|
||||
// Add TrajectoryTraceComponent by default for all newly created mesh entities.
|
||||
rootComponent = entity->GetRootComponent();
|
||||
if (rootComponent) {
|
||||
SceneComponent* traceComponent = ComponentFactory::Create("TrajectoryTraceComponent", rootComponent);
|
||||
if (traceComponent) {
|
||||
traceComponent->AttachTo(rootComponent);
|
||||
LOG_INFO("EntitiesManager::CreateMesh - Added TrajectoryTraceComponent");
|
||||
} else {
|
||||
LOG_WARN("EntitiesManager::CreateMesh - Failed to create TrajectoryTraceComponent");
|
||||
}
|
||||
} else {
|
||||
SceneComponent* traceComponent = ComponentFactory::Create("TrajectoryTraceComponent", nullptr);
|
||||
if (traceComponent) {
|
||||
traceComponent->AttachEntity(entity);
|
||||
LOG_INFO("EntitiesManager::CreateMesh - Added TrajectoryTraceComponent with no root");
|
||||
} else {
|
||||
LOG_WARN("EntitiesManager::CreateMesh - Failed to create TrajectoryTraceComponent with no root");
|
||||
}
|
||||
}
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
|
||||
@ -88,6 +88,28 @@ Entity* EntityFactory::CreateEntityWithComponents(const QString& type, const QSt
|
||||
}
|
||||
}
|
||||
|
||||
// Always add TrajectoryTraceComponent so newly created entities can edit/show traces immediately.
|
||||
{
|
||||
SceneComponent* rootComponent = entity->GetRootComponent();
|
||||
if (nullptr == rootComponent) {
|
||||
SceneComponent* traceComponent = ComponentFactory::Create("TrajectoryTraceComponent", nullptr);
|
||||
if (traceComponent) {
|
||||
traceComponent->AttachEntity(entity);
|
||||
LOG_INFO("EntityFactory::CreateEntityWithComponents - Added TrajectoryTraceComponent");
|
||||
} else {
|
||||
LOG_WARN("EntityFactory::CreateEntityWithComponents - Failed to create TrajectoryTraceComponent");
|
||||
}
|
||||
} else {
|
||||
SceneComponent* traceComponent = ComponentFactory::Create("TrajectoryTraceComponent", rootComponent);
|
||||
if (traceComponent) {
|
||||
traceComponent->AttachTo(rootComponent);
|
||||
LOG_INFO("EntityFactory::CreateEntityWithComponents - Added TrajectoryTraceComponent");
|
||||
} else {
|
||||
LOG_WARN("EntityFactory::CreateEntityWithComponents - Failed to create TrajectoryTraceComponent");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add required components
|
||||
QStringList requiredComponents = it->second->GetRequiredComponents();
|
||||
SceneComponent* rootComponent = entity->GetRootComponent();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user