Beispiel #1
0
void Bullet::onTrigger(void)
{
	OBJECT_ID id = INVALID_ID;

	// Only consider Creature from our World that are not the Bullet owner
	ActorSet s = getZone().getObjects().typeFilter<Creature>().exclude(owner);

	if(isAnythingInProximity(s, id))
	{
		Creature& creature = dynamic_cast<Creature&>(s.get(id));

		creature.damage(damageValue, owner);
		creature.applyKnockBack(creature.getPos()-getPos());

		if(causesFreeze)
			creature.freeze();

		kill();
	}
}
Beispiel #2
0
void Shadow::update(const ActorSet &zoneActors, float deltaTime)
{
	if(light!=0 && zoneActors.isMember(actorID))
	{
		const Actor &actor = zoneActors.get(actorID);

		// Update the shadow when something has changed
		needsUpdate |= (actor.hasAnimated || actor.hasMoved);

		// Update when necessary or requested
		if(needsUpdate)
		{
			float lx=0, ly=0;

			calculateAngularSpread(actor, lightViewMatrix, lx, ly);

			calculateMatrices(*light, actor, shadowMapSize, lightProjectionMatrix, lightViewMatrix, textureMatrix, lx, ly);

			frustum = calculateFrustum(lightProjectionMatrix, lightViewMatrix);

			if(g_Application.displayDebugData)
			{
				calculateFrustumVertices(*light, actor, lx, ly, ntl, ntr, nbl, nbr, ftl, ftr, fbl, fbr);
			}

			renderToShadow(shadowMapTexture, shadowMapSize, actor, lightProjectionMatrix, lightViewMatrix);

			needsUpdate=false;
		}

		// Periodically take some time to determine the actors that be receiving this shadow
		periodicTimer-=deltaTime;
		if(periodicTimer<0)
		{
			periodicTimer = 250.0f + FRAND_RANGE(100.0f, 250.0f); // stagger
			receivers = calculateReceivers(zoneActors, lightProjectionMatrix, lightViewMatrix);
		}
	}
}