Exemplo n.º 1
0
//Melee///////////////////////////////////////////////////////////////////////////////////////////
Collidable Melee::get_attack_collidable(Entity* attacker, Vec2 dir)
{
	Collidable attack_box = Collidable();
	attack_box.set_all_positions(attacker->get_position()+dir);
	attack_box.set_collision_box(Rect_dub(0.5,0.5,1,1));//Rect_dub(0.5,1.5,1,3)
	attack_box.set_team(attacker->get_team());

	return attack_box;	
}
Exemplo n.º 2
0
void Unit::UpdateCollideQueue( StarSystem *ss, CollideMap::iterator hint[NUM_COLLIDE_MAPS] )
{
    if (activeStarSystem == NULL)
        activeStarSystem = ss;

    else
        assert( activeStarSystem == ss );
    for (unsigned int locind = 0; locind < NUM_COLLIDE_MAPS; ++locind)
        if ( is_null( location[locind] ) ) {
            assert( !isSubUnit() );
            if ( !isSubUnit() )
                location[locind] = ss->collidemap[locind]->insert( Collidable( this ), hint[locind] );
        }
}
Exemplo n.º 3
0
udword Havok::BatchBoxSweeps(PintSQThreadContext context, udword nb, PintRaycastHit* dest, const PintBoxSweepData* sweeps)
{
	ASSERT(mPhysicsWorld);

	// Since we're not too concerned with perfect accuracy, we can set the early out
	// distance to give the algorithm a chance to exit more quickly:
//	mPhysicsWorld->getCollisionInput()->m_config->m_iterativeLinearCastEarlyOutDistance = 0.1f;

	hkpClosestCdPointCollector castCollector;
	udword NbHits = 0;
	while(nb--)
	{
		hkpLinearCastInput input;
		input.m_to = ToHkVector4(sweeps->mBox.mCenter + sweeps->mDir*sweeps->mMaxDist);

		const hkpBoxShape BoxShape(ToHkVector4(sweeps->mBox.mExtents), 0.0f);
		const hkTransform Pose(ToHkQuaternion(Quat(sweeps->mBox.mRot)), ToHkVector4(sweeps->mBox.mCenter));
		hkpCollidable Collidable(&BoxShape, &Pose);

		castCollector.reset();
		mPhysicsWorld->linearCast(&Collidable, input, castCollector);

		if(castCollector.hasHit())
		{
			NbHits++;
			FillResultStruct(*dest, castCollector, sweeps->mMaxDist);
		}
		else
		{
			dest->mObject = null;
		}
		sweeps++;
		dest++;
	}

	return NbHits;
}
Exemplo n.º 4
0
void Unit::CollideAll()
{
    static bool noUnitCollisions = XMLSupport::parse_bool( vs_config->getVariable( "physics", "no_unit_collisions", "false" ) );
    if (isSubUnit() || killed || noUnitCollisions)
        return;
    for (unsigned int locind = 0; locind < NUM_COLLIDE_MAPS; ++locind)
        if ( is_null( this->location[locind] ) )
            this->location[locind] = this->getStarSystem()->collidemap[locind]->insert( Collidable( this ) );
    CollideMap *cm = this->getStarSystem()->collidemap[Unit::UNIT_BOLT];
    cm->CheckCollisions( this, *this->location[Unit::UNIT_BOLT] );
}