From 485727747cab3ca4f56ba67887bd60a6aa7f5e20 Mon Sep 17 00:00:00 2001 From: TrevorCash Date: Sun, 23 Jan 2022 12:10:36 -0700 Subject: [PATCH 1/2] Move Some Implementations from ndShapeCompount.h to ndShapeCompount.cpp --- .../sdk/dCollision/ndShapeCompound.cpp | 87 +++++++++++++++++++ newton-4.00/sdk/dCollision/ndShapeCompound.h | 85 ------------------ 2 files changed, 87 insertions(+), 85 deletions(-) diff --git a/newton-4.00/sdk/dCollision/ndShapeCompound.cpp b/newton-4.00/sdk/dCollision/ndShapeCompound.cpp index c1416d5aaf..da7242b91d 100644 --- a/newton-4.00/sdk/dCollision/ndShapeCompound.cpp +++ b/newton-4.00/sdk/dCollision/ndShapeCompound.cpp @@ -46,6 +46,93 @@ ndShapeCompound::ndNodeBase::~ndNodeBase() } } + +inline ndShapeCompound::ndNodeBase::ndNodeBase() + :ndClassAlloc() + , m_type(m_node) + , m_left(nullptr) + , m_right(nullptr) + , m_parent(nullptr) + , m_myNode(nullptr) + , m_shapeInstance(nullptr) +{ +} + +inline ndShapeCompound::ndNodeBase::ndNodeBase(const ndNodeBase& copyFrom) + :ndClassAlloc() + , m_p0(copyFrom.m_p0) + , m_p1(copyFrom.m_p1) + , m_size(copyFrom.m_size) + , m_origin(copyFrom.m_origin) + , m_area(copyFrom.m_area) + , m_type(copyFrom.m_type) + , m_left(nullptr) + , m_right(nullptr) + , m_parent(nullptr) + , m_myNode(nullptr) + , m_shapeInstance(nullptr) +{ + dAssert(!copyFrom.m_shapeInstance); +} + +inline ndShapeCompound::ndNodeBase::ndNodeBase(ndShapeInstance* const instance) + :ndClassAlloc() + , m_type(m_leaf) + , m_left(nullptr) + , m_right(nullptr) + , m_parent(nullptr) + , m_myNode(nullptr) + , m_shapeInstance(new ndShapeInstance(*instance)) +{ + CalculateAABB(); +} + +inline ndShapeCompound::ndNodeBase::ndNodeBase(ndNodeBase* const left, ndNodeBase* const right) + :ndClassAlloc() + , m_type(m_node) + , m_left(left) + , m_right(right) + , m_parent(nullptr) + , m_myNode(nullptr) + , m_shapeInstance(nullptr) +{ + m_left->m_parent = this; + m_right->m_parent = this; + + ndVector p0(left->m_p0.GetMin(right->m_p0)); + ndVector p1(left->m_p1.GetMax(right->m_p1)); + SetBox(p0, p1); +} + +inline ndShapeInstance* ndShapeCompound::ndNodeBase::GetShape() const +{ + return m_shapeInstance; +} + +inline void ndShapeCompound::ndNodeBase::CalculateAABB() +{ + ndVector p0; + ndVector p1; + m_shapeInstance->CalculateAabb(m_shapeInstance->GetLocalMatrix(), p0, p1); + SetBox(p0, p1); +} + +inline void ndShapeCompound::ndNodeBase::SetBox(const ndVector& p0, const ndVector& p1) +{ + m_p0 = p0; + m_p1 = p1; + dAssert(m_p0.m_w == ndFloat32(0.0f)); + dAssert(m_p1.m_w == ndFloat32(0.0f)); + m_size = ndVector::m_half * (m_p1 - m_p0); + m_origin = ndVector::m_half * (m_p1 + m_p0); + m_area = m_size.DotProduct(m_size.ShiftTripleRight()).m_x; +} + +inline const ndShapeCompound::ndTreeArray& ndShapeCompound::GetTree() const +{ + return m_array; +} + class ndShapeCompound::ndSpliteInfo { public: diff --git a/newton-4.00/sdk/dCollision/ndShapeCompound.h b/newton-4.00/sdk/dCollision/ndShapeCompound.h index 2a6982ddae..c2c8e80cd5 100644 --- a/newton-4.00/sdk/dCollision/ndShapeCompound.h +++ b/newton-4.00/sdk/dCollision/ndShapeCompound.h @@ -149,91 +149,6 @@ class ndShapeCompound::ndNodeBase: public ndClassAlloc friend class ndStackBvhStackEntry; }; -inline ndShapeCompound::ndNodeBase::ndNodeBase() - :ndClassAlloc() - ,m_type(m_node) - ,m_left(nullptr) - ,m_right(nullptr) - ,m_parent(nullptr) - ,m_myNode(nullptr) - ,m_shapeInstance(nullptr) -{ -} - -inline ndShapeCompound::ndNodeBase::ndNodeBase(const ndNodeBase& copyFrom) - :ndClassAlloc() - ,m_p0(copyFrom.m_p0) - ,m_p1(copyFrom.m_p1) - ,m_size(copyFrom.m_size) - ,m_origin(copyFrom.m_origin) - ,m_area(copyFrom.m_area) - ,m_type(copyFrom.m_type) - ,m_left(nullptr) - ,m_right(nullptr) - ,m_parent(nullptr) - ,m_myNode(nullptr) - ,m_shapeInstance(nullptr) -{ - dAssert(!copyFrom.m_shapeInstance); -} - -inline ndShapeCompound::ndNodeBase::ndNodeBase(ndShapeInstance* const instance) - :ndClassAlloc() - ,m_type(m_leaf) - ,m_left(nullptr) - ,m_right(nullptr) - ,m_parent(nullptr) - ,m_myNode(nullptr) - ,m_shapeInstance(new ndShapeInstance(*instance)) -{ - CalculateAABB(); -} - -inline ndShapeCompound::ndNodeBase::ndNodeBase(ndNodeBase* const left, ndNodeBase* const right) - :ndClassAlloc() - ,m_type(m_node) - ,m_left(left) - ,m_right(right) - ,m_parent(nullptr) - ,m_myNode(nullptr) - ,m_shapeInstance(nullptr) -{ - m_left->m_parent = this; - m_right->m_parent = this; - - ndVector p0(left->m_p0.GetMin(right->m_p0)); - ndVector p1(left->m_p1.GetMax(right->m_p1)); - SetBox(p0, p1); -} - -inline ndShapeInstance* ndShapeCompound::ndNodeBase::GetShape() const -{ - return m_shapeInstance; -} - -inline void ndShapeCompound::ndNodeBase::CalculateAABB() -{ - ndVector p0; - ndVector p1; - m_shapeInstance->CalculateAabb(m_shapeInstance->GetLocalMatrix(), p0, p1); - SetBox(p0, p1); -} - -inline void ndShapeCompound::ndNodeBase::SetBox(const ndVector& p0, const ndVector& p1) -{ - m_p0 = p0; - m_p1 = p1; - dAssert(m_p0.m_w == ndFloat32(0.0f)); - dAssert(m_p1.m_w == ndFloat32(0.0f)); - m_size = ndVector::m_half * (m_p1 - m_p0); - m_origin = ndVector::m_half * (m_p1 + m_p0); - m_area = m_size.DotProduct(m_size.ShiftTripleRight()).m_x; -} - -inline const ndShapeCompound::ndTreeArray& ndShapeCompound::GetTree() const -{ - return m_array; -} #endif From d5ec91fc83fe0442321b480f42908a23a3a51b82 Mon Sep 17 00:00:00 2001 From: TrevorCash Date: Sun, 23 Jan 2022 13:20:09 -0700 Subject: [PATCH 2/2] remove inline on some constructors. some more changes to get things to compile. perhaps the D_API's should be brought out to automatically expose all class members? --- newton-4.00/sdk/dCollision/ndShapeCompound.cpp | 12 ++++++------ newton-4.00/sdk/dCollision/ndShapeCompound.h | 4 ++-- newton-4.00/sdk/dNewton/ndLoadSave.cpp | 4 +++- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/newton-4.00/sdk/dCollision/ndShapeCompound.cpp b/newton-4.00/sdk/dCollision/ndShapeCompound.cpp index da7242b91d..335f84e03a 100644 --- a/newton-4.00/sdk/dCollision/ndShapeCompound.cpp +++ b/newton-4.00/sdk/dCollision/ndShapeCompound.cpp @@ -47,7 +47,7 @@ ndShapeCompound::ndNodeBase::~ndNodeBase() } -inline ndShapeCompound::ndNodeBase::ndNodeBase() +ndShapeCompound::ndNodeBase::ndNodeBase() :ndClassAlloc() , m_type(m_node) , m_left(nullptr) @@ -58,7 +58,7 @@ inline ndShapeCompound::ndNodeBase::ndNodeBase() { } -inline ndShapeCompound::ndNodeBase::ndNodeBase(const ndNodeBase& copyFrom) +ndShapeCompound::ndNodeBase::ndNodeBase(const ndNodeBase& copyFrom) :ndClassAlloc() , m_p0(copyFrom.m_p0) , m_p1(copyFrom.m_p1) @@ -75,7 +75,7 @@ inline ndShapeCompound::ndNodeBase::ndNodeBase(const ndNodeBase& copyFrom) dAssert(!copyFrom.m_shapeInstance); } -inline ndShapeCompound::ndNodeBase::ndNodeBase(ndShapeInstance* const instance) +ndShapeCompound::ndNodeBase::ndNodeBase(ndShapeInstance* const instance) :ndClassAlloc() , m_type(m_leaf) , m_left(nullptr) @@ -87,7 +87,7 @@ inline ndShapeCompound::ndNodeBase::ndNodeBase(ndShapeInstance* const instance) CalculateAABB(); } -inline ndShapeCompound::ndNodeBase::ndNodeBase(ndNodeBase* const left, ndNodeBase* const right) +ndShapeCompound::ndNodeBase::ndNodeBase(ndNodeBase* const left, ndNodeBase* const right) :ndClassAlloc() , m_type(m_node) , m_left(left) @@ -104,7 +104,7 @@ inline ndShapeCompound::ndNodeBase::ndNodeBase(ndNodeBase* const left, ndNodeBas SetBox(p0, p1); } -inline ndShapeInstance* ndShapeCompound::ndNodeBase::GetShape() const +ndShapeInstance* ndShapeCompound::ndNodeBase::GetShape() const { return m_shapeInstance; } @@ -128,7 +128,7 @@ inline void ndShapeCompound::ndNodeBase::SetBox(const ndVector& p0, const ndVect m_area = m_size.DotProduct(m_size.ShiftTripleRight()).m_x; } -inline const ndShapeCompound::ndTreeArray& ndShapeCompound::GetTree() const +const ndShapeCompound::ndTreeArray& ndShapeCompound::GetTree() const { return m_array; } diff --git a/newton-4.00/sdk/dCollision/ndShapeCompound.h b/newton-4.00/sdk/dCollision/ndShapeCompound.h index c2c8e80cd5..44126a5ef1 100644 --- a/newton-4.00/sdk/dCollision/ndShapeCompound.h +++ b/newton-4.00/sdk/dCollision/ndShapeCompound.h @@ -53,7 +53,7 @@ class ndShapeCompound: public ndShape void SetOwner(const ndShapeInstance* const myInstance); - const ndTreeArray& GetTree() const; + D_COLLISION_API const ndTreeArray& GetTree() const; D_COLLISION_API virtual void BeginAddRemove(); D_COLLISION_API virtual ndTreeArray::ndNode* AddCollision(ndShapeInstance* const part); @@ -125,7 +125,7 @@ class ndShapeCompound::ndNodeBase: public ndClassAlloc ~ndNodeBase(); //void Sanity(int level = 0); - ndShapeInstance* GetShape() const; + D_COLLISION_API ndShapeInstance* GetShape() const; private: void CalculateAABB(); diff --git a/newton-4.00/sdk/dNewton/ndLoadSave.cpp b/newton-4.00/sdk/dNewton/ndLoadSave.cpp index 25e7f98444..26558da748 100644 --- a/newton-4.00/sdk/dNewton/ndLoadSave.cpp +++ b/newton-4.00/sdk/dNewton/ndLoadSave.cpp @@ -18,12 +18,14 @@ * * 3. This notice may not be removed or altered from any source distribution. */ - +#include "ndCollisionStdafx.h" #include "ndCoreStdafx.h" #include "ndNewtonStdafx.h" #include "ndWorld.h" #include "ndModel.h" #include "ndLoadSave.h" +#include "ndShapeCompound.h" +#include "ndShapeInstance.h" #include "ndBodyDynamic.h" D_CLASS_REFLECTION_IMPLEMENT_LOADER(ndWordSettings);