/* Copyright (C) 2009 Sony Computer Entertainment Inc. All rights reserved. This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #ifndef BT_TRBSTATEVEC_H__ #define BT_TRBSTATEVEC_H__ #include #ifdef PFX_USE_FREE_VECTORMATH #include "vecmath/vmInclude.h" #else #include "vectormath/vmInclude.h" #endif //PFX_USE_FREE_VECTORMATH #include "PlatformDefinitions.h" static inline vmVector3 read_Vector3(const float* p) { vmVector3 v; loadXYZ(v, p); return v; } static inline vmQuat read_Quat(const float* p) { vmQuat vq; loadXYZW(vq, p); return vq; } static inline void store_Vector3(const vmVector3 &src, float* p) { vmVector3 v = src; storeXYZ(v, p); } static inline void store_Quat(const vmQuat &src, float* p) { vmQuat vq = src; storeXYZW(vq, p); } // Motion Type enum { PfxMotionTypeFixed = 0, PfxMotionTypeActive, PfxMotionTypeKeyframe, PfxMotionTypeOneWay, PfxMotionTypeTrigger, PfxMotionTypeCount }; #define PFX_MOTION_MASK_DYNAMIC 0x0a // Active,OneWay #define PFX_MOTION_MASK_STATIC 0x95 // Fixed,Keyframe,Trigger,Sleeping #define PFX_MOTION_MASK_SLEEP 0x0e // Can sleep #define PFX_MOTION_MASK_TYPE 0x7f // // Rigid Body state // #ifdef __CELLOS_LV2__ ATTRIBUTE_ALIGNED128(class) TrbState #else ATTRIBUTE_ALIGNED16(class) TrbState #endif { public: TrbState() { setMotionType(PfxMotionTypeActive); contactFilterSelf=contactFilterTarget=0xffffffff; deleted = 0; mSleeping = 0; useSleep = 1; trbBodyIdx=0; mSleepCount=0; useCcd = 0; useContactCallback = 0; useSleepCallback = 0; linearDamping = 1.0f; angularDamping = 0.99f; } TrbState(const uint8_t m, const vmVector3& x, const vmQuat& q, const vmVector3& v, const vmVector3& omega ); uint16_t mSleepCount; uint8_t mMotionType; uint8_t deleted : 1; uint8_t mSleeping : 1; uint8_t useSleep : 1; uint8_t useCcd : 1; uint8_t useContactCallback : 1; uint8_t useSleepCallback : 1; uint16_t trbBodyIdx; uint32_t contactFilterSelf; uint32_t contactFilterTarget; float center[3]; // AABB center(World) float half[3]; // AABB half(World) float linearDamping; float angularDamping; float deltaLinearVelocity[3]; float deltaAngularVelocity[3]; float fX[3]; // position float fQ[4]; // orientation float fV[3]; // velocity float fOmega[3]; // angular velocity inline void setZero(); // Zeroes out the elements inline void setIdentity(); // Sets the rotation to identity and zeroes out the other elements bool isDeleted() const {return deleted==1;} uint16_t getRigidBodyId() const {return trbBodyIdx;} void setRigidBodyId(uint16_t i) {trbBodyIdx = i;} uint32_t getContactFilterSelf() const {return contactFilterSelf;} void setContactFilterSelf(uint32_t filter) {contactFilterSelf = filter;} uint32_t getContactFilterTarget() const {return contactFilterTarget;} void setContactFilterTarget(uint32_t filter) {contactFilterTarget = filter;} float getLinearDamping() const {return linearDamping;} float getAngularDamping() const {return angularDamping;} void setLinearDamping(float damping) {linearDamping=damping;} void setAngularDamping(float damping) {angularDamping=damping;} uint8_t getMotionType() const {return mMotionType;} void setMotionType(uint8_t t) {mMotionType = t;mSleeping=0;mSleepCount=0;} uint8_t getMotionMask() const {return (1<