Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/components/CCmpSelectable.cpp
Show First 20 Lines • Show All 460 Lines • ▼ Show 20 Lines | void CCmpSelectable::UpdateTexturedLineOverlay(const SOverlayDescriptor* overlayDescriptor, SOverlayTexturedLine& overlay, float frameOffset, bool buildingOverlay) | ||||
entity_pos_t fpSize0_fixed, fpSize1_fixed, fpHeight_fixed; | entity_pos_t fpSize0_fixed, fpSize1_fixed, fpHeight_fixed; | ||||
cmpFootprint->GetShape(fpShape, fpSize0_fixed, fpSize1_fixed, fpHeight_fixed); | cmpFootprint->GetShape(fpShape, fpSize0_fixed, fpSize1_fixed, fpHeight_fixed); | ||||
float rotY; | float rotY; | ||||
CVector2D origin; | CVector2D origin; | ||||
cmpPosition->GetInterpolatedPosition2D(frameOffset, origin.X, origin.Y, rotY); | cmpPosition->GetInterpolatedPosition2D(frameOffset, origin.X, origin.Y, rotY); | ||||
CFixedVector3D rotation = cmpPosition->GetRotation(); | CFixedVector3D rotation = cmpPosition->GetRotation(); | ||||
CTextureProperties texturePropsBase(overlayDescriptor->m_LineTexture.c_str()); | g_Renderer.GetTextureManager().PrepareOverlayTexture(overlayDescriptor->m_LineTexture.c_str(), | ||||
texturePropsBase.SetWrap(GL_CLAMP_TO_BORDER, GL_CLAMP_TO_EDGE); | overlayDescriptor->m_LineTextureMask.c_str(), overlay.m_TextureBase, overlay.m_TextureMask, 4.f); | ||||
texturePropsBase.SetMaxAnisotropy(4.f); | |||||
CTextureProperties texturePropsMask(overlayDescriptor->m_LineTextureMask.c_str()); | |||||
texturePropsMask.SetWrap(GL_CLAMP_TO_BORDER, GL_CLAMP_TO_EDGE); | |||||
texturePropsMask.SetMaxAnisotropy(4.f); | |||||
overlay.m_AlwaysVisible = false; | overlay.m_AlwaysVisible = false; | ||||
overlay.m_Closed = true; | overlay.m_Closed = true; | ||||
overlay.m_SimContext = &GetSimContext(); | overlay.m_SimContext = &GetSimContext(); | ||||
overlay.m_Thickness = overlayDescriptor->m_LineThickness; | overlay.m_Thickness = overlayDescriptor->m_LineThickness; | ||||
overlay.m_TextureBase = g_Renderer.GetTextureManager().CreateTexture(texturePropsBase); | |||||
overlay.m_TextureMask = g_Renderer.GetTextureManager().CreateTexture(texturePropsMask); | |||||
overlay.m_Color = m_Color; | overlay.m_Color = m_Color; | ||||
if (buildingOverlay && fpShape == ICmpFootprint::SQUARE) | if (buildingOverlay && fpShape == ICmpFootprint::SQUARE) | ||||
{ | { | ||||
float s = sinf(-rotation.Y.ToFloat()); | float s = sinf(-rotation.Y.ToFloat()); | ||||
float c = cosf(-rotation.Y.ToFloat()); | float c = cosf(-rotation.Y.ToFloat()); | ||||
CVector2D unitX(c, s); | CVector2D unitX(c, s); | ||||
CVector2D unitZ(-s, c); | CVector2D unitZ(-s, c); | ||||
▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | void CCmpSelectable::UpdateDynamicOverlay(float frameOffset) | ||||
// --------------------------------------------------------------------------------- | // --------------------------------------------------------------------------------- | ||||
if (!m_UnitOverlay) | if (!m_UnitOverlay) | ||||
{ | { | ||||
m_UnitOverlay = new SOverlayQuad; | m_UnitOverlay = new SOverlayQuad; | ||||
// Assuming we don't need the capability of swapping textures on-demand. | // Assuming we don't need the capability of swapping textures on-demand. | ||||
CTextureProperties texturePropsBase(m_OverlayDescriptor.m_QuadTexture.c_str()); | g_Renderer.GetTextureManager().PrepareOverlayTexture(m_OverlayDescriptor.m_QuadTexture.c_str(), | ||||
texturePropsBase.SetWrap(GL_CLAMP_TO_BORDER, GL_CLAMP_TO_EDGE); | m_OverlayDescriptor.m_QuadTextureMask.c_str(), m_UnitOverlay->m_Texture, m_UnitOverlay->m_TextureMask, 4.f); | ||||
texturePropsBase.SetMaxAnisotropy(4.f); | |||||
CTextureProperties texturePropsMask(m_OverlayDescriptor.m_QuadTextureMask.c_str()); | |||||
texturePropsMask.SetWrap(GL_CLAMP_TO_BORDER, GL_CLAMP_TO_EDGE); | |||||
texturePropsMask.SetMaxAnisotropy(4.f); | |||||
m_UnitOverlay->m_Texture = g_Renderer.GetTextureManager().CreateTexture(texturePropsBase); | |||||
m_UnitOverlay->m_TextureMask = g_Renderer.GetTextureManager().CreateTexture(texturePropsMask); | |||||
} | } | ||||
m_UnitOverlay->m_Color = m_Color; | m_UnitOverlay->m_Color = m_Color; | ||||
// TODO: some code duplication here :< would be nice to factor out getting the corner points of an | // TODO: some code duplication here :< would be nice to factor out getting the corner points of an | ||||
// entity based on its footprint sizes (and regardless of whether it's a circle or a square) | // entity based on its footprint sizes (and regardless of whether it's a circle or a square) | ||||
float s = sinf(-rotY); | float s = sinf(-rotY); | ||||
▲ Show 20 Lines • Show All 131 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator