Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/components/CCmpProjectileManager.cpp
Show All 29 Lines | |||||
#include "graphics/Frustum.h" | #include "graphics/Frustum.h" | ||||
#include "graphics/Model.h" | #include "graphics/Model.h" | ||||
#include "graphics/Unit.h" | #include "graphics/Unit.h" | ||||
#include "graphics/UnitManager.h" | #include "graphics/UnitManager.h" | ||||
#include "maths/Matrix3D.h" | #include "maths/Matrix3D.h" | ||||
#include "maths/Quaternion.h" | #include "maths/Quaternion.h" | ||||
#include "maths/Vector3D.h" | #include "maths/Vector3D.h" | ||||
#include "ps/CLogger.h" | #include "ps/CLogger.h" | ||||
#include "renderer/Renderer.h" | |||||
#include "renderer/Scene.h" | #include "renderer/Scene.h" | ||||
// Time (in seconds) before projectiles that stuck in the ground are destroyed | // Time (in seconds) before projectiles that stuck in the ground are destroyed | ||||
const static float PROJECTILE_DECAY_TIME = 30.f; | const static float PROJECTILE_DECAY_TIME = 30.f; | ||||
class CCmpProjectileManager : public ICmpProjectileManager | class CCmpProjectileManager : public ICmpProjectileManager | ||||
{ | { | ||||
public: | public: | ||||
▲ Show 20 Lines • Show All 322 Lines • ▼ Show 20 Lines | void CCmpProjectileManager::RenderModel(CModelAbstract& model, const CVector3D& position, SceneCollector& collector, | ||||
model.ValidatePosition(); | model.ValidatePosition(); | ||||
if (culling && !frustum.IsBoxVisible(model.GetWorldBoundsRec())) | if (culling && !frustum.IsBoxVisible(model.GetWorldBoundsRec())) | ||||
return; | return; | ||||
// TODO: do something about LOS (copy from CCmpVisualActor) | // TODO: do something about LOS (copy from CCmpVisualActor) | ||||
CMatrix3D worldToCam; | |||||
g_Renderer.GetViewCamera().m_Orientation.GetInverse(worldToCam); | |||||
vladislavbelov: It's not needed to calculate inverse of a camera matrix for each model. For many models it… | |||||
CVector3D modelpos = model.GetTransform().GetTranslation(); | |||||
float dist = worldToCam.Transform(modelpos).Z; | |||||
if (dist > 250) | |||||
wraitiiAuthorUnsubmitted Not Done Inline ActionsThis definitely needs to be a different check. Ideally, you would take the AABB, calculate how many pixels across it'd be, and possibly skip if the # of pixel is significantly less than 1. wraitii: This definitely needs to be a different check. Ideally, you would take the AABB, calculate how… | |||||
return; | |||||
collector.SubmitRecursive(&model); | collector.SubmitRecursive(&model); | ||||
} | } | ||||
void CCmpProjectileManager::RenderSubmit(SceneCollector& collector, const CFrustum& frustum, bool culling) const | void CCmpProjectileManager::RenderSubmit(SceneCollector& collector, const CFrustum& frustum, bool culling) const | ||||
{ | { | ||||
CmpPtr<ICmpRangeManager> cmpRangeManager(GetSystemEntity()); | CmpPtr<ICmpRangeManager> cmpRangeManager(GetSystemEntity()); | ||||
int player = GetSimContext().GetCurrentDisplayedPlayer(); | int player = GetSimContext().GetCurrentDisplayedPlayer(); | ||||
ICmpRangeManager::CLosQuerier los(cmpRangeManager->GetLosQuerier(player)); | ICmpRangeManager::CLosQuerier los(cmpRangeManager->GetLosQuerier(player)); | ||||
Show All 13 Lines |
Wildfire Games · Phabricator
It's not needed to calculate inverse of a camera matrix for each model. For many models it might be noticeable for performance (see implementation of GetInverse).