Пример #1
0
void HitLine3D::Collide(CollisionEvent* coll)
{
    Ball *pball = coll->ball;
    const Vertex3Ds& hitnormal = coll->hitnormal;

    const float dot = hitnormal.Dot(pball->m_vel);
    pball->Collide3DWall(hitnormal, m_elasticity, m_elasticityFalloff, m_friction, m_scatter);

    if (m_ObjType == ePrimitive && dot <= -m_threshold)
        FireHitEvent(pball);
}
Пример #2
0
void Hit3DPoly::Collide(CollisionEvent *coll)
{
   Ball *pball = coll->ball;
   const Vertex3Ds& hitnormal = coll->hitnormal;

   if (m_ObjType != eTrigger)
   {
      const float dot = hitnormal.x * pball->m_vel.x + hitnormal.y * pball->m_vel.y;

      pball->Collide3DWall(normal, m_elasticity, m_elasticityFalloff, m_friction, m_scatter);

      if (m_ObjType == ePrimitive && dot <= -m_threshold)
          FireHitEvent(pball);
   }
	else
	{
		if (!pball->m_vpVolObjs) return;

		const int i = pball->m_vpVolObjs->IndexOf(m_pObj); // if -1 then not in objects volume set (i.e not already hit)

		if ((coll->hitvelocity.x != 1.0f) == (i < 0))	   // Hit == NotAlreadyHit
		{			
            pball->m_pos += STATICTIME * pball->m_vel;     //move ball slightly forward
				
			if (i < 0)
			{	
				pball->m_vpVolObjs->AddElement(m_pObj);
				((Trigger*)m_pObj)->FireGroupEvent(DISPID_HitEvents_Hit);				
			}		
			else			
			{
				pball->m_vpVolObjs->RemoveElementAt(i);
				((Trigger*)m_pObj)->FireGroupEvent(DISPID_HitEvents_Unhit);				
			}
		}	
	}
}