The convexSweepTest feature

Software: Away3D 4.x

Rope, Newbie
Posted: 16 April 2012 12:07 PM   Total Posts: 5

Hello,
I tried to add the interface for convexSweepTest in awayphysics.swc
but it seems not work. It’s time-consuming and get the wrong result.

source as below(awayPhysics.c)

==================================================
AS3_Val sweptSphereTest(voiddataAS3_Val args){
 btCollisionObject
obj;
 
double fromxfromyfromz;
 
double toxtoytoz;
 
double radius;
 
AS3_ArrayValue(args"PtrType,DoubleType,DoubleType,DoubleType,DoubleType,DoubleType,DoubleType,DoubleType", &obj;, &fromx;, &fromy;, &fromz;, &tox;, &toy;, &toz;, &radius;);
 
 if(
collisionWorld)
 
{
  btSphereShape
sweptShape =  new btSphereShape(radius);
  
btVector3 source(fromxfromyfromz);
  
btVector3 dest(toxtoytoz); 
  
btCollisionWorld::ClosestConvexResultCallback cb(sourcedest);
  
btTransform from;
  
from.setIdentity();
  
from.setOrigin(source);
  
btTransform to;
  
to.setIdentity();
  
from.setOrigin(dest);

  
btVector3 hit_surface;
  
btVector3 hit_com;
  
btVector3 normal;
  
double hit_fraction;

  
collisionWorld->convexSweepTest (sweptShapefromtocb);
  
  if (
cb.hasHit ())
  
{
   hit_surface 
cb.m_hitPointWorld;
   
hit_com.setInterpolate3(sourcedestcb.m_closestHitFraction);
   
hit_fraction cb.m_closestHitFraction;
   
normal cb.m_hitNormalWorld;
   
normal.normalize ();
   
   
//get rigid body from collision object
   
btRigidBodybody btRigidBody::upcast(cb.m_hitCollisionObject);
   
//clone result
   
SphereSweptInfo out(hit_surfacehit_comnormalhit_fractionbody);
   
return_as3_ptr(&out;);
  
else {
   hit_com 
dest;
   
hit_surface dest;
   
hit_fraction 1.0f;
   
normal btVector3(1.00.00.0);
   return 
AS3_Null();
  
}
 }
 
return AS3_Null();
}
================================================== 

I have check the out struct(SphereSweptInfo) in as3 source pointer.
Is it wrong?

   

Rope, Newbie
Posted: 19 April 2012 01:13 AM   Total Posts: 5   [ # 1 ]

I have solved it.

It’s caused by the AWPBase member _scaling

We need to scaling the swept source, destination and shape too.

So… the code above is work fine.

   
   
‹‹ advice/link need it

X

Away3D Forum

Member Login

Username

Password

Remember_me



X