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:
authorNathan Letwory <nathan@letworyinteractive.com>2004-03-23 01:02:18 +0300
committerNathan Letwory <nathan@letworyinteractive.com>2004-03-23 01:02:18 +0300
commit00291b5cf4a0f16ddca425b74ed30e8ac35d40e2 (patch)
tree952bb1c2f6fd8c2f34b950597ed0fa73a4ea7594 /source/gameengine/Physics/Sumo/Fuzzics/include
parent5b90aafbd6815e29343f8e9aba9e3e20f85b3cc0 (diff)
[GameEngine] Commit all Kester's changes made to the gameengine to restore 2.25 like physics.
[SCons] Build with Solid as default when enabling the gameengine in the build process [SCons] Build solid and qhull from the extern directory and link statically against them That was about it. There are a few things that needs double checking: * Makefiles * Projectfiles * All the other systems than Linux and Windows on which the build (with scons) has been successfully tested.
Diffstat (limited to 'source/gameengine/Physics/Sumo/Fuzzics/include')
-rw-r--r--source/gameengine/Physics/Sumo/Fuzzics/include/SM_Debug.h26
-rw-r--r--source/gameengine/Physics/Sumo/Fuzzics/include/SM_FhObject.h45
-rw-r--r--source/gameengine/Physics/Sumo/Fuzzics/include/SM_Object.h84
-rw-r--r--source/gameengine/Physics/Sumo/Fuzzics/include/SM_Scene.h90
4 files changed, 206 insertions, 39 deletions
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Debug.h b/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Debug.h
new file mode 100644
index 00000000000..48d5906e53d
--- /dev/null
+++ b/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Debug.h
@@ -0,0 +1,26 @@
+
+
+#ifndef __SM_DEBUG_H__
+#define __SM_DEBUG_H__
+
+/* Comment this to disable all SUMO debugging printfs */
+
+#define SM_DEBUG
+
+#ifdef SM_DEBUG
+
+#include <stdio.h>
+
+/* Uncomment this to printf all ray casts */
+//#define SM_DEBUG_RAYCAST
+
+/* Uncomment this to printf collision callbacks */
+//#define SM_DEBUG_BOING
+
+/* Uncomment this to printf Xform matrix calculations */
+//#define SM_DEBUG_XFORM
+
+#endif /* SM_DEBUG */
+
+#endif /* __SM_DEBUG_H__ */
+
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_FhObject.h b/source/gameengine/Physics/Sumo/Fuzzics/include/SM_FhObject.h
index 36ba075eeff..116eed12cea 100644
--- a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_FhObject.h
+++ b/source/gameengine/Physics/Sumo/Fuzzics/include/SM_FhObject.h
@@ -1,3 +1,34 @@
+/**
+ * $Id$
+ *
+ * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ */
#ifndef SM_FHOBJECT_H
#define SM_FHOBJECT_H
@@ -5,19 +36,15 @@
class SM_FhObject : public SM_Object {
public:
- SM_FhObject() {}
- SM_FhObject(const MT_Vector3& ray, SM_Object *client_object) :
- SM_Object(DT_Ray(ray[0], ray[1], ray[2]), 0, 0, 0),
- m_ray(ray),
- m_ray_direction(ray.normalized()),
- m_client_object(client_object) {}
+ virtual ~SM_FhObject();
+ SM_FhObject(DT_ShapeHandle rayshape, MT_Vector3 ray, SM_Object *parent_object);
const MT_Vector3& getRay() const { return m_ray; }
MT_Point3 getSpot() const { return m_pos + m_ray; }
const MT_Vector3& getRayDirection() const { return m_ray_direction; }
- SM_Object *getClientObject() const { return m_client_object; }
+ SM_Object *getParentObject() const { return m_parent_object; }
- static void ray_hit(void *client_data,
+ static DT_Bool ray_hit(void *client_data,
void *object1,
void *object2,
const DT_CollData *coll_data);
@@ -25,7 +52,7 @@ public:
private:
MT_Vector3 m_ray;
MT_Vector3 m_ray_direction;
- SM_Object *m_client_object;
+ SM_Object *m_parent_object;
};
#endif
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Object.h b/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Object.h
index 5342ba5d3a5..c84a3c2ff56 100644
--- a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Object.h
+++ b/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Object.h
@@ -1,9 +1,40 @@
+/**
+ * $Id$
+ *
+ * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ */
#ifndef SM_OBJECT_H
#define SM_OBJECT_H
#include <vector>
-#include "solid.h"
+#include <SOLID/SOLID.h>
#include "SM_Callback.h"
#include "SM_MotionState.h"
@@ -15,6 +46,7 @@ class SM_FhObject;
// Properties of dynamic objects
struct SM_ShapeProps {
MT_Scalar m_mass; // Total mass
+ MT_Scalar m_radius; // Bound sphere size
MT_Scalar m_inertia; // Inertia, should be a tensor some time
MT_Scalar m_lin_drag; // Linear drag (air, water) 0 = concrete, 1 = vacuum
MT_Scalar m_ang_drag; // Angular drag
@@ -36,6 +68,7 @@ struct SM_MaterialProps {
};
+
class SM_Object : public SM_MotionState {
public:
SM_Object() ;
@@ -45,7 +78,6 @@ public:
const SM_ShapeProps *shapeProps,
SM_Object *dynamicParent
);
-
virtual ~SM_Object();
bool isDynamic() const;
@@ -89,7 +121,7 @@ public:
void setMargin(MT_Scalar margin) ;
MT_Scalar getMargin() const ;
-
+
const SM_MaterialProps *getMaterialProps() const ;
const SM_ShapeProps *getShapeProps() const ;
@@ -164,7 +196,8 @@ public:
void applyAngularImpulse(const MT_Vector3& impulse);
MT_Point3 getWorldCoord(const MT_Point3& local) const;
-
+ MT_Point3 getLocalCoord(const MT_Point3& world) const;
+
MT_Vector3 getVelocity(const MT_Point3& local) const;
@@ -180,9 +213,6 @@ public:
DT_ObjectHandle getObjectHandle() const ;
DT_ShapeHandle getShapeHandle() const ;
- void setClientObject(void *clientobj) ;
- void *getClientObject() ;
-
SM_Object *getDynamicParent() ;
void integrateForces(MT_Scalar timeStep);
@@ -192,10 +222,9 @@ public:
bool isRigidBody() const ;
-
// This is the callback for handling collisions of dynamic objects
static
- void
+ DT_Bool
boing(
void *client_data,
void *object1,
@@ -203,6 +232,26 @@ public:
const DT_CollData *coll_data
);
+ static
+ DT_Bool
+ fix(
+ void *client_data,
+ void *object1,
+ void *object2,
+ const DT_CollData *coll_data
+ );
+
+
+ void *getClientObject() { return m_client_object; }
+ void setClientObject(void *client_object) { m_client_object = client_object; }
+
+ void relax();
+
+ void backup() {
+ m_pos = m_prev_state.getPosition();
+ m_orn = m_prev_state.getOrientation();
+ m_xform = m_prev_xform;
+ }
private:
// return the actual linear_velocity of this object this
@@ -217,11 +266,20 @@ private:
MT_Vector3
actualAngVelocity(
) const ;
+
+ void dynamicCollision(MT_Point3 local2,
+ MT_Vector3 normal,
+ MT_Scalar dist,
+ MT_Vector3 rel_vel,
+ MT_Scalar restitution,
+ MT_Scalar friction_factor,
+ MT_Scalar invMass
+ );
typedef std::vector<SM_Callback *> T_CallbackList;
- T_CallbackList m_callbackList; // Each object can have multiple callbacks from the client (=game engine)
+ T_CallbackList m_callbackList; // Each object can have multiple callbacks from the client (=game engine)
SM_Object *m_dynamicParent; // Collisions between parent and children are ignored
// as the collision callback now has only information
@@ -229,7 +287,7 @@ private:
// can identify it's clientdata after a collision
void *m_client_object;
- DT_ShapeHandle m_shape; // Shape for collision detection
+ DT_ShapeHandle m_shape; // Shape for collision detection
// Material and shape properties are not owned by this class.
@@ -237,7 +295,7 @@ private:
const SM_MaterialProps *m_materialPropsBackup; // Backup in case the object temporarily becomes a ghost.
const SM_ShapeProps *m_shapeProps;
const SM_ShapeProps *m_shapePropsBackup; // Backup in case the object's dynamics is temporarily suspended
- DT_ObjectHandle m_object; // A handle to the corresponding object in SOLID.
+ DT_ObjectHandle m_object; // A handle to the corresponding object in SOLID.
MT_Scalar m_margin; // Offset for the object's shape (also for collision detection)
MT_Vector3 m_scaling; // Non-uniform scaling of the object's shape
@@ -258,6 +316,8 @@ private:
MT_Vector3 m_ang_mom; // Angular momentum (angualr velocity times inertia)
MT_Vector3 m_force; // Force on center of mass (afffects linear momentum)
MT_Vector3 m_torque; // Torque around center of mass (affects angualr momentum)
+
+ MT_Vector3 m_error; // Error in position:- amount object must be moved to prevent intersection with scene
// Here are the values of externally set linear and angular
// velocity. These are updated from the outside
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Scene.h b/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Scene.h
index 1d4a4afc721..7afa2a59084 100644
--- a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Scene.h
+++ b/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Scene.h
@@ -2,38 +2,70 @@
* $Id$
* Copyright (C) 2001 NaN Technologies B.V.
* The physics scene.
+ *
+ * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
-
#ifndef SM_SCENE_H
#define SM_SCENE_H
+#ifdef WIN32
#pragma warning (disable : 4786)
+#endif
#include <vector>
#include <set>
#include <utility> //needed for pair
-#include "solid.h"
+#include <SOLID/SOLID.h>
#include "MT_Vector3.h"
#include "MT_Point3.h"
-class SM_Object;
+#include "SM_Object.h"
+
+typedef enum
+{
+ FH_RESPONSE,
+ SENSOR_RESPONSE, /* Touch Sensors */
+ CAMERA_RESPONSE, /* Visibility Culling */
+ OBJECT_RESPONSE, /* Object Dynamic Geometry Response */
+ STATIC_RESPONSE, /* Static Geometry Response */
+
+ NUM_RESPONSE
+};
class SM_Scene {
public:
- SM_Scene() :
- m_scene(DT_CreateScene()),
- m_respTable(DT_CreateRespTable()),
- m_secondaryRespTable(0),
- m_forceField(0.0, 0.0, 0.0)
- {}
+ SM_Scene();
- ~SM_Scene() {
- DT_DeleteRespTable(m_respTable);
- DT_DeleteScene(m_scene);
- }
-
+ ~SM_Scene();
+
DT_RespTableHandle getRespTableHandle() const {
return m_respTable;
}
@@ -50,6 +82,9 @@ public:
m_forceField = forceField;
}
+ void addTouchCallback(int response_class, DT_ResponseCallback callback, void *user);
+
+ void addSensor(SM_Object& object);
void add(SM_Object& object);
void remove(SM_Object& object);
@@ -61,9 +96,10 @@ public:
m_pairList.clear();
}
- void setSecondaryRespTable(DT_RespTableHandle secondaryRespTable) {
- m_secondaryRespTable = secondaryRespTable;
- }
+ void setSecondaryRespTable(DT_RespTableHandle secondaryRespTable);
+ DT_RespTableHandle getSecondaryRespTable() { return m_secondaryRespTable; }
+
+ void requestCollisionCallback(SM_Object &object);
// Perform an integration step of duration 'timeStep'.
@@ -96,7 +132,16 @@ private:
// Clear the user set velocities.
void clearObjectCombinedVelocities();
-
+ // This is the callback for handling collisions of dynamic objects
+ static
+ DT_Bool
+ boing(
+ void *client_data,
+ void *object1,
+ void *object2,
+ const DT_CollData *coll_data
+ );
+
/** internal type */
typedef std::vector<SM_Object *> T_ObjectList;
/** internal type */
@@ -106,10 +151,19 @@ private:
DT_SceneHandle m_scene;
/** Following response table contains the callbacks for the dynmics */
DT_RespTableHandle m_respTable;
+ DT_ResponseClass m_ResponseClass[NUM_RESPONSE];
/**
* Following response table contains callbacks for the client (=
* game engine) */
DT_RespTableHandle m_secondaryRespTable; // Handle
+ DT_ResponseClass m_secondaryResponseClass[NUM_RESPONSE];
+
+ /**
+ * Following resposne table contains callbacks for fixing the simulation
+ * ie making sure colliding objects do not intersect.
+ */
+ DT_RespTableHandle m_fixRespTable;
+ DT_ResponseClass m_fixResponseClass[NUM_RESPONSE];
/** The acceleration from the force field */
MT_Vector3 m_forceField;