Blend tree nodes can now exist without transform components, without the game crashing.
This commit is contained in:
@@ -47,6 +47,7 @@ private:
|
|||||||
// Utility functions
|
// Utility functions
|
||||||
EntityWrapper importEntity(EntityWrapper parent, boost::filesystem::path filePath);
|
EntityWrapper importEntity(EntityWrapper parent, boost::filesystem::path filePath);
|
||||||
void setWidgetMode(EditorGUI::WidgetMode mode);
|
void setWidgetMode(EditorGUI::WidgetMode mode);
|
||||||
|
bool IsAnyParentMissingTransform(EntityID entityID);
|
||||||
|
|
||||||
// GUI callbacks
|
// GUI callbacks
|
||||||
void OnEntitySelected(EntityWrapper entity);
|
void OnEntitySelected(EntityWrapper entity);
|
||||||
|
|||||||
@@ -70,7 +70,11 @@ void EditorSystem::Update(double dt)
|
|||||||
m_EditorGUI->Draw();
|
m_EditorGUI->Draw();
|
||||||
m_EditorStats->Draw(actualDelta);
|
m_EditorStats->Draw(actualDelta);
|
||||||
|
|
||||||
|
if (IsAnyParentMissingTransform(m_CurrentSelection.ID)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (m_CurrentSelection.Valid() && m_Widget.Valid()) {
|
if (m_CurrentSelection.Valid() && m_Widget.Valid()) {
|
||||||
|
|
||||||
(glm::vec3&)m_Widget["Transform"]["Position"] = Transform::AbsolutePosition(m_CurrentSelection);
|
(glm::vec3&)m_Widget["Transform"]["Position"] = Transform::AbsolutePosition(m_CurrentSelection);
|
||||||
if (m_WidgetSpace == EditorGUI::WidgetSpace::Local) {
|
if (m_WidgetSpace == EditorGUI::WidgetSpace::Local) {
|
||||||
(glm::vec3&)m_Widget["Transform"]["Orientation"] = Transform::AbsoluteOrientationEuler(m_CurrentSelection);
|
(glm::vec3&)m_Widget["Transform"]["Orientation"] = Transform::AbsoluteOrientationEuler(m_CurrentSelection);
|
||||||
@@ -78,7 +82,6 @@ void EditorSystem::Update(double dt)
|
|||||||
(glm::vec3&)m_Widget["Transform"]["Orientation"] = glm::vec3(0, 0, 0);
|
(glm::vec3&)m_Widget["Transform"]["Orientation"] = glm::vec3(0, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_EditorWorldSystemPipeline->Update(actualDelta);
|
m_EditorWorldSystemPipeline->Update(actualDelta);
|
||||||
|
|
||||||
ComponentWrapper& cameraTransform = m_EditorCamera["Transform"];
|
ComponentWrapper& cameraTransform = m_EditorCamera["Transform"];
|
||||||
@@ -202,6 +205,9 @@ bool EditorSystem::OnMousePress(const Events::MousePress& e)
|
|||||||
bool EditorSystem::OnWidgetDelta(const Events::WidgetDelta& e)
|
bool EditorSystem::OnWidgetDelta(const Events::WidgetDelta& e)
|
||||||
{
|
{
|
||||||
if (m_CurrentSelection.Valid()) {
|
if (m_CurrentSelection.Valid()) {
|
||||||
|
if (IsAnyParentMissingTransform(m_CurrentSelection.ID)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (m_WidgetSpace == EditorGUI::WidgetSpace::Global) {
|
if (m_WidgetSpace == EditorGUI::WidgetSpace::Global) {
|
||||||
glm::quat parentOrientation;
|
glm::quat parentOrientation;
|
||||||
EntityWrapper parent = m_CurrentSelection.Parent();
|
EntityWrapper parent = m_CurrentSelection.Parent();
|
||||||
@@ -301,3 +307,15 @@ void EditorSystem::setWidgetMode(EditorGUI::WidgetMode mode)
|
|||||||
|
|
||||||
m_Widget["Transform"]["Position"] = Transform::AbsolutePosition(m_CurrentSelection.World, m_CurrentSelection.ID);
|
m_Widget["Transform"]["Position"] = Transform::AbsolutePosition(m_CurrentSelection.World, m_CurrentSelection.ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool EditorSystem::IsAnyParentMissingTransform(EntityID entityID)
|
||||||
|
{
|
||||||
|
EntityWrapper entity(m_World, entityID);
|
||||||
|
while (entity.Parent().Valid()) {
|
||||||
|
if (!entity.HasComponent("Transform")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
entity = entity.Parent();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user