|
ParticleTools: ColliderPatches
Parameters
UseColliders operate only on moving objects — if an object is stationary and is crossed by a moving collider, the collider will not interact with it. ImplementationVEE uses the OPCODE Collision Detection system. Here's the VEE code that detects the collision between object VEE_Vector3 l= o->location() - location(); ICEMATHS_API ICE::Point loc = * ( ICEMATHS_API ICE::Point *) & l; VEE_Vector3 vel = o->velocity(); VEE_Vector3 dir = vel; float speed = dir.length(); if(speed > 1.0e-8) dir *= (1.0f / speed); m_rayCollider.SetMaxDist(speed * m_dt * 2.0f + 0.1); ray.mOrig = loc; dir.normalize(); ray.mDir = * ( ICEMATHS_API ICE::Point *) & dir; m_rayCollider.Collide(ray, m_opcModel, (const Matrix4x4 *) & m_opcMatrix); bool contact = m_rayCollider.GetContactStatus(); if(!contact) continue; const Opcode::CollisionFace * face = m_collisionFaces.GetFaces(); const VEE_Vector3 normal = m_normals[face->mFaceID]; float gamma = dot(normal, vel); VEE_Vector3 tangential = vel - gamma * normal; VEE_Vector3 normalBounce = - gamma * normal; VEE_Vector3 newVel = tangential * (1.0f - m_drag) + normalBounce * m_bounce; o->collision(normal); o->setVelocity(newVel); (from vee-0.1.7/src/extensions/vee_opcode_collision.C)
|
Documentation |