Draw wire sphere on selected lights to visualize light radius

This commit is contained in:
parax0
2015-11-29 03:00:18 -07:00
parent 9b2dd838ea
commit 7622bb2032
8 changed files with 79 additions and 10 deletions

View File

@@ -27,20 +27,28 @@ ENodeType CLightNode::NodeType()
void CLightNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo)
{
if (!ViewInfo.ViewFrustum.BoxInFrustum(AABox())) return;
if (ViewInfo.GameMode) return;
pRenderer->AddOpaqueMesh(this, -1, AABox(), eDrawMesh);
if (ViewInfo.ViewFrustum.BoxInFrustum(AABox()))
pRenderer->AddOpaqueMesh(this, -1, AABox(), eDrawMesh);
if (IsSelected() && mpLight->GetType() == eCustom)
{
CAABox RadiusBox = (CAABox::skOne * 2.f * mpLight->GetRadius()) + mPosition;
if (ViewInfo.ViewFrustum.BoxInFrustum(RadiusBox))
pRenderer->AddOpaqueMesh(this, -1, AABox(), eDrawSelection);
}
}
void CLightNode::Draw(ERenderOptions /*Options*/, int /*ComponentIndex*/, const SViewInfo& ViewInfo)
{
CDrawUtil::DrawLightBillboard(mpLight->GetType(), mpLight->GetColor(), mPosition, BillboardScale(), TintColor(ViewInfo));
}
// Below commented-out code is for light radius visualization as a bounding box
/*float r = mLight->GetRadius();
CAABox AABB(Position + r, Position - r);
pRenderer->DrawBoundingBox(mLight->GetColor(), AABB);*/
void CLightNode::DrawSelection()
{
CDrawUtil::DrawWireSphere(mPosition, mpLight->GetRadius(), mpLight->GetColor());
}
void CLightNode::RayAABoxIntersectTest(CRayCollisionTester& Tester, const SViewInfo& /*ViewInfo*/)

View File

@@ -12,6 +12,7 @@ public:
ENodeType NodeType();
void AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo);
void Draw(ERenderOptions Options, int ComponentIndex, const SViewInfo& ViewInfo);
void DrawSelection();
void RayAABoxIntersectTest(CRayCollisionTester& Tester, const SViewInfo& ViewInfo);
SRayIntersection RayNodeIntersectTest(const CRay &Ray, u32 AssetID, const SViewInfo& ViewInfo);
CLight* Light();

View File

@@ -205,6 +205,7 @@ void CDamageableTriggerExtra::Draw(ERenderOptions Options, int /*ComponentIndex*
CGraphics::sPixelBlock.TintColor = mpParent->TintColor(ViewInfo).ToVector4f();
mpMat->SetCurrent(Options);
// Note: The plane the game renders this onto is 5x4.5, which is why we divide the tex coords by this value
CVector2f TexUL(0.f, mCoordScale.y / 4.5f);
CVector2f TexUR(mCoordScale.x / 5.f, mCoordScale.y / 4.5f);
CVector2f TexBR(mCoordScale.x / 5.f, 0.f);