Changeset View
Changeset View
Standalone View
Standalone View
source/renderer/SilhouetteRenderer.cpp
Show All 20 Lines | |||||
#include "graphics/Camera.h" | #include "graphics/Camera.h" | ||||
#include "graphics/HFTracer.h" | #include "graphics/HFTracer.h" | ||||
#include "graphics/Model.h" | #include "graphics/Model.h" | ||||
#include "graphics/Patch.h" | #include "graphics/Patch.h" | ||||
#include "graphics/ShaderManager.h" | #include "graphics/ShaderManager.h" | ||||
#include "maths/MathUtil.h" | #include "maths/MathUtil.h" | ||||
#include "ps/Profile.h" | #include "ps/Profile.h" | ||||
#include "ps/ScreenSize.h" | |||||
#include "renderer/Renderer.h" | #include "renderer/Renderer.h" | ||||
#include "renderer/Scene.h" | #include "renderer/Scene.h" | ||||
#include <cfloat> | #include <cfloat> | ||||
extern int g_xres, g_yres; | |||||
// For debugging | // For debugging | ||||
static const bool g_DisablePreciseIntersections = false; | static const bool g_DisablePreciseIntersections = false; | ||||
SilhouetteRenderer::SilhouetteRenderer() | SilhouetteRenderer::SilhouetteRenderer() | ||||
{ | { | ||||
m_DebugEnabled = false; | m_DebugEnabled = false; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 186 Lines • ▼ Show 20 Lines | void SilhouetteRenderer::ComputeSubmissions(const CCamera& camera) | ||||
// Bump the positions of unit casters upwards a bit, so they're not always | // Bump the positions of unit casters upwards a bit, so they're not always | ||||
// detected as intersecting the terrain they're standing on | // detected as intersecting the terrain they're standing on | ||||
CVector3D posOffset(0.0f, 0.1f, 0.0f); | CVector3D posOffset(0.0f, 0.1f, 0.0f); | ||||
#if 0 | #if 0 | ||||
// For debugging ray-patch intersections - casts a ton of rays and draws | // For debugging ray-patch intersections - casts a ton of rays and draws | ||||
// a sphere where they intersect | // a sphere where they intersect | ||||
for (int y = 0; y < g_yres; y += 8) | for (int y = 0; y < g_ScreenSize.LogicalHeight(); y += 8) | ||||
{ | { | ||||
for (int x = 0; x < g_xres; x += 8) | for (int x = 0; x < g_ScreenSize.LogicalWidth(); x += 8) | ||||
{ | { | ||||
SOverlaySphere sphere; | SOverlaySphere sphere; | ||||
sphere.m_Color = CColor(1, 0, 0, 1); | sphere.m_Color = CColor(1, 0, 0, 1); | ||||
sphere.m_Radius = 0.25f; | sphere.m_Radius = 0.25f; | ||||
sphere.m_Center = camera.GetWorldCoordinates(x, y, false); | sphere.m_Center = camera.GetWorldCoordinates(x, y, false); | ||||
CVector3D origin, dir; | CVector3D origin, dir; | ||||
camera.BuildCameraRay(x, y, origin, dir); | camera.BuildCameraRay(x, y, origin, dir); | ||||
▲ Show 20 Lines • Show All 207 Lines • ▼ Show 20 Lines | void SilhouetteRenderer::RenderDebugOverlays(const CCamera& camera) | ||||
{ | { | ||||
shader->Uniform(str_color, m_DebugBounds[i].color); | shader->Uniform(str_color, m_DebugBounds[i].color); | ||||
m_DebugBounds[i].bounds.RenderOutline(shader); | m_DebugBounds[i].bounds.RenderOutline(shader); | ||||
} | } | ||||
CMatrix3D m; | CMatrix3D m; | ||||
m.SetIdentity(); | m.SetIdentity(); | ||||
m.Scale(1.0f, -1.f, 1.0f); | m.Scale(1.0f, -1.f, 1.0f); | ||||
m.Translate(0.0f, (float)g_yres, -1000.0f); | m.Translate(0.0f, (float)g_ScreenSize.ScreenHeight(), -1000.0f); | ||||
CMatrix3D proj; | CMatrix3D proj; | ||||
proj.SetOrtho(0.f, g_MaxCoord, 0.f, g_MaxCoord, -1.f, 1000.f); | proj.SetOrtho(0.f, g_MaxCoord, 0.f, g_MaxCoord, -1.f, 1000.f); | ||||
m = proj * m; | m = proj * m; | ||||
shader->Uniform(str_transform, proj); | shader->Uniform(str_transform, proj); | ||||
for (size_t i = 0; i < m_DebugRects.size(); ++i) | for (size_t i = 0; i < m_DebugRects.size(); ++i) | ||||
Show All 26 Lines |
Wildfire Games · Phabricator