From ed78298f9b24904e8092573b5380d95801940414 Mon Sep 17 00:00:00 2001 From: Porteries Tristan Date: Thu, 21 Jun 2018 01:03:39 +0200 Subject: [PATCH] UPBGE: Restore and move IsNegativeScaling in SG_Node. --- source/gameengine/Ketsji/KX_FontObject.cpp | 2 +- source/gameengine/Ketsji/KX_GameObject.cpp | 4 +--- source/gameengine/Ketsji/KX_GameObject.h | 3 +-- source/gameengine/SceneGraph/SG_Node.cpp | 5 +++++ source/gameengine/SceneGraph/SG_Node.h | 2 ++ 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/source/gameengine/Ketsji/KX_FontObject.cpp b/source/gameengine/Ketsji/KX_FontObject.cpp index 57b21dbbed66..4e1e6e529e8f 100644 --- a/source/gameengine/Ketsji/KX_FontObject.cpp +++ b/source/gameengine/Ketsji/KX_FontObject.cpp @@ -170,7 +170,7 @@ void KX_FontObject::UpdateBuckets() RAS_TextUser *textUser = (RAS_TextUser *)m_meshUser; textUser->SetColor(mt::vec4(color)); - textUser->SetFrontFace(!m_bIsNegativeScaling); + textUser->SetFrontFace(!IsNegativeScaling()); textUser->SetFontId(m_fontid); textUser->SetSize(size); textUser->SetDpi(m_dpi); diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index fdad48524e3d..49b91abba794 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -112,7 +112,6 @@ KX_GameObject::KX_GameObject(void *sgReplicationInfo, m_currentLodLevel(0), m_meshUser(nullptr), m_convertInfo(nullptr), - m_bIsNegativeScaling(false), m_objectColor(mt::one4), m_bVisible(true), m_bOccluder(false), @@ -144,7 +143,6 @@ KX_GameObject::KX_GameObject(const KX_GameObject& other) m_currentLodLevel(0), m_meshUser(nullptr), m_convertInfo(other.m_convertInfo), - m_bIsNegativeScaling(other.m_bIsNegativeScaling), m_objectColor(other.m_objectColor), m_bVisible(other.m_bVisible), m_bOccluder(other.m_bOccluder), @@ -707,7 +705,7 @@ void KX_GameObject::UpdateBuckets() } m_meshUser->SetColor(m_objectColor); - m_meshUser->SetFrontFace(!m_bIsNegativeScaling); + m_meshUser->SetFrontFace(!IsNegativeScaling()); m_meshUser->ActivateMeshSlots(); } diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index 5f5185b9288d..9dcea6b1056c 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -111,7 +111,6 @@ class KX_GameObject : public SCA_IObject, public mt::SimdClassAllocator /// Info about blender object convert from. BL_ConvertObjectInfo *m_convertInfo; - bool m_bIsNegativeScaling; mt::vec4 m_objectColor; // visible = user setting @@ -809,7 +808,7 @@ class KX_GameObject : public SCA_IObject, public mt::SimdClassAllocator bool IsNegativeScaling( void - ) { return m_bIsNegativeScaling; } + ) { return m_sgNode->IsNegativeScaling(); } /** * \section Logic bubbling methods. diff --git a/source/gameengine/SceneGraph/SG_Node.cpp b/source/gameengine/SceneGraph/SG_Node.cpp index 7b74b5e503b2..8e067e80c48d 100644 --- a/source/gameengine/SceneGraph/SG_Node.cpp +++ b/source/gameengine/SceneGraph/SG_Node.cpp @@ -547,6 +547,11 @@ mt::mat3x4 SG_Node::GetLocalTransform() const return mt::mat3x4(m_localRotation, m_localPosition, m_localScaling); } +bool SG_Node::IsNegativeScaling() const +{ + return (m_worldScaling.x * m_worldScaling.y * m_worldScaling.z) < 0.0f; +} + bool SG_Node::ComputeWorldTransforms(const SG_Node *parent, bool& parentUpdated) { return m_parent_relation->UpdateChildCoordinates(this, parent, parentUpdated); diff --git a/source/gameengine/SceneGraph/SG_Node.h b/source/gameengine/SceneGraph/SG_Node.h index 55a6f4c12f38..c902ba5546e9 100644 --- a/source/gameengine/SceneGraph/SG_Node.h +++ b/source/gameengine/SceneGraph/SG_Node.h @@ -337,6 +337,8 @@ class SG_Node : public SG_QList, public mt::SimdClassAllocator mt::mat3x4 GetWorldTransform() const; mt::mat3x4 GetLocalTransform() const; + bool IsNegativeScaling() const; + bool ComputeWorldTransforms(const SG_Node *parent, bool& parentUpdated); const std::shared_ptr& GetFamilly() const;