these files missed the cvs commt yesterday, this should fix compilation problems
This commit is contained in:
@@ -197,6 +197,12 @@ struct BlenderDebugDraw : public IDebugDraw
|
||||
KX_RasterizerDrawDebugLine(kxfrom,kxto,kxcolor);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void DrawContactPoint(const SimdVector3& PointOnB,const SimdVector3& normalOnB,float distance,int lifeTime,const SimdVector3& color)
|
||||
{
|
||||
//not yet
|
||||
}
|
||||
|
||||
virtual void SetDebugMode(int debugMode)
|
||||
{
|
||||
m_debugMode = debugMode;
|
||||
|
@@ -33,7 +33,7 @@
|
||||
#define KX_CONVERTPHYSICSOBJECTS
|
||||
|
||||
/* These are defined by the build system... */
|
||||
#define USE_SUMO_SOLID
|
||||
//#define USE_SUMO_SOLID
|
||||
//#define USE_ODE
|
||||
|
||||
//on visual studio 7/8, always enable BULLET for now
|
||||
|
@@ -7,8 +7,12 @@
|
||||
|
||||
class BP_Proxy;
|
||||
|
||||
///todo: fill all the empty CcdPhysicsController methods, hook them up to the RigidBody class
|
||||
|
||||
//'temporarily' global variables
|
||||
float gDeactivationTime = 2.f;
|
||||
bool gDisableDeactivation = false;
|
||||
|
||||
float gLinearSleepingTreshold = 0.8f;
|
||||
float gAngularSleepingTreshold = 1.0f;
|
||||
|
||||
@@ -116,46 +120,31 @@ void CcdPhysicsController::RelativeTranslate(float dlocX,float dlocY,float dloc
|
||||
|
||||
}
|
||||
|
||||
void CcdPhysicsController::RelativeRotate(const float rotval[12],bool local)
|
||||
void CcdPhysicsController::RelativeRotate(const float drot[9],bool local)
|
||||
{
|
||||
if (m_body )
|
||||
{
|
||||
SimdMatrix3x3 drotmat( rotval[0],rotval[1],rotval[2],
|
||||
rotval[4],rotval[5],rotval[6],
|
||||
rotval[8],rotval[9],rotval[10]);
|
||||
|
||||
|
||||
SimdMatrix3x3 currentOrn;
|
||||
GetWorldOrientation(currentOrn);
|
||||
|
||||
SimdTransform xform = m_body->getCenterOfMassTransform();
|
||||
|
||||
xform.setBasis(xform.getBasis()*(local ?
|
||||
drotmat : (currentOrn.inverse() * drotmat * currentOrn)));
|
||||
|
||||
printf("hi\n");
|
||||
m_body->setCenterOfMassTransform(xform);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CcdPhysicsController::GetWorldOrientation(SimdMatrix3x3& mat)
|
||||
{
|
||||
float orn[4];
|
||||
m_MotionState->getWorldOrientation(orn[0],orn[1],orn[2],orn[3]);
|
||||
SimdQuaternion quat(orn[0],orn[1],orn[2],orn[3]);
|
||||
mat.setRotation(quat);
|
||||
}
|
||||
|
||||
void CcdPhysicsController::getOrientation(float &quatImag0,float &quatImag1,float &quatImag2,float &quatReal)
|
||||
{
|
||||
|
||||
}
|
||||
void CcdPhysicsController::setOrientation(float quatImag0,float quatImag1,float quatImag2,float quatReal)
|
||||
{
|
||||
m_body->activate();
|
||||
|
||||
SimdTransform xform = m_body->getCenterOfMassTransform();
|
||||
xform.setRotation(SimdQuaternion(quatImag0,quatImag1,quatImag2,quatReal));
|
||||
m_body->setCenterOfMassTransform(xform);
|
||||
|
||||
}
|
||||
|
||||
void CcdPhysicsController::setPosition(float posX,float posY,float posZ)
|
||||
{
|
||||
m_body->activate();
|
||||
|
||||
SimdTransform xform = m_body->getCenterOfMassTransform();
|
||||
xform.setOrigin(SimdVector3(posX,posY,posZ));
|
||||
m_body->setCenterOfMassTransform(xform);
|
||||
|
||||
}
|
||||
void CcdPhysicsController::resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ)
|
||||
{
|
||||
@@ -196,9 +185,7 @@ void CcdPhysicsController::applyImpulse(float attachX,float attachY,float attac
|
||||
SimdVector3 impulse(impulseX,impulseY,impulseZ);
|
||||
SimdVector3 pos(attachX,attachY,attachZ);
|
||||
|
||||
//it might be sleeping... wake up !
|
||||
m_body->SetActivationState(1);
|
||||
m_body->m_deactivationTime = 0.f;
|
||||
m_body->activate();
|
||||
|
||||
m_body->applyImpulse(impulse,pos);
|
||||
|
||||
@@ -255,7 +242,7 @@ bool CcdPhysicsController::wantsSleeping()
|
||||
{
|
||||
|
||||
//disable deactivation
|
||||
if (gDeactivationTime == 0.f)
|
||||
if (gDisableDeactivation || (gDeactivationTime == 0.f))
|
||||
return false;
|
||||
//2 == ISLAND_SLEEPING, 3 == WANTS_DEACTIVATION
|
||||
if ( (m_body->GetActivationState() == 2) || (m_body->GetActivationState() == 3))
|
||||
|
@@ -8,13 +8,12 @@
|
||||
/// It contains the IMotionState and IDeformableMesh Interfaces.
|
||||
#include "SimdVector3.h"
|
||||
#include "SimdScalar.h"
|
||||
#include "SimdMatrix3x3.h"
|
||||
|
||||
class CollisionShape;
|
||||
|
||||
extern float gDeactivationTime;
|
||||
extern float gLinearSleepingTreshold;
|
||||
extern float gAngularSleepingTreshold;
|
||||
extern bool gDisableDeactivation;
|
||||
|
||||
|
||||
struct CcdConstructionInfo
|
||||
@@ -89,7 +88,7 @@ class CcdPhysicsController : public PHY_IPhysicsController
|
||||
|
||||
// kinematic methods
|
||||
virtual void RelativeTranslate(float dlocX,float dlocY,float dlocZ,bool local);
|
||||
virtual void RelativeRotate(const float rotval[12],bool local);
|
||||
virtual void RelativeRotate(const float drot[9],bool local);
|
||||
virtual void getOrientation(float &quatImag0,float &quatImag1,float &quatImag2,float &quatReal);
|
||||
virtual void setOrientation(float quatImag0,float quatImag1,float quatImag2,float quatReal);
|
||||
virtual void setPosition(float posX,float posY,float posZ);
|
||||
@@ -132,8 +131,6 @@ class CcdPhysicsController : public PHY_IPhysicsController
|
||||
|
||||
void SetAabb(const SimdVector3& aabbMin,const SimdVector3& aabbMax);
|
||||
|
||||
void GetWorldOrientation(SimdMatrix3x3& mat);
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
@@ -301,11 +301,17 @@ bool CcdPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep)
|
||||
{
|
||||
|
||||
|
||||
// printf("CcdPhysicsEnvironment::proceedDeltaTime\n");
|
||||
|
||||
if (timeStep == 0.f)
|
||||
return true;
|
||||
|
||||
printf("CcdPhysicsEnvironment::proceedDeltaTime\n");
|
||||
if (m_debugDrawer)
|
||||
{
|
||||
gDisableDeactivation = (m_debugDrawer->GetDebugMode() & IDebugDraw::DBG_NoDeactivation);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//clamp hardcoded for now
|
||||
if (timeStep > 0.02)
|
||||
@@ -314,8 +320,8 @@ bool CcdPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep)
|
||||
//this is needed because scaling is not known in advance, and scaling has to propagate to the shape
|
||||
if (!m_scalingPropagated)
|
||||
{
|
||||
SyncMotionStates(timeStep);
|
||||
m_scalingPropagated = true;
|
||||
//SyncMotionStates(timeStep);
|
||||
//m_scalingPropagated = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -436,17 +442,17 @@ bool CcdPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep)
|
||||
shapeinterface->GetAabb(body->getCenterOfMassTransform(),
|
||||
minAabb,maxAabb);
|
||||
|
||||
SimdVector3 manifoldExtraExtents(gContactBreakingTreshold,gContactBreakingTreshold,gContactBreakingTreshold);
|
||||
minAabb -= manifoldExtraExtents;
|
||||
maxAabb += manifoldExtraExtents;
|
||||
|
||||
BroadphaseProxy* bp = (BroadphaseProxy*) ctrl->m_broadphaseHandle;
|
||||
if (bp)
|
||||
{
|
||||
|
||||
#ifdef WIN32
|
||||
SimdVector3 color (1,0,0);
|
||||
SimdVector3 color (1,1,0);
|
||||
|
||||
|
||||
|
||||
|
||||
if (m_debugDrawer)
|
||||
{
|
||||
//draw aabb
|
||||
@@ -454,7 +460,7 @@ bool CcdPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep)
|
||||
{
|
||||
case ISLAND_SLEEPING:
|
||||
{
|
||||
color.setValue(0,1,0);
|
||||
color.setValue(1,1,1);
|
||||
break;
|
||||
}
|
||||
case WANTS_DEACTIVATION:
|
||||
@@ -466,11 +472,13 @@ bool CcdPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
DrawAabb(m_debugDrawer,minAabb,maxAabb,color);
|
||||
if (m_debugDrawer->GetDebugMode() & IDebugDraw::DBG_DrawAabb)
|
||||
{
|
||||
DrawAabb(m_debugDrawer,minAabb,maxAabb,color);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -709,7 +717,89 @@ void CcdPhysicsEnvironment::setGravity(float x,float y,float z)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DASHDASJKHASDJK
|
||||
class RaycastingQueryBox : public QueryBox
|
||||
{
|
||||
|
||||
SimdVector3 m_aabbMin;
|
||||
|
||||
SimdVector3 m_aabbMax;
|
||||
|
||||
|
||||
|
||||
public:
|
||||
|
||||
RaycastCallback m_raycastCallback;
|
||||
|
||||
|
||||
RaycastingQueryBox(QueryBoxConstructionInfo& ci,const SimdVector3& from,const SimdVector3& to)
|
||||
: QueryBox(ci),
|
||||
m_raycastCallback(from,to)
|
||||
{
|
||||
for (int i=0;i<3;i++)
|
||||
{
|
||||
float fromI = from[i];
|
||||
float toI = to[i];
|
||||
if (fromI < toI)
|
||||
{
|
||||
m_aabbMin[i] = fromI;
|
||||
m_aabbMax[i] = toI;
|
||||
} else
|
||||
{
|
||||
m_aabbMin[i] = toI;
|
||||
m_aabbMax[i] = fromI;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
virtual void AddCollider( BroadphaseProxy* proxy)
|
||||
{
|
||||
//perform raycast if wanted, and update the m_hitFraction
|
||||
|
||||
if (proxy->GetClientObjectType() == TRIANGLE_MESH_SHAPE_PROXYTYPE)
|
||||
{
|
||||
//do it
|
||||
RigidBody* body = (RigidBody*)proxy->m_clientObject;
|
||||
TriangleMeshInterface* meshInterface = (TriangleMeshInterface*)
|
||||
body->m_minkowski1;
|
||||
|
||||
//if the hit is closer, record the proxy!
|
||||
float curFraction = m_raycastCallback.m_hitFraction;
|
||||
|
||||
meshInterface->ProcessAllTriangles(&m_raycastCallback,m_aabbMin,m_aabbMax);
|
||||
|
||||
if (m_raycastCallback.m_hitFraction < curFraction)
|
||||
{
|
||||
m_raycastCallback.m_hitProxy = proxy;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
struct InternalVehicleRaycaster : public VehicleRaycaster
|
||||
{
|
||||
|
||||
CcdPhysicsEnvironment* m_env;
|
||||
|
||||
public:
|
||||
|
||||
InternalVehicleRaycaster(CcdPhysicsEnvironment* env)
|
||||
: m_env(env)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
virtual void* CastRay(const SimdVector3& from,const SimdVector3& to, VehicleRaycasterResult& result)
|
||||
{
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl0,class PHY_IPhysicsController* ctrl1,PHY_ConstraintType type,
|
||||
float pivotX,float pivotY,float pivotZ,
|
||||
float axisX,float axisY,float axisZ)
|
||||
@@ -775,12 +865,10 @@ void CcdPhysicsEnvironment::removeConstraint(int constraintid)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
PHY_IPhysicsController* CcdPhysicsEnvironment::rayTest(PHY_IPhysicsController* ignoreClient, float fromX,float fromY,float fromZ, float toX,float toY,float toZ,
|
||||
float& hitX,float& hitY,float& hitZ,float& normalX,float& normalY,float& normalZ)
|
||||
{
|
||||
|
||||
printf("raytest\n");
|
||||
int minFraction = 1.f;
|
||||
|
||||
SimdTransform rayFromTrans,rayToTrans;
|
||||
@@ -800,17 +888,13 @@ PHY_IPhysicsController* CcdPhysicsEnvironment::rayTest(PHY_IPhysicsController* i
|
||||
for (i=m_controllers.begin();
|
||||
!(i==m_controllers.end()); i++)
|
||||
{
|
||||
|
||||
CcdPhysicsController* ctrl = (*i);
|
||||
if (ctrl == ignoreClient)
|
||||
continue;
|
||||
|
||||
RigidBody* body = ctrl->GetRigidBody();
|
||||
|
||||
if (body->GetCollisionShape()->IsConvex())
|
||||
{
|
||||
ConvexCast::CastResult rayResult;
|
||||
rayResult.m_fraction = minFraction;
|
||||
rayResult.m_fraction = 1.f;
|
||||
|
||||
ConvexShape* convexShape = (ConvexShape*) body->GetCollisionShape();
|
||||
VoronoiSimplexSolver simplexSolver;
|
||||
@@ -831,41 +915,6 @@ PHY_IPhysicsController* CcdPhysicsEnvironment::rayTest(PHY_IPhysicsController* i
|
||||
hitZ = rayResult.m_hitTransformA.getOrigin().getZ();
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
if (body->GetCollisionShape()->IsConcave())
|
||||
{
|
||||
TriangleMeshShape* triangleMesh = (TriangleMeshShape*)body->GetCollisionShape();
|
||||
|
||||
SimdTransform worldToBody = body->getCenterOfMassTransform().inverse();
|
||||
|
||||
SimdVector3 rayFromLocal = worldToBody * rayFromTrans.getOrigin();
|
||||
SimdVector3 rayToLocal = worldToBody * rayToTrans.getOrigin();
|
||||
|
||||
RaycastCallback rcb(rayFromLocal,rayToLocal);
|
||||
rcb.m_hitFraction = minFraction;
|
||||
|
||||
SimdVector3 aabbMax(1e30f,1e30f,1e30f);
|
||||
|
||||
triangleMesh->ProcessAllTriangles(&rcb,-aabbMax,aabbMax);
|
||||
if (rcb.m_hitFound && (rcb.m_hitFraction < minFraction))
|
||||
{
|
||||
printf("hit %f\n",rcb.m_hitFraction);
|
||||
nearestHit = ctrl;
|
||||
minFraction = rcb.m_hitFraction;
|
||||
SimdVector3 hitNormalWorld = body->getCenterOfMassTransform()(rcb.m_hitNormalLocal);
|
||||
|
||||
normalX = hitNormalWorld.getX();
|
||||
normalY = hitNormalWorld.getY();
|
||||
normalZ = hitNormalWorld.getZ();
|
||||
SimdVector3 hitWorld;
|
||||
hitWorld.setInterpolate3(rayFromTrans.getOrigin(),rayToTrans.getOrigin(),rcb.m_hitFraction);
|
||||
hitX = hitWorld.getX();
|
||||
hitY = hitWorld.getY();
|
||||
hitZ = hitWorld.getZ();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user