Changeset View
Changeset View
Standalone View
Standalone View
source/renderer/TexturedLineRData.cpp
Show All 15 Lines | |||||
*/ | */ | ||||
#include "precompiled.h" | #include "precompiled.h" | ||||
#include "TexturedLineRData.h" | #include "TexturedLineRData.h" | ||||
#include "graphics/ShaderProgram.h" | #include "graphics/ShaderProgram.h" | ||||
#include "graphics/Terrain.h" | #include "graphics/Terrain.h" | ||||
#include "graphics/Water.h" | |||||
#include "maths/Frustum.h" | #include "maths/Frustum.h" | ||||
#include "maths/MathUtil.h" | #include "maths/MathUtil.h" | ||||
#include "maths/Quaternion.h" | #include "maths/Quaternion.h" | ||||
#include "ps/CStrInternStatic.h" | #include "ps/CStrInternStatic.h" | ||||
#include "ps/World.h" | |||||
#include "renderer/OverlayRenderer.h" | #include "renderer/OverlayRenderer.h" | ||||
#include "renderer/Renderer.h" | #include "renderer/Renderer.h" | ||||
#include "simulation2/Simulation2.h" | |||||
#include "simulation2/system/SimContext.h" | #include "simulation2/system/SimContext.h" | ||||
#include "simulation2/components/ICmpWaterManager.h" | |||||
/* Note: this implementation uses g_VBMan directly rather than access it through the nicer VertexArray interface, | /* Note: this implementation uses g_VBMan directly rather than access it through the nicer VertexArray interface, | ||||
* because it allows you to work with variable amounts of vertices and indices more easily. New code should prefer | * because it allows you to work with variable amounts of vertices and indices more easily. New code should prefer | ||||
* to use VertexArray where possible, though. */ | * to use VertexArray where possible, though. */ | ||||
void CTexturedLineRData::Render(const SOverlayTexturedLine& line, const CShaderProgramPtr& shader) | void CTexturedLineRData::Render(const SOverlayTexturedLine& line, const CShaderProgramPtr& shader) | ||||
{ | { | ||||
if (!m_VB || !m_VBIndices) | if (!m_VB || !m_VBIndices) | ||||
Show All 28 Lines | void CTexturedLineRData::Render(const SOverlayTexturedLine& line, const CShaderProgramPtr& shader) | ||||
g_Renderer.GetStats().m_OverlayTris += m_VBIndices->m_Count/3; | g_Renderer.GetStats().m_OverlayTris += m_VBIndices->m_Count/3; | ||||
} | } | ||||
void CTexturedLineRData::Update(const SOverlayTexturedLine& line) | void CTexturedLineRData::Update(const SOverlayTexturedLine& line) | ||||
{ | { | ||||
m_VBIndices.Reset(); | m_VBIndices.Reset(); | ||||
m_VB.Reset(); | m_VB.Reset(); | ||||
if (!line.m_SimContext) | if (!line.m_SimContext || !line.m_SimContext->GetWorld()) | ||||
{ | { | ||||
debug_warn(L"[TexturedLineRData] No SimContext set for textured overlay line, cannot render (no terrain data)"); | debug_warn(L"[TexturedLineRData] No SimContext set for textured overlay line, cannot render (no terrain data)"); | ||||
return; | return; | ||||
} | } | ||||
float v = 0.f; | float v = 0.f; | ||||
std::vector<SVertex> vertices; | std::vector<SVertex> vertices; | ||||
std::vector<u16> indices; | std::vector<u16> indices; | ||||
Show All 21 Lines | void CTexturedLineRData::Update(const SOverlayTexturedLine& line) | ||||
bool p1floating = false; | bool p1floating = false; | ||||
bool p2floating = false; | bool p2floating = false; | ||||
// Compute terrain heights, clamped to the water height (and remember whether | // Compute terrain heights, clamped to the water height (and remember whether | ||||
// each point was floating on water, for normal computation later) | // each point was floating on water, for normal computation later) | ||||
// TODO: if we ever support more than one water level per map, recompute this per point | // TODO: if we ever support more than one water level per map, recompute this per point | ||||
CmpPtr<ICmpWaterManager> cmpWaterManager(*line.m_SimContext, SYSTEM_ENTITY); | float w = line.m_SimContext->GetWorld()->GetWater()->GetExactWaterHeight(p0.X, p0.Z); | ||||
float w = cmpWaterManager ? cmpWaterManager->GetExactWaterLevel(p0.X, p0.Z) : 0.f; | |||||
const CTerrain& terrain = line.m_SimContext->GetTerrain(); | const CTerrain& terrain = line.m_SimContext->GetTerrain(); | ||||
p0.Y = terrain.GetExactGroundLevel(p0.X, p0.Z); | p0.Y = terrain.GetExactGroundLevel(p0.X, p0.Z); | ||||
if (p0.Y < w) | if (p0.Y < w) | ||||
p0.Y = w; | p0.Y = w; | ||||
p1.Y = terrain.GetExactGroundLevel(p1.X, p1.Z); | p1.Y = terrain.GetExactGroundLevel(p1.X, p1.Z); | ||||
▲ Show 20 Lines • Show All 321 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator