Пример #1
0
void CProjectileDrawer::DrawProjectile(CProjectile* pro, bool drawReflection, bool drawRefraction)
{
	const CUnit* owner = pro->owner();

	const float time = !GML::SimEnabled() ? globalRendering->timeOffset :
		((float)spring_tomsecs(globalRendering->lastFrameStart) - (float)pro->lastProjUpdate) * globalRendering->weightedSpeedFactor;
		pro->drawPos = pro->pos + (pro->speed * time);

	if (
		(gu->spectatingFullView || loshandler->InLos(pro, gu->myAllyTeam) || (owner && teamHandler->Ally(owner->allyteam, gu->myAllyTeam)))
		&& camera->InView(pro->pos, pro->drawRadius)
	) {
		if (drawReflection) {
			if (pro->pos.y < -pro->drawRadius) {
				return;
			}

			float dif = pro->pos.y - camera->pos.y;
			float3 zeroPos = camera->pos * (pro->pos.y / dif) + pro->pos * (-camera->pos.y / dif);

			if (ground->GetApproximateHeight(zeroPos.x, zeroPos.z, false) > 3 + 0.5f * pro->drawRadius) {
				return;
			}
		}

		if (drawRefraction && pro->pos.y > pro->drawRadius) {
			return;
		}

		DrawProjectileModel(pro, false);

		pro->tempdist = pro->pos.dot(camera->forward);
		zSortedProjectiles.insert(pro);
	}
}
Пример #2
0
void CProjectileDrawer::DrawProjectile(CProjectile* pro, bool drawReflection, bool drawRefraction)
{
	const CUnit* owner = pro->owner();

	#if defined(USE_GML) && GML_ENABLE_SIM
		pro->drawPos = pro->pos + (pro->speed * ((float)globalRendering->lastFrameStart - (float)pro->lastProjUpdate) * globalRendering->weightedSpeedFactor);
	#else
		pro->drawPos = pro->pos + (pro->speed * globalRendering->timeOffset);
	#endif

	if (
		(gu->spectatingFullView || loshandler->InLos(pro, gu->myAllyTeam) || (owner && teamHandler->Ally(owner->allyteam, gu->myAllyTeam)))
		&& camera->InView(pro->pos, pro->drawRadius)
	) {

		const bool stunned = owner ? owner->stunned : false;

		if (stunned && dynamic_cast<CShieldPartProjectile*>(pro)) {
			// if the unit that fired this projectile is stunned and the projectile
			// forms part of a shield (ie., the unit has a CPlasmaRepulser weapon but
			// cannot fire it), prevent the projectile (shield segment) from being drawn
			//
			// also prevents shields being drawn at unit's pre-pickup position
			// (since CPlasmaRepulser::Update() is responsible for updating
			// CShieldPartProjectile::centerPos) if the unit is in a non-fireplatform
			// transport
			return;
		}

		if (drawReflection) {
			if (pro->pos.y < -pro->drawRadius) {
				return;
			}

			float dif = pro->pos.y - camera->pos.y;
			float3 zeroPos = camera->pos * (pro->pos.y / dif) + pro->pos * (-camera->pos.y / dif);

			if (ground->GetApproximateHeight(zeroPos.x, zeroPos.z, false) > 3 + 0.5f * pro->drawRadius) {
				return;
			}
		}

		if (drawRefraction && pro->pos.y > pro->drawRadius) {
			return;
		}

		DrawProjectileModel(pro, false);

		pro->tempdist = pro->pos.dot(camera->forward);
		zSortedProjectiles.insert(pro);
	}
}
Пример #3
0
void CProjectileDrawer::DrawProjectileShadow(CProjectile* p)
{
	const CUnit* owner = p->owner();
	if ((gu->spectatingFullView || loshandler->InLos(p, gu->myAllyTeam) ||
		(owner && teamHandler->Ally(owner->allyteam, gu->myAllyTeam)))) {

		if (!DrawProjectileModel(p, true)) {
			if (p->castShadow) {
				// don't need to z-sort particle
				// effects for the shadow pass
				p->Draw();
			}
		}
	}
}
Пример #4
0
void CProjectileDrawer::DrawProjectileShadow(CProjectile* p)
{
	const CUnit* owner = p->owner();

	if ((gu->spectatingFullView || loshandler->InLos(p, gu->myAllyTeam) ||
		(owner && teamHandler->Ally(owner->allyteam, gu->myAllyTeam)))) {

		// if this returns false, then projectile is
		// neither weapon nor piece, or has no model
		if (DrawProjectileModel(p, true))
			return;

		if (!p->castShadow)
			return;

		// don't need to z-sort particle
		// effects for the shadow pass
		p->Draw();
	}
}