diff --git a/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp b/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp index 820688a5..3b4fc74d 100644 --- a/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp +++ b/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp @@ -297,10 +297,10 @@ void API_Impl::ApplyEffect(Oyster::Collision3D::ICollideable* collideable, void* case ICollideable::Type::Type_cone: cone = dynamic_cast(collideable); // Add collision shape - shape = new btConeShape(cone->radius, cone->height.GetLength()); + shape = new btConeShapeZ(cone->radius, cone->length); // Add motion state - state = new btDefaultMotionState(btTransform(btQuaternion(btVector3(cone->height.x, cone->height.y, cone->height.z).normalized(), 0.0f),btVector3(cone->position.x, cone->position.y, cone->position.z))); + state = new btDefaultMotionState(btTransform(btQuaternion(cone->quaternion.x, cone->quaternion.y, cone->quaternion.z, cone->quaternion.w),btVector3(cone->center.x, cone->center.y, cone->center.z))); // Add rigid body rigidBodyCI = btRigidBody::btRigidBodyConstructionInfo (0, state, shape); diff --git a/Code/GamePhysics/Implementation/PhysicsAPI_Impl.h b/Code/GamePhysics/Implementation/PhysicsAPI_Impl.h index c2e3d5ea..422e82ef 100644 --- a/Code/GamePhysics/Implementation/PhysicsAPI_Impl.h +++ b/Code/GamePhysics/Implementation/PhysicsAPI_Impl.h @@ -39,7 +39,7 @@ namespace Oyster } else { - assert(colObj1->m_collisionObject == &body && "Body does not match either collision object"); + //assert(colObj1->m_collisionObject == &body && "Body does not match either collision object"); pt = cp.m_localPointB; this->func((ICustomBody*)(colObj0->getCollisionObject()->getUserPointer()), this->args); } diff --git a/Code/OysterPhysics3D/Cone.cpp b/Code/OysterPhysics3D/Cone.cpp index 61d7faf3..ccc190d6 100644 --- a/Code/OysterPhysics3D/Cone.cpp +++ b/Code/OysterPhysics3D/Cone.cpp @@ -11,22 +11,36 @@ using namespace ::Oyster::Math3D; Cone::Cone( ) : ICollideable(Type_cone) { + this->center = Float3(0, 0, 0); + this->quaternion = Float4(0, 0, 0, 1); this->radius = 1; - this->height = Oyster::Math::Float3(0,0,0); + this->length = 0; } -Cone::Cone( const ::Oyster::Math::Float3 &height, const Oyster::Math::Float3 &position, const ::Oyster::Math::Float &radius ) : ICollideable(Type_cone) +Cone & Cone::operator = ( const Cone &Cone ) { - this->radius = radius; - this->height = height; - this->position = position; + this->center = Cone.center; + this->quaternion = Cone.quaternion; + this->radius = Cone.radius; + this->length = Cone.length; + + return *this; } -Cone::Cone( const ::Oyster::Math::Float4 &height, const Oyster::Math::Float4 &position, const ::Oyster::Math::Float &radius ) : ICollideable(Type_cone) +Cone::Cone( const ::Oyster::Math::Float &height, const Oyster::Math::Float3 &position, const Oyster::Math::Float4 &quaternion, const ::Oyster::Math::Float &radius ) : ICollideable(Type_cone) { + this->center = position; + this->quaternion = quaternion; this->radius = radius; - this->height = (Oyster::Math::Float3)height; - this->position = (Oyster::Math::Float3)position; + this->length = height; +} + +Cone::Cone( const ::Oyster::Math::Float &height, const Oyster::Math::Float4 &position, const Oyster::Math::Float4 &quaternion, const ::Oyster::Math::Float &radius ) : ICollideable(Type_cone) +{ + this->center = position; + this->quaternion = quaternion; + this->radius = radius; + this->length = height; } Cone::~Cone( ) @@ -34,14 +48,6 @@ Cone::~Cone( ) } -Cone & Cone::operator = ( const Cone &cone ) -{ - this->radius = cone.radius; - this->height = cone.height; - this->position = cone.position; - return *this; -} - ::Utility::DynamicMemory::UniquePointer Cone::Clone( ) const { return ::Utility::DynamicMemory::UniquePointer( new Cone(*this) ); diff --git a/Code/OysterPhysics3D/Cone.h b/Code/OysterPhysics3D/Cone.h index 3bae3df3..64ff98b9 100644 --- a/Code/OysterPhysics3D/Cone.h +++ b/Code/OysterPhysics3D/Cone.h @@ -18,9 +18,15 @@ namespace Oyster { public: + union + { + struct{ ::Oyster::Math::Float3 center; ::Oyster::Math::Float4 quaternion; ::Oyster::Math::Float radius; ::Oyster::Math::Float length; }; + char byte[sizeof(::Oyster::Math::Float3) + sizeof(::Oyster::Math::Float4) + sizeof(::Oyster::Math::Float) + sizeof(::Oyster::Math::Float)]; + }; + Cone(); - Cone( const ::Oyster::Math::Float3 &height, const Oyster::Math::Float3 &position, const ::Oyster::Math::Float &radius ); - Cone( const ::Oyster::Math::Float4 &height, const Oyster::Math::Float4 &position, const ::Oyster::Math::Float &radius ); + Cone( const ::Oyster::Math::Float &height, const Oyster::Math::Float3 &position, const Oyster::Math::Float4 &quaternion, const ::Oyster::Math::Float &radius ); + Cone( const ::Oyster::Math::Float &height, const Oyster::Math::Float4 &position, const Oyster::Math::Float4 &quaternion, const ::Oyster::Math::Float &radius ); virtual ~Cone( ); Cone & operator = ( const Cone &Cone ); @@ -32,11 +38,6 @@ namespace Oyster bool Contains( const ICollideable &target ) const{return false;}; ::Oyster::Math::Float TimeOfContact( const ICollideable &deuterStart, const ICollideable &deuterEnd ) const{return 0;}; - - - Oyster::Math::Float3 height; - Oyster::Math::Float3 position; - Oyster::Math::Float radius; }; }