mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-21 10:49:23 +00:00
Added a couple more collision view features; set up a proper UI for changing collision render settings
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#ifndef SVIEWINFO
|
||||
#define SVIEWINFO
|
||||
|
||||
#include "Core/Resource/CCollisionMaterial.h"
|
||||
#include "Core/Scene/FShowFlags.h"
|
||||
#include <Math/CFrustumPlanes.h>
|
||||
#include <Math/CMatrix4f.h>
|
||||
@@ -10,6 +11,8 @@ struct SCollisionRenderSettings
|
||||
{
|
||||
u64 HighlightMask;
|
||||
u64 HideMask;
|
||||
|
||||
CCollisionMaterial HideMaterial;
|
||||
bool DrawWireframe;
|
||||
bool DrawBackfaces;
|
||||
bool DrawAreaCollisionBounds;
|
||||
@@ -23,7 +26,7 @@ struct SCollisionRenderSettings
|
||||
, DrawBackfaces(false)
|
||||
, DrawAreaCollisionBounds(true)
|
||||
, TintWithSurfaceColor(true)
|
||||
, TintUnwalkableTris(false) {}
|
||||
, TintUnwalkableTris(true) {}
|
||||
};
|
||||
|
||||
struct SViewInfo
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "CCollisionMaterial.h"
|
||||
#include "EGame.h"
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
|
||||
ECollisionFlag CCollisionMaterial::SurfaceType(EGame Game) const
|
||||
{
|
||||
@@ -42,7 +42,7 @@ ECollisionFlag CCollisionMaterial::SurfaceType(EGame Game) const
|
||||
}
|
||||
|
||||
// Type-to-color mappings
|
||||
const std::map<ECollisionFlag, CColor> gkTypeToColor = {
|
||||
const std::unordered_map<ECollisionFlag, CColor> gkTypeToColor = {
|
||||
{ eCF_Stone, CColor::Integral(220, 215, 160) }, // Brownish/greenish
|
||||
{ eCF_Metal, CColor::Integral(143, 143, 143) }, // Gray
|
||||
{ eCF_Grass, CColor::Integral( 90, 150, 70) }, // Green
|
||||
|
||||
@@ -122,7 +122,7 @@ void CCollisionMesh::Draw()
|
||||
mVBO.Unbind();
|
||||
}
|
||||
|
||||
void CCollisionMesh::DrawMaterial(u32 MatIdx)
|
||||
void CCollisionMesh::DrawMaterial(u32 MatIdx, bool Wireframe)
|
||||
{
|
||||
if (!mBuffered) BufferGL();
|
||||
ASSERT(MatIdx < mMaterials.size());
|
||||
@@ -130,7 +130,18 @@ void CCollisionMesh::DrawMaterial(u32 MatIdx)
|
||||
mVBO.Bind();
|
||||
u32 StartIdx = (MatIdx == 0 ? 0 : mMaterialOffsets[MatIdx - 1]);
|
||||
u32 NumElements = mMaterialOffsets[MatIdx] - StartIdx;
|
||||
|
||||
if (Wireframe)
|
||||
{
|
||||
CDrawUtil::UseColorShader(CColor::skBlack);
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
}
|
||||
|
||||
mIBO.DrawElements(StartIdx, NumElements);
|
||||
|
||||
if (Wireframe)
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
|
||||
mVBO.Unbind();
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ public:
|
||||
|
||||
void BufferGL();
|
||||
void Draw();
|
||||
void DrawMaterial(u32 MatIdx);
|
||||
void DrawMaterial(u32 MatIdx, bool Wireframe);
|
||||
void DrawWireframe();
|
||||
|
||||
inline u32 NumMaterials() const { return mMaterials.size(); }
|
||||
|
||||
@@ -54,7 +54,10 @@ void CCollisionNode::Draw(FRenderOptions /*Options*/, int /*ComponentIndex*/, ER
|
||||
{
|
||||
CCollisionMaterial& rMat = pMesh->GetMaterial(iMat);
|
||||
|
||||
if (rkViewInfo.CollisionSettings.HideMask != 0 && (rMat.RawFlags() & rkViewInfo.CollisionSettings.HideMask) == rkViewInfo.CollisionSettings.HideMask)
|
||||
if (rkViewInfo.CollisionSettings.HideMaterial & rMat)
|
||||
continue;
|
||||
|
||||
if (rkViewInfo.CollisionSettings.HideMask != 0 && (rMat.RawFlags() & rkViewInfo.CollisionSettings.HideMask) != 0)
|
||||
continue;
|
||||
|
||||
CColor Tint = BaseTint;
|
||||
@@ -65,17 +68,14 @@ void CCollisionNode::Draw(FRenderOptions /*Options*/, int /*ComponentIndex*/, ER
|
||||
else if (CollisionGame != eReturns && rkViewInfo.CollisionSettings.TintWithSurfaceColor)
|
||||
Tint *= rMat.SurfaceColor(CollisionGame);
|
||||
|
||||
bool IsFloor = (rkViewInfo.CollisionSettings.TintUnwalkableTris ? rMat.HasFlag(eCF_Floor) : true);
|
||||
bool IsUnstandable = (rkViewInfo.CollisionSettings.TintUnwalkableTris ? rMat.HasFlag(eCF_JumpNotAllowed) : false);
|
||||
bool IsFloor = (rkViewInfo.CollisionSettings.TintUnwalkableTris ? rMat.HasFlag(eCF_Floor) : true) || CollisionGame == eReturns;
|
||||
bool IsUnstandable = (rkViewInfo.CollisionSettings.TintUnwalkableTris ? rMat.HasFlag(eCF_JumpNotAllowed) : false) && CollisionGame != eReturns;
|
||||
CDrawUtil::UseCollisionShader(IsFloor, IsUnstandable, Tint);
|
||||
pMesh->DrawMaterial(iMat);
|
||||
}
|
||||
}
|
||||
pMesh->DrawMaterial(iMat, false);
|
||||
|
||||
if (rkViewInfo.CollisionSettings.DrawWireframe)
|
||||
{
|
||||
CDrawUtil::UseColorShader(CColor::skTransparentBlack);
|
||||
mpCollision->DrawWireframe();
|
||||
if (rkViewInfo.CollisionSettings.DrawWireframe)
|
||||
pMesh->DrawMaterial(iMat, true);
|
||||
}
|
||||
}
|
||||
|
||||
// Restore backface culling setting
|
||||
@@ -85,7 +85,7 @@ void CCollisionNode::Draw(FRenderOptions /*Options*/, int /*ComponentIndex*/, ER
|
||||
// Draw collision bounds for area collision
|
||||
// note: right now checking parent is the best way to check whether this node is area collision instead of actor collision
|
||||
// actor collision will have a script node parent whereas area collision will have a root node parent
|
||||
if (rkViewInfo.CollisionSettings.DrawAreaCollisionBounds && Parent()->NodeType() == eRootNode)
|
||||
if (rkViewInfo.CollisionSettings.DrawAreaCollisionBounds && Parent()->NodeType() == eRootNode && CollisionGame != eReturns)
|
||||
CDrawUtil::DrawWireCube( mpCollision->MeshByIndex(0)->BoundingBox(), CColor::skRed );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user