Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/gameengine/SceneGraph')
-rw-r--r--source/gameengine/SceneGraph/SG_BBox.cpp22
-rw-r--r--source/gameengine/SceneGraph/SG_BBox.h22
-rw-r--r--source/gameengine/SceneGraph/SG_Controller.cpp2
-rw-r--r--source/gameengine/SceneGraph/SG_Controller.h22
-rw-r--r--source/gameengine/SceneGraph/SG_DList.h6
-rw-r--r--source/gameengine/SceneGraph/SG_IObject.cpp10
-rw-r--r--source/gameengine/SceneGraph/SG_IObject.h64
-rw-r--r--source/gameengine/SceneGraph/SG_Node.cpp24
-rw-r--r--source/gameengine/SceneGraph/SG_Node.h26
-rw-r--r--source/gameengine/SceneGraph/SG_ParentRelation.h52
-rw-r--r--source/gameengine/SceneGraph/SG_QList.h2
-rw-r--r--source/gameengine/SceneGraph/SG_Spatial.cpp28
-rw-r--r--source/gameengine/SceneGraph/SG_Spatial.h56
-rw-r--r--source/gameengine/SceneGraph/SG_Tree.cpp64
-rw-r--r--source/gameengine/SceneGraph/SG_Tree.h46
15 files changed, 223 insertions, 223 deletions
diff --git a/source/gameengine/SceneGraph/SG_BBox.cpp b/source/gameengine/SceneGraph/SG_BBox.cpp
index f9d83d37384..9eaba788435 100644
--- a/source/gameengine/SceneGraph/SG_BBox.cpp
+++ b/source/gameengine/SceneGraph/SG_BBox.cpp
@@ -32,10 +32,10 @@
#include <math.h>
-
+
#include "SG_BBox.h"
#include "SG_Node.h"
-
+
SG_BBox::SG_BBox() :
m_min(0.0f, 0.0f, 0.0f),
m_max(0.0f, 0.0f, 0.0f)
@@ -81,12 +81,12 @@ SG_BBox& SG_BBox::operator +=(const MT_Point3 &point)
m_min[1] = point[1];
else if (point[1] > m_max[1])
m_max[1] = point[1];
-
+
if (point[2] < m_min[2])
m_min[2] = point[2];
else if (point[2] > m_max[2])
m_max[2] = point[2];
-
+
return *this;
}
@@ -94,7 +94,7 @@ SG_BBox& SG_BBox::operator += (const SG_BBox &bbox)
{
*this += bbox.m_min;
*this += bbox.m_max;
-
+
return *this;
}
@@ -162,7 +162,7 @@ bool SG_BBox::outside(const SG_BBox& other) const
SG_BBox::intersect SG_BBox::test(const SG_BBox& other) const
{
bool point1(inside(other.m_min)), point2(inside(other.m_max));
-
+
return point1?(point2?INSIDE:INTERSECT):(point2?INTERSECT:OUTSIDE);
}
@@ -211,7 +211,7 @@ void SG_BBox::split(SG_BBox &left, SG_BBox &right) const
left.m_max[0] = m_max[0];
left.m_max[1] = m_min[1] + sizey/2.0f;
left.m_max[2] = m_max[2];
-
+
right.m_min[0] = m_min[0];
right.m_min[1] = m_min[1] + sizey/2.0f;
right.m_min[2] = m_min[2];
@@ -223,7 +223,7 @@ void SG_BBox::split(SG_BBox &left, SG_BBox &right) const
left.m_max[0] = m_max[0];
left.m_max[1] = m_max[1];
left.m_max[2] = m_min[2] + sizez/2.0f;
-
+
right.m_min[0] = m_min[0];
right.m_min[1] = m_min[1];
right.m_min[2] = m_min[2] + sizez/2.0f;
@@ -237,7 +237,7 @@ void SG_BBox::split(SG_BBox &left, SG_BBox &right) const
left.m_max[0] = m_min[0] + sizex/2.0f;
left.m_max[1] = m_max[1];
left.m_max[2] = m_max[2];
-
+
right.m_min[0] = m_min[0] + sizex/2.0f;
right.m_min[1] = m_min[1];
right.m_min[2] = m_min[2];
@@ -249,7 +249,7 @@ void SG_BBox::split(SG_BBox &left, SG_BBox &right) const
left.m_max[0] = m_max[0];
left.m_max[1] = m_max[1];
left.m_max[2] = m_min[2] + sizez/2.0f;
-
+
right.m_min[0] = m_min[0];
right.m_min[1] = m_min[1];
right.m_min[2] = m_min[2] + sizez/2.0f;
@@ -257,6 +257,6 @@ void SG_BBox::split(SG_BBox &left, SG_BBox &right) const
std::cout << "splitz" << std::endl;
}
}
-
+
//std::cout << "Left: " << left.m_min << " -> " << left.m_max << " Right: " << right.m_min << " -> " << right.m_max << std::endl;
}
diff --git a/source/gameengine/SceneGraph/SG_BBox.h b/source/gameengine/SceneGraph/SG_BBox.h
index 3c524dc7f18..65fa417d25a 100644
--- a/source/gameengine/SceneGraph/SG_BBox.h
+++ b/source/gameengine/SceneGraph/SG_BBox.h
@@ -29,16 +29,16 @@
* \ingroup bgesg
* \brief Bounding Box
*/
-
+
#ifndef __SG_BBOX_H__
#define __SG_BBOX_H__
-
+
#include "MT_Scalar.h"
#include "MT_Point3.h"
#include "MT_Vector3.h"
#include "MT_Transform.h"
-#include <vector>
+#include <vector>
#ifdef WITH_CXX_GUARDEDALLOC
#include "MEM_guardedalloc.h"
@@ -71,7 +71,7 @@ public:
* Enlarges the bounding box to contain the specified bound box.
*/
SG_BBox& operator +=(const SG_BBox &bbox);
-
+
SG_BBox operator + (const SG_BBox &bbox2) const;
#if 0
/**
@@ -88,12 +88,12 @@ public:
* Computes the volume of the bounding box.
*/
MT_Scalar volume() const;
-
+
/**
* Test if the given point is inside this bounding box.
*/
bool inside(const MT_Point3 &point) const;
-
+
/**
* Test if the given bounding box is inside this bounding box.
*/
@@ -103,17 +103,17 @@ public:
* Test if the given bounding box is outside this bounding box.
*/
bool outside(const SG_BBox &other) const;
-
+
/**
* Test if the given bounding box intersects this bounding box.
*/
bool intersects(const SG_BBox &other) const;
-
+
/**
* Test the given bounding box with this bounding box.
*/
intersect test(const SG_BBox &other) const;
-
+
/**
* Get the eight points that define this bounding box.
*
@@ -127,11 +127,11 @@ public:
* \param world a world transform to be applied.
*/
void getaa(MT_Point3 *box, const MT_Transform &world) const;
-
+
void getmm(MT_Point3 *box, const MT_Transform &world) const;
void split(SG_BBox &left, SG_BBox &right) const;
-
+
friend class SG_Tree;
diff --git a/source/gameengine/SceneGraph/SG_Controller.cpp b/source/gameengine/SceneGraph/SG_Controller.cpp
index 264942415c9..1731b572fbd 100644
--- a/source/gameengine/SceneGraph/SG_Controller.cpp
+++ b/source/gameengine/SceneGraph/SG_Controller.cpp
@@ -31,7 +31,7 @@
#include "SG_Controller.h"
- void
+ void
SG_Controller::
SetObject(SG_IObject* obj)
{
diff --git a/source/gameengine/SceneGraph/SG_Controller.h b/source/gameengine/SceneGraph/SG_Controller.h
index a173633e13c..000be4f871a 100644
--- a/source/gameengine/SceneGraph/SG_Controller.h
+++ b/source/gameengine/SceneGraph/SG_Controller.h
@@ -31,7 +31,7 @@
/** \file SG_Controller.h
* \ingroup bgesg
*/
-
+
#ifndef __SG_CONTROLLER_H__
#define __SG_CONTROLLER_H__
@@ -40,7 +40,7 @@
/**
* A scenegraph controller
*/
-class SG_Controller
+class SG_Controller
{
public:
SG_Controller(
@@ -48,18 +48,18 @@ public:
m_pObject(NULL) {
}
- virtual
+ virtual
~SG_Controller(
) {};
- virtual
+ virtual
bool
Update(
double time
)=0;
- virtual
- void
+ virtual
+ void
SetObject (
SG_IObject* object
);
@@ -68,7 +68,7 @@ public:
ClearObject(
);
- virtual
+ virtual
void
SetSimulatedTime(
double time
@@ -84,8 +84,8 @@ public:
* Hacky way of passing options to specific controllers
* \param option An integer identifying the option.
* \param value The value of this option.
- * \attention This has been placed here to give sca-elements
- * \attention some control over the controllers. This is
+ * \attention This has been placed here to give sca-elements
+ * \attention some control over the controllers. This is
* \attention necessary because the identity of the controller
* \attention is lost on the way here.
*/
@@ -97,8 +97,8 @@ public:
)=0;
/**
- * Option-identifiers: SG_CONTR_<controller-type>_<option>.
- * Options only apply to a specific controller type. The
+ * Option-identifiers: SG_CONTR_<controller-type>_<option>.
+ * Options only apply to a specific controller type. The
* semantics are defined by whoever uses the setting.
*/
enum SG_Controller_option {
diff --git a/source/gameengine/SceneGraph/SG_DList.h b/source/gameengine/SceneGraph/SG_DList.h
index 90153f14c07..6e0998a197e 100644
--- a/source/gameengine/SceneGraph/SG_DList.h
+++ b/source/gameengine/SceneGraph/SG_DList.h
@@ -28,7 +28,7 @@
/** \file SG_DList.h
* \ingroup bgesg
*/
-
+
#ifndef __SG_DLIST_H__
#define __SG_DLIST_H__
@@ -214,8 +214,8 @@ public:
{
return this;
}
-
-
+
+
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("GE:SG_DList")
#endif
diff --git a/source/gameengine/SceneGraph/SG_IObject.cpp b/source/gameengine/SceneGraph/SG_IObject.cpp
index 9ae32a89ff8..4e8c56da8a7 100644
--- a/source/gameengine/SceneGraph/SG_IObject.cpp
+++ b/source/gameengine/SceneGraph/SG_IObject.cpp
@@ -42,7 +42,7 @@ SG_IObject(
void* clientobj,
void* clientinfo,
SG_Callbacks& callbacks
-):
+):
SG_QList(),
m_SGclientObject(clientobj),
m_SGclientInfo(clientinfo)
@@ -57,12 +57,12 @@ SG_IObject(
SG_QList(),
m_SGclientObject(other.m_SGclientObject),
m_SGclientInfo(other.m_SGclientInfo),
- m_callbacks(other.m_callbacks)
+ m_callbacks(other.m_callbacks)
{
//nothing to do
}
- void
+ void
SG_IObject::
AddSGController(
SG_Controller* cont
@@ -83,8 +83,8 @@ RemoveSGController(
void
SG_IObject::
RemoveAllControllers(
-) {
- m_SGcontrollers.clear();
+) {
+ m_SGcontrollers.clear();
}
void SG_IObject::SetControllerTime(double time)
diff --git a/source/gameengine/SceneGraph/SG_IObject.h b/source/gameengine/SceneGraph/SG_IObject.h
index 2dcf3c6492e..91f53d04c90 100644
--- a/source/gameengine/SceneGraph/SG_IObject.h
+++ b/source/gameengine/SceneGraph/SG_IObject.h
@@ -28,7 +28,7 @@
/** \file SG_IObject.h
* \ingroup bgesg
*/
-
+
#ifndef __SG_IOBJECT_H__
#define __SG_IOBJECT_H__
@@ -63,7 +63,7 @@ inline void SG_SetActiveStage(SG_Stage stage)
{
gSG_Stage = stage;
}
-
+
class SG_Controller;
@@ -109,13 +109,13 @@ typedef bool (*SG_RescheduleUpdateCallback)(
* with replicated nodes and their children.
* The second is called when a node is destroyed and again
* is their for synchronization purposes
- * These callbacks may both be NULL.
- * The efficacy of this approach has not been proved some
+ * These callbacks may both be NULL.
+ * The efficacy of this approach has not been proved some
* alternatives might be to perform all replication and destruction
- * externally.
+ * externally.
* To define a class interface rather than a simple function
- * call back so that replication information can be transmitted from
- * parent->child.
+ * call back so that replication information can be transmitted from
+ * parent->child.
*/
struct SG_Callbacks
{
@@ -135,7 +135,7 @@ struct SG_Callbacks
SG_UpdateTransformCallback updatefunc,
SG_ScheduleUpdateCallback schedulefunc,
SG_RescheduleUpdateCallback reschedulefunc
- ):
+ ):
m_replicafunc(repfunc),
m_destructionfunc(destructfunc),
m_updatefunc(updatefunc),
@@ -168,12 +168,12 @@ public:
/**
- * Add a pointer to a controller allocated on the heap, to
- * this node. This memory for this controller becomes the
+ * Add a pointer to a controller allocated on the heap, to
+ * this node. This memory for this controller becomes the
* responsibility of this class. It will be deleted when
* this object is deleted.
*/
-
+
void
AddSGController(
SG_Controller* cont
@@ -189,45 +189,45 @@ public:
SG_Controller* cont
);
- /**
- * Clear the array of pointers to controllers associated with
+ /**
+ * Clear the array of pointers to controllers associated with
* this node. This does not delete the controllers themselves!
* This should be used very carefully to avoid memory
* leaks.
*/
-
+
void
RemoveAllControllers(
- );
+ );
/// Needed for replication
- /**
- * Return a reference to this node's controller list.
+ /**
+ * Return a reference to this node's controller list.
* Whilst we don't wish to expose full control of the container
* to the user we do allow them to call non_const methods
* on pointers in the container. C++ topic: how to do this in
- * using STL?
+ * using STL?
*/
SGControllerList& GetSGControllerList()
- {
- return m_SGcontrollers;
+ {
+ return m_SGcontrollers;
}
/**
- *
+ *
*/
SG_Callbacks& GetCallBackFunctions()
{
return m_callbacks;
}
-
+
/**
* Get the client object associated with this
* node. This interface allows you to associate
* arbitrary external objects with this node. They are
- * passed to the callback functions when they are
+ * passed to the callback functions when they are
* activated so you can synchronize these external objects
* upon replication and destruction
* This may be NULL.
@@ -239,17 +239,17 @@ public:
}
inline void* GetSGClientObject()
- {
+ {
return m_SGclientObject;
}
/**
- * Set the client object for this node. This is just a
- * pointer to an object allocated that should exist for
+ * Set the client object for this node. This is just a
+ * pointer to an object allocated that should exist for
* the duration of the lifetime of this object, or until
* this function is called again.
*/
-
+
void SetSGClientObject(void* clientObject)
{
m_SGclientObject = clientObject;
@@ -271,15 +271,15 @@ public:
}
- /**
+ /**
* Set the current simulation time for this node.
* The implementation of this function runs through
* the nodes list of controllers and calls their SetSimulatedTime methods
*/
-
+
void SetControllerTime(double time);
-
- virtual
+
+ virtual
void
Destruct(
) = 0;
@@ -316,7 +316,7 @@ protected :
delete this;
}
}
-
+
void
ActivateUpdateTransformCallback(
)
diff --git a/source/gameengine/SceneGraph/SG_Node.cpp b/source/gameengine/SceneGraph/SG_Node.cpp
index 04d9a306fc4..82c7230c31e 100644
--- a/source/gameengine/SceneGraph/SG_Node.cpp
+++ b/source/gameengine/SceneGraph/SG_Node.cpp
@@ -70,17 +70,17 @@ SG_Node* SG_Node::GetSGReplica()
if (replica == NULL) return NULL;
ProcessSGReplica(&replica);
-
+
return replica;
}
- void
+ void
SG_Node::
ProcessSGReplica(
SG_Node** replica
) {
// Apply the replication call back function.
- if (!ActivateReplicationCallback(*replica))
+ if (!ActivateReplicationCallback(*replica))
{
delete (*replica);
*replica = NULL;
@@ -94,7 +94,7 @@ ProcessSGReplica(
{
// if this node has children, the replica has too, so clear and clone children
(*replica)->ClearSGChildren();
-
+
NodeList::iterator childit;
for (childit = m_children.begin();childit!=m_children.end();++childit)
{
@@ -107,7 +107,7 @@ ProcessSGReplica(
// not worth to keep, they will just take up CPU
// This can happen in partial replication of hierarchy
// during group duplication.
- if ((*replica)->m_children.empty() &&
+ if ((*replica)->m_children.empty() &&
(*replica)->GetSGClientObject() == NULL)
{
delete (*replica);
@@ -116,16 +116,16 @@ ProcessSGReplica(
}
- void
+ void
SG_Node::
Destruct()
{
// Not entirely sure what Destruct() expects to happen.
// I think it probably means just to call the DestructionCallback
// in the right order on all the children - rather than free any memory
-
+
// We'll delete m_parent_relation now anyway.
-
+
delete(m_parent_relation);
m_parent_relation = NULL;
@@ -142,7 +142,7 @@ Destruct()
ActivateDestructionCallback();
}
-const
+const
SG_Node *
SG_Node::
GetRootSGParent(
@@ -152,11 +152,11 @@ GetRootSGParent(
bool SG_Node::IsAncessor(const SG_Node* child) const
{
- return (!child->m_SGparent) ? false :
+ return (!child->m_SGparent) ? false :
(child->m_SGparent == this) ? true : IsAncessor(child->m_SGparent);
}
- void
+ void
SG_Node::
DisconnectFromParent(
) {
@@ -192,7 +192,7 @@ void SG_Node::UpdateWorldData(double time, bool parentUpdated)
// return;
if (UpdateSpatialData(GetSGParent(),time,parentUpdated))
- // to update the
+ // to update the
ActivateUpdateTransformCallback();
// The node is updated, remove it from the update list
diff --git a/source/gameengine/SceneGraph/SG_Node.h b/source/gameengine/SceneGraph/SG_Node.h
index bde64f21305..8043fed082c 100644
--- a/source/gameengine/SceneGraph/SG_Node.h
+++ b/source/gameengine/SceneGraph/SG_Node.h
@@ -28,7 +28,7 @@
/** \file SG_Node.h
* \ingroup bgesg
*/
-
+
#ifndef __SG_NODE_H__
#define __SG_NODE_H__
@@ -68,7 +68,7 @@ public:
SG_Node* child
);
- /**
+ /**
* Remove a child node from this object. This just removes the child
* pointer from the list of children - it does not destroy the child.
* This does not inform the child that this node is no longer it's parent.
@@ -87,13 +87,13 @@ public:
IsAncessor(
const SG_Node* child
) const;
- /**
+ /**
* Get the current list of children. Do not use this interface for
* adding or removing children please use the methods of this class for
* that.
* \return a reference to the list of children of this node.
*/
-
+
NodeList& GetSGChildren()
{
return this->m_children;
@@ -109,7 +109,7 @@ public:
return this->m_children;
}
- /**
+ /**
* Clear the list of children associated with this node
*/
@@ -121,14 +121,14 @@ public:
/**
* return the parent of this node if it exists.
*/
-
- SG_Node* GetSGParent() const
- {
+
+ SG_Node* GetSGParent() const
+ {
return m_SGparent;
}
/**
- * Set the parent of this node.
+ * Set the parent of this node.
*/
void SetSGParent(SG_Node* parent)
@@ -139,9 +139,9 @@ public:
/**
* Return the top node in this node's Scene graph hierarchy
*/
-
- const
- SG_Node*
+
+ const
+ SG_Node*
GetRootSGParent(
) const;
@@ -251,7 +251,7 @@ public:
void
Destruct(
);
-
+
private:
void
diff --git a/source/gameengine/SceneGraph/SG_ParentRelation.h b/source/gameengine/SceneGraph/SG_ParentRelation.h
index ce45b42c148..e6cbc358cf4 100644
--- a/source/gameengine/SceneGraph/SG_ParentRelation.h
+++ b/source/gameengine/SceneGraph/SG_ParentRelation.h
@@ -23,27 +23,27 @@
* Contributor(s): none yet.
*
* ***** END GPL LICENSE BLOCK *****
- *
+ *
*/
/** \file SG_ParentRelation.h
* \ingroup bgesg
- * \page SG_ParentRelationPage SG_ParentRelation
+ * \page SG_ParentRelationPage SG_ParentRelation
*
* \section SG_ParentRelationSection SG_ParentRelation
- *
- * This is an abstract interface class to the Scene Graph library.
+ *
+ * This is an abstract interface class to the Scene Graph library.
* It allows you to specify how child nodes react to parent nodes.
* Normally a child will use it's parent's transforms to compute
* it's own global transforms. How this is performed depends on
- * the type of relation. For example if the parent is a vertex
- * parent to this child then the child should not inherit any
+ * the type of relation. For example if the parent is a vertex
+ * parent to this child then the child should not inherit any
* rotation information from the parent. Or if the parent is a
- * 'slow parent' to this child then the child should react
+ * 'slow parent' to this child then the child should react
* slowly to changes in the parent's position. The exact relation
- * is left for you to implement by filling out this interface
- * with concrete examples.
- *
+ * is left for you to implement by filling out this interface
+ * with concrete examples.
+ *
* There is exactly one SG_ParentRelation per SG_Node. Subclasses
* should not be value types and should be allocated on the heap.
*
@@ -59,13 +59,13 @@ class SG_ParentRelation {
public :
/**
* Update the childs local and global coordinates
- * based upon the parents global coordinates.
+ * based upon the parents global coordinates.
* You must also handle the case when this node has no
- * parent (parent == NULL). Usually you should just
- * copy the local coordinates of the child to the
+ * parent (parent == NULL). Usually you should just
+ * copy the local coordinates of the child to the
* world coordinates.
- */
-
+ */
+
virtual
bool
UpdateChildCoordinates(
@@ -74,11 +74,11 @@ public :
bool& parentUpdated
) = 0;
- virtual
+ virtual
~SG_ParentRelation(
) {};
- /**
+ /**
* You must provide a way of duplicating an
* instance of an SG_ParentRelation. This should
* return a pointer to a new duplicate allocated
@@ -86,7 +86,7 @@ public :
* duplicate resides with the caller of this method.
*/
- virtual
+ virtual
SG_ParentRelation *
NewCopy(
) = 0;
@@ -97,23 +97,23 @@ public :
virtual
bool
IsVertexRelation(
- ) {
+ ) {
return false;
}
-
+
/**
* Need this to see if we are able to adjust time-offset from the python api
*/
virtual
bool
IsSlowRelation(
- ) {
+ ) {
return false;
}
protected :
- /**
- * Protected constructors
+ /**
+ * Protected constructors
* this class is not meant to be instantiated.
*/
@@ -127,9 +127,9 @@ protected :
SG_ParentRelation(
const SG_ParentRelation &
- );
-
-
+ );
+
+
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("GE:SG_ParentRelation")
#endif
diff --git a/source/gameengine/SceneGraph/SG_QList.h b/source/gameengine/SceneGraph/SG_QList.h
index 663f29ebd88..baf5f52f3e6 100644
--- a/source/gameengine/SceneGraph/SG_QList.h
+++ b/source/gameengine/SceneGraph/SG_QList.h
@@ -28,7 +28,7 @@
/** \file SG_QList.h
* \ingroup bgesg
*/
-
+
#ifndef __SG_QLIST_H__
#define __SG_QLIST_H__
diff --git a/source/gameengine/SceneGraph/SG_Spatial.cpp b/source/gameengine/SceneGraph/SG_Spatial.cpp
index 5cb75873237..561d3b30cd8 100644
--- a/source/gameengine/SceneGraph/SG_Spatial.cpp
+++ b/source/gameengine/SceneGraph/SG_Spatial.cpp
@@ -40,19 +40,19 @@ SG_Spatial(
void* clientobj,
void* clientinfo,
SG_Callbacks& callbacks
-):
+):
SG_IObject(clientobj,clientinfo,callbacks),
m_localPosition(0.0f,0.0f,0.0f),
m_localRotation(1.0f,0.0f,0.0f,0.0f,1.0f,0.0f,0.0f,0.0f,1.0f),
m_localScaling(1.0f,1.0f,1.0f),
-
+
m_worldPosition(0.0f,0.0f,0.0f),
m_worldRotation(1.0f,0.0f,0.0f,0.0f,1.0f,0.0f,0.0f,0.0f,1.0f),
m_worldScaling(1.0f,1.0f,1.0f),
m_parent_relation (NULL),
-
+
m_bbox(MT_Point3(-1.0f, -1.0f, -1.0f), MT_Point3(1.0f, 1.0f, 1.0f)),
m_radius(1.0f),
m_modified(false),
@@ -63,18 +63,18 @@ SG_Spatial(
SG_Spatial::
SG_Spatial(
const SG_Spatial& other
-) :
+) :
SG_IObject(other),
m_localPosition(other.m_localPosition),
m_localRotation(other.m_localRotation),
m_localScaling(other.m_localScaling),
-
+
m_worldPosition(other.m_worldPosition),
m_worldRotation(other.m_worldRotation),
m_worldScaling(other.m_worldScaling),
-
+
m_parent_relation(NULL),
-
+
m_bbox(other.m_bbox),
m_radius(other.m_radius),
m_modified(false),
@@ -83,7 +83,7 @@ SG_Spatial(
// duplicate the parent relation for this object
m_parent_relation = other.m_parent_relation->NewCopy();
}
-
+
SG_Spatial::
~SG_Spatial()
{
@@ -142,7 +142,7 @@ UpdateSpatialData(
*/
- void
+ void
SG_Spatial::
RelativeTranslate(
const MT_Vector3& trans,
@@ -166,7 +166,7 @@ RelativeTranslate(
/**
* Scaling methods.
- */
+ */
/**
@@ -174,15 +174,15 @@ RelativeTranslate(
*/
- void
+ void
SG_Spatial::
RelativeRotate(
const MT_Matrix3x3& rot,
bool local
) {
m_localRotation = m_localRotation * (
- local ?
- rot
+ local ?
+ rot
:
(GetWorldOrientation().inverse() * rot * GetWorldOrientation()));
SetModified();
@@ -192,7 +192,7 @@ RelativeRotate(
MT_Transform SG_Spatial::GetWorldTransform() const
{
- return MT_Transform(m_worldPosition,
+ return MT_Transform(m_worldPosition,
m_worldRotation.scaled(
m_worldScaling[0], m_worldScaling[1], m_worldScaling[2]));
}
diff --git a/source/gameengine/SceneGraph/SG_Spatial.h b/source/gameengine/SceneGraph/SG_Spatial.h
index aa917fa70db..7fa21506675 100644
--- a/source/gameengine/SceneGraph/SG_Spatial.h
+++ b/source/gameengine/SceneGraph/SG_Spatial.h
@@ -28,7 +28,7 @@
/** \file SG_Spatial.h
* \ingroup bgesg
*/
-
+
#ifndef __SG_SPATIAL_H__
#define __SG_SPATIAL_H__
@@ -44,7 +44,7 @@ class SG_Node;
class SG_ParentRelation;
/**
- * SG_Spatial contains spatial information (local & world position, rotation
+ * SG_Spatial contains spatial information (local & world position, rotation
* and scaling) for a Scene graph node.
* It also contains a link to the node's parent.
*/
@@ -59,18 +59,18 @@ protected:
MT_Point3 m_worldPosition;
MT_Matrix3x3 m_worldRotation;
MT_Vector3 m_worldScaling;
-
+
SG_ParentRelation * m_parent_relation;
-
+
SG_BBox m_bbox;
MT_Scalar m_radius;
bool m_modified;
bool m_ogldirty; // true if the openGL matrix for this object must be recomputed
public:
- inline void ClearModified()
- {
- m_modified = false;
+ inline void ClearModified()
+ {
+ m_modified = false;
m_ogldirty = true;
}
inline void SetModified()
@@ -82,15 +82,15 @@ public:
{
m_ogldirty = false;
}
- /**
+ /**
* Define the relationship this node has with it's parent
* node. You should pass an unshared instance of an SG_ParentRelation
* allocated on the heap to this method. Ownership of this
- * instance is assumed by this class.
- * You may call this function several times in the lifetime
- * of a node to change the relationship dynamically.
+ * instance is assumed by this class.
+ * You may call this function several times in the lifetime
+ * of a node to change the relationship dynamically.
* You must call this method before the first call to UpdateSpatialData().
- * An assertion will be fired at run-time in debug if this is not
+ * An assertion will be fired at run-time in debug if this is not
* the case.
* The relation is activated only if no controllers of this object
* updated the coordinates of the child.
@@ -100,7 +100,7 @@ public:
SetParentRelation(
SG_ParentRelation *relation
);
-
+
SG_ParentRelation * GetParentRelation()
{
return m_parent_relation;
@@ -111,12 +111,12 @@ public:
/**
* Apply a translation relative to the current position.
- * if local then the translation is assumed to be in the
+ * if local then the translation is assumed to be in the
* local coordinates of this object. If not then the translation
- * is assumed to be in global coordinates. In this case
- * you must provide a pointer to the parent of this object if it
+ * is assumed to be in global coordinates. In this case
+ * you must provide a pointer to the parent of this object if it
* exists otherwise if there is no parent set it to NULL
- */
+ */
void
RelativeTranslate(
@@ -136,7 +136,7 @@ public:
m_worldPosition = trans;
}
-
+
void
RelativeRotate(
const MT_Matrix3x3& rot,
@@ -156,7 +156,7 @@ public:
SetModified();
}
- void SetWorldOrientation(const MT_Matrix3x3& rot)
+ void SetWorldOrientation(const MT_Matrix3x3& rot)
{
m_worldRotation = rot;
}
@@ -174,7 +174,7 @@ public:
}
void SetWorldScale(const MT_Vector3& scale)
- {
+ {
m_worldScaling = scale;
}
@@ -242,20 +242,20 @@ public:
bool inside(const MT_Point3 &point) const;
void getBBox(MT_Point3 *box) const;
void getAABBox(MT_Point3 *box) const;
-
+
MT_Scalar Radius() const { return m_radius; }
void SetRadius(MT_Scalar radius) { m_radius = radius; }
bool IsModified() { return m_modified; }
bool IsDirty() { return m_ogldirty; }
-
+
protected:
friend class SG_Controller;
friend class KX_BoneParentRelation;
friend class KX_VertexParentRelation;
friend class KX_SlowParentRelation;
friend class KX_NormalParentRelation;
-
- /**
+
+ /**
* Protected constructor this class is not
* designed for direct instantiation
*/
@@ -273,12 +273,12 @@ protected:
virtual ~SG_Spatial();
- /**
+ /**
* Update the world coordinates of this spatial node. This also informs
- * any controllers to update this object.
- */
+ * any controllers to update this object.
+ */
- bool
+ bool
UpdateSpatialData(
const SG_Spatial *parent,
double time,
diff --git a/source/gameengine/SceneGraph/SG_Tree.cpp b/source/gameengine/SceneGraph/SG_Tree.cpp
index 87feb2c012a..6dfc1e52a89 100644
--- a/source/gameengine/SceneGraph/SG_Tree.cpp
+++ b/source/gameengine/SceneGraph/SG_Tree.cpp
@@ -32,7 +32,7 @@
#include <math.h>
-
+
#include "SG_BBox.h"
#include "SG_Tree.h"
#include "SG_Node.h"
@@ -65,7 +65,7 @@ SG_Tree::SG_Tree(SG_Tree* left, SG_Tree* right) :
m_center = (m_bbox.m_min + m_bbox.m_max)/2.0f;
m_radius = (m_bbox.m_max - m_bbox.m_min).length();
}
-
+
SG_Tree::SG_Tree(SG_Node* client) :
m_left(NULL),
m_right(NULL),
@@ -77,15 +77,15 @@ SG_Tree::SG_Tree(SG_Node* client) :
m_radius = (m_bbox.m_max - m_bbox.m_min).length();
}
-SG_Tree::~SG_Tree()
+SG_Tree::~SG_Tree()
{
}
-
+
MT_Scalar SG_Tree::volume() const
{
return m_bbox.volume();
}
-
+
void SG_Tree::dump() const
{
if (m_left)
@@ -117,27 +117,27 @@ SG_Tree* SG_Tree::Find(SG_Node *node)
{
if (m_client_object == node)
return this;
-
+
SG_Tree *left = m_left, *right = m_right;
-
+
if (left && right)
{
if (right->m_bbox.intersects(node->BBox()))
std::swap(left, right);
}
-
+
if (left)
{
SG_Tree* ret = left->Find(node);
if (ret) return ret;
}
-
+
if (right)
{
SG_Tree* ret = right->Find(node);
if (ret) return ret;
}
-
+
return NULL;
}
@@ -185,7 +185,7 @@ class HalfArray
public:
HalfArray() {}
~HalfArray() {}
-
+
void resize(unsigned int size)
{
m_array.resize(size);
@@ -194,13 +194,13 @@ public:
m_array[i].resize(size - i);
}
}
-
+
T& operator() (unsigned int x, unsigned int y)
{
assert(x >= y);
return m_array[y][x - y];
}
-
+
void erase_column (unsigned int x)
{
for (unsigned int y = 0; y <= x; y++)
@@ -215,7 +215,7 @@ public:
m_array[y].erase(m_array[y].begin() + x - y);
}
}
-
+
void erase_row (unsigned int y)
{
m_array.erase(m_array.begin() + y);
@@ -229,7 +229,7 @@ SG_TreeFactory::SG_TreeFactory()
SG_TreeFactory::~SG_TreeFactory()
{
}
-
+
void SG_TreeFactory::Add(SG_Node* client)
{
if (client)
@@ -247,7 +247,7 @@ SG_Tree* SG_TreeFactory::MakeTreeDown(SG_BBox &bbox)
return NULL;
if (m_objects.size() == 1)
return *m_objects.begin();
-
+
TreeSet::iterator it = m_objects.begin();
SG_Tree *root = *it;
if (m_objects.size() == 2)
@@ -255,7 +255,7 @@ SG_Tree* SG_TreeFactory::MakeTreeDown(SG_BBox &bbox)
root->SetRight(*(++it));
return root;
}
-
+
if (m_objects.size() == 3)
{
root->SetLeft(*(++it));
@@ -265,26 +265,26 @@ SG_Tree* SG_TreeFactory::MakeTreeDown(SG_BBox &bbox)
if (bbox.volume() < 1.0f)
return MakeTreeUp();
-
+
SG_TreeFactory lefttree;
SG_TreeFactory righttree;
-
+
SG_BBox left, right;
int hasleft = 0, hasright = 0;
bbox.split(left, right);
-
+
if (left.test(root->BBox()) == SG_BBox::INSIDE)
{
lefttree.Add(root);
root = NULL;
}
-
+
if (root && right.test(root->BBox()) == SG_BBox::INSIDE)
{
righttree.Add(root);
root = NULL;
}
-
+
for (++it; it != m_objects.end(); ++it)
{
switch (left.test((*it)->BBox()))
@@ -312,15 +312,15 @@ SG_Tree* SG_TreeFactory::MakeTreeDown(SG_BBox &bbox)
}
}
std::cout << "Left: " << hasleft << " Right: " << hasright << " Count: " << m_objects.size() << std::endl;
-
+
SG_Tree *leftnode = NULL;
if (hasleft)
leftnode = lefttree.MakeTreeDown(left);
-
+
SG_Tree *rightnode = NULL;
if (hasright)
rightnode = righttree.MakeTreeDown(right);
-
+
if (!root)
root = new SG_Tree(leftnode, rightnode);
else
@@ -343,14 +343,14 @@ SG_Tree* SG_TreeFactory::MakeTree()
SG_BBox bbox((*it)->BBox());
for (++it; it != m_objects.end(); ++it)
bbox += (*it)->BBox();
-
+
return MakeTreeDown(bbox);
}
SG_Tree* SG_TreeFactory::MakeTreeUp()
{
unsigned int num_objects = m_objects.size();
-
+
if (num_objects < 1)
return NULL;
if (num_objects < 2)
@@ -358,7 +358,7 @@ SG_Tree* SG_TreeFactory::MakeTreeUp()
HalfArray<SG_Tree*> sizes;
sizes.resize(num_objects);
-
+
unsigned int x, y;
TreeSet::iterator xit, yit;
for ( y = 0, yit = m_objects.begin(); y < num_objects; y++, ++yit)
@@ -368,7 +368,7 @@ SG_Tree* SG_TreeFactory::MakeTreeUp()
for ( x = y+1, ++xit; x < num_objects; x++, ++xit)
{
sizes(x, y) = new SG_Tree(*xit, *yit);
-
+
}
}
while (num_objects > 2)
@@ -391,10 +391,10 @@ SG_Tree* SG_TreeFactory::MakeTreeUp()
}
}
}
-
+
/* Remove other bboxes that contain the two bboxes */
sizes.delete_column(miny);
-
+
for ( x = miny + 1; x < num_objects; x++)
{
if (x == minx)
@@ -402,7 +402,7 @@ SG_Tree* SG_TreeFactory::MakeTreeUp()
delete sizes(x, miny);
}
sizes.erase_row(miny);
-
+
num_objects--;
minx--;
sizes(minx, minx) = min;
diff --git a/source/gameengine/SceneGraph/SG_Tree.h b/source/gameengine/SceneGraph/SG_Tree.h
index 339862c652f..b0eaea814e8 100644
--- a/source/gameengine/SceneGraph/SG_Tree.h
+++ b/source/gameengine/SceneGraph/SG_Tree.h
@@ -24,18 +24,18 @@
*
* ***** END GPL LICENSE BLOCK *****
*/
-
+
/** \file SG_Tree.h
* \ingroup bgesg
*/
-
+
#ifndef __SG_TREE_H__
#define __SG_TREE_H__
-
+
#include "MT_Point3.h"
#include "SG_BBox.h"
-#include <set>
+#include <set>
class SG_Node;
@@ -44,7 +44,7 @@ class SG_Node;
* SG_Tree.
* Holds a binary tree of SG_Nodes.
*/
-class SG_Tree
+class SG_Tree
{
SG_Tree* m_left;
SG_Tree* m_right;
@@ -56,27 +56,27 @@ class SG_Tree
public:
SG_Tree();
SG_Tree(SG_Tree* left, SG_Tree* right);
-
+
SG_Tree(SG_Node* client);
~SG_Tree();
-
+
/**
* Computes the volume of the bounding box.
*/
MT_Scalar volume() const;
-
+
/**
* Prints the tree (for debugging.)
*/
void dump() const;
-
+
/**
* Returns the left node.
*/
SG_Tree *Left() const;
SG_Tree *Right() const;
SG_Node *Client() const;
-
+
SG_Tree* Find(SG_Node *node);
/**
* Gets the eight corners of this treenode's bounding box,
@@ -90,20 +90,20 @@ public:
* Get the tree node's bounding box.
*/
const SG_BBox& BBox() const;
-
+
/**
* Test if the given bounding box is inside this bounding box.
*/
bool inside(const MT_Point3 &point) const;
-
+
void SetLeft(SG_Tree *left);
void SetRight(SG_Tree *right);
MT_Point3 Center() const { return m_center; }
MT_Scalar Radius() { return m_radius; }
-
+
//friend class SG_TreeFactory;
-
+
struct greater
{
bool operator()(const SG_Tree *a, const SG_Tree *b)
@@ -111,9 +111,9 @@ public:
return a->volume() > b->volume();
}
};
-
-
-
+
+
+
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("GE:SG_Tree")
#endif
@@ -127,14 +127,14 @@ public:
* cf building an optimized Huffman tree.
* \warning O(n^3)!!!
*/
-class SG_TreeFactory
+class SG_TreeFactory
{
typedef std::multiset<SG_Tree*, SG_Tree::greater> TreeSet;
TreeSet m_objects;
public:
SG_TreeFactory();
~SG_TreeFactory();
-
+
/**
* Add a node to be added to the tree.
*/
@@ -146,15 +146,15 @@ public:
* the Add method.
*/
SG_Tree* MakeTreeUp();
-
+
/**
* Build the tree from the set of nodes top down.
*/
SG_Tree* MakeTreeDown(SG_BBox &bbox);
-
+
SG_Tree* MakeTree();
-
-
+
+
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("GE:SG_TreeFactory")
#endif