~ubuntu-branches/ubuntu/gutsy/blender/gutsy-security

« back to all changes in this revision

Viewing changes to source/gameengine/Physics/Sumo/Fuzzics/include/SM_Object.h

  • Committer: Bazaar Package Importer
  • Author(s): Florian Ernst
  • Date: 2005-11-06 12:40:03 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051106124003-3pgs7tcg5rox96xg
Tags: 2.37a-1.1
* Non-maintainer upload.
* Split out parts of 01_SConstruct_debian.dpatch again: root_build_dir
  really needs to get adjusted before the clean target runs - closes: #333958,
  see #288882 for reference

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/**
2
 
 * $Id: SM_Object.h,v 1.9 2004/04/24 06:40:14 kester Exp $
 
2
 * $Id: SM_Object.h,v 1.16 2005/03/25 10:33:39 kester Exp $
3
3
 *
4
4
 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
5
5
 *
66
66
        bool      m_fh_normal;             ///< Should the object slide off slopes?
67
67
};
68
68
 
 
69
class SM_ClientObject
 
70
{
 
71
public:
 
72
        SM_ClientObject() {}
 
73
        virtual ~SM_ClientObject() {}
 
74
        
 
75
        virtual bool hasCollisionCallback() = 0;
 
76
};
69
77
 
70
78
/**
71
79
 * SM_Object is an internal part of the Sumo physics engine.
73
81
 * It encapsulates an object in the physics scene, and is responsible
74
82
 * for calculating the collision response of objects.
75
83
 */
76
 
class SM_Object : public SM_MotionState {
 
84
class SM_Object 
 
85
{
77
86
public:
78
87
        SM_Object() ;
79
88
        SM_Object(
136
145
        void setOrientation(const MT_Quaternion& orn);
137
146
        void setScaling(const MT_Vector3& scaling);
138
147
        
139
 
 
140
148
        /**
141
149
         * set an external velocity. This velocity complements
142
150
         * the physics velocity. So setting it does not override the
254
262
        );
255
263
        
256
264
        
257
 
        void *getClientObject() { return m_client_object; }
258
 
        void setClientObject(void *client_object) { m_client_object = client_object; }
259
 
        
 
265
        SM_ClientObject *getClientObject() { return m_client_object; }
 
266
        void setClientObject(SM_ClientObject *client_object) { m_client_object = client_object; }
 
267
        void    setPhysicsClientObject(void* physicsClientObject)
 
268
        {
 
269
                m_physicsClientObject = physicsClientObject;
 
270
        }
 
271
        void*   getPhysicsClientObject() {
 
272
                return m_physicsClientObject;
 
273
        }
260
274
        void relax();
261
275
        
262
 
        void backup() {
263
 
                m_pos = m_prev_state.getPosition();
264
 
                m_orn = m_prev_state.getOrientation();
265
 
                m_xform = m_prev_xform;
266
 
        }
 
276
        SM_MotionState &getCurrentFrame();
 
277
        SM_MotionState &getPreviousFrame();
 
278
        SM_MotionState &getNextFrame();
 
279
        
 
280
        const SM_MotionState &getCurrentFrame()   const;
 
281
        const SM_MotionState &getPreviousFrame()  const;
 
282
        const SM_MotionState &getNextFrame()      const;
 
283
 
 
284
        // Motion state functions       
 
285
        const MT_Point3&     getPosition()        const;
 
286
        const MT_Quaternion& getOrientation()     const;
 
287
        const MT_Vector3&    getLinearVelocity()  const;
 
288
        const MT_Vector3&    getAngularVelocity() const;
 
289
        
 
290
        MT_Scalar            getTime()            const;
 
291
        
 
292
        void setTime(MT_Scalar time);
 
293
        
 
294
        void interpolate(MT_Scalar timeStep);
 
295
        void endFrame();
 
296
        
267
297
private:
 
298
        friend class Contact;
 
299
        // Tweak parameters
 
300
        static MT_Scalar ImpulseThreshold;
268
301
 
269
302
        // return the actual linear_velocity of this object this 
270
303
        // is the addition of m_combined_lin_vel and m_lin_vel.
297
330
    // as the collision callback now has only information
298
331
        // on an SM_Object, there must be a way that the SM_Object client
299
332
        // can identify it's clientdata after a collision
300
 
        void                   *m_client_object;
 
333
        SM_ClientObject        *m_client_object;
 
334
        
 
335
        void*                                   m_physicsClientObject;
301
336
 
302
337
        DT_ShapeHandle          m_shape;                 // Shape for collision detection
303
338
 
320
355
        MT_Vector3              m_reaction_impulse;      // The accumulated impulse resulting from collisions
321
356
        MT_Vector3              m_reaction_force;        // The reaction force derived from the reaction impulse   
322
357
 
323
 
        unsigned int            m_kinematic      : 1;    // Have I been displaced (translated, rotated, scaled) in this frame? 
324
 
        unsigned int            m_prev_kinematic : 1;    // Have I been displaced (translated, rotated, scaled) in the previous frame? 
325
 
        unsigned int            m_is_rigid_body  : 1;    // Should friction give me a change in angular momentum?
326
 
 
327
358
        MT_Vector3              m_lin_mom;               // Linear momentum (linear velocity times mass)
328
359
        MT_Vector3              m_ang_mom;               // Angular momentum (angualr velocity times inertia)
329
360
        MT_Vector3              m_force;                 // Force on center of mass (afffects linear momentum)
330
 
        MT_Vector3              m_torque;                // Torque around center of mass (affects angualr momentum)
 
361
        MT_Vector3              m_torque;                // Torque around center of mass (affects angular momentum)
 
362
        
 
363
        SM_MotionState          m_frames[3];             
331
364
        
332
365
        MT_Vector3              m_error;                 // Error in position:- amount object must be moved to prevent intersection with scene
333
366
 
351
384
        MT_Scalar               m_inv_mass;              // 1/mass
352
385
        MT_Vector3              m_inv_inertia;           // [1/inertia_x, 1/inertia_y, 1/inertia_z]
353
386
        MT_Matrix3x3            m_inv_inertia_tensor;    // Inverse Inertia Tensor
 
387
        
 
388
        bool                    m_kinematic;             // Have I been displaced (translated, rotated, scaled) in this frame? 
 
389
        bool                    m_prev_kinematic;        // Have I been displaced (translated, rotated, scaled) in the previous frame? 
 
390
        bool                    m_is_rigid_body;         // Should friction give me a change in angular momentum?
 
391
        int                     m_static;                // temporarily static.
 
392
 
354
393
};
355
394
 
356
395
#endif