diff options
author | Kester Maddock <Christopher.Maddock.1@uni.massey.ac.nz> | 2004-05-16 16:54:44 +0400 |
---|---|---|
committer | Kester Maddock <Christopher.Maddock.1@uni.massey.ac.nz> | 2004-05-16 16:54:44 +0400 |
commit | c50055204df1a73583f646bba688d5f7a76531a8 (patch) | |
tree | 07cc15029e144d08f138e7164e5f6d1edc4651d8 /source/gameengine/SceneGraph/SG_Spatial.cpp | |
parent | 3e6b05f60719f3e04e511c9d52a8f27d7ce3a1a4 (diff) |
SceneGraph support for bounding boxs
Diffstat (limited to 'source/gameengine/SceneGraph/SG_Spatial.cpp')
-rw-r--r-- | source/gameengine/SceneGraph/SG_Spatial.cpp | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/source/gameengine/SceneGraph/SG_Spatial.cpp b/source/gameengine/SceneGraph/SG_Spatial.cpp index 77e805c0758..633e89b3e6a 100644 --- a/source/gameengine/SceneGraph/SG_Spatial.cpp +++ b/source/gameengine/SceneGraph/SG_Spatial.cpp @@ -50,12 +50,12 @@ SG_Spatial( m_localPosition(MT_Point3(0,0,0)), m_localRotation(1,0,0,0,1,0,0,0,1), m_localScaling(MT_Vector3(1.f,1.f,1.f)), - m_parent_relation (NULL), m_worldPosition(MT_Point3(0,0,0)), m_worldRotation(0,0,0,0,0,0,0,0,0), - m_worldScaling(MT_Vector3(1.f,1.f,1.f)) + m_worldScaling(MT_Vector3(1.f,1.f,1.f)), + m_parent_relation (NULL) { } @@ -67,10 +67,14 @@ SG_Spatial( m_localPosition(other.m_localPosition), m_localRotation(other.m_localRotation), m_localScaling(other.m_localScaling), - m_parent_relation(NULL), + m_worldPosition(other.m_worldPosition), m_worldRotation(other.m_worldRotation), - m_worldScaling(other.m_worldScaling) + m_worldScaling(other.m_worldScaling), + + m_parent_relation(NULL), + + m_bbox(other.m_bbox) { // duplicate the parent relation for this object m_parent_relation = other.m_parent_relation->NewCopy(); @@ -285,3 +289,28 @@ GetWorldScaling( return m_worldScaling; } +SG_BBox& SG_Spatial::BBox() +{ + return m_bbox; +} + +void SG_Spatial::SetBBox(SG_BBox& bbox) +{ + m_bbox = bbox; +} + +bool SG_Spatial::inside(const MT_Point3 &point) const +{ + return m_bbox.transform(MT_Transform(m_worldPosition, m_worldRotation.scaled(m_worldScaling[0], m_worldScaling[1], m_worldScaling[2]))).inside(point); +} + +void SG_Spatial::getBBox(MT_Point3 *box) const +{ + m_bbox.get(box, MT_Transform(m_worldPosition, m_worldRotation.scaled(m_worldScaling[0], m_worldScaling[1], m_worldScaling[2]))); +} + +void SG_Spatial::getAABBox(MT_Point3 *box) const +{ + m_bbox.getaa(box, MT_Transform(m_worldPosition, m_worldRotation.scaled(m_worldScaling[0], m_worldScaling[1], m_worldScaling[2]))); +} + |