Changeset View
Changeset View
Standalone View
Standalone View
source/graphics/Decal.cpp
/* Copyright (C) 2021 Wildfire Games. | /* Copyright (C) 2022 Wildfire Games. | ||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
Show All 10 Lines | |||||
#include "Decal.h" | #include "Decal.h" | ||||
#include "graphics/Terrain.h" | #include "graphics/Terrain.h" | ||||
#include "maths/MathUtil.h" | #include "maths/MathUtil.h" | ||||
#include "ps/CStrInternStatic.h" | #include "ps/CStrInternStatic.h" | ||||
CModelAbstract* CModelDecal::Clone() const | CModelAbstract* CModelDecal::Clone() const | ||||
{ | { | ||||
CModelDecal* clone = new CModelDecal(m_Terrain, m_Decal); | CModelDecal* clone = new CModelDecal(m_Terrain, m_Water, m_Decal); | ||||
return clone; | return clone; | ||||
} | } | ||||
void CModelDecal::CalcVertexExtents(ssize_t& i0, ssize_t& j0, ssize_t& i1, ssize_t& j1) | void CModelDecal::CalcVertexExtents(ssize_t& i0, ssize_t& j0, ssize_t& i1, ssize_t& j1) | ||||
{ | { | ||||
CVector3D corner0(m_Decal.m_OffsetX + m_Decal.m_SizeX/2, 0, m_Decal.m_OffsetZ + m_Decal.m_SizeZ/2); | CVector3D corner0(m_Decal.m_OffsetX + m_Decal.m_SizeX/2, 0, m_Decal.m_OffsetZ + m_Decal.m_SizeZ/2); | ||||
CVector3D corner1(m_Decal.m_OffsetX + m_Decal.m_SizeX/2, 0, m_Decal.m_OffsetZ - m_Decal.m_SizeZ/2); | CVector3D corner1(m_Decal.m_OffsetX + m_Decal.m_SizeX/2, 0, m_Decal.m_OffsetZ - m_Decal.m_SizeZ/2); | ||||
CVector3D corner2(m_Decal.m_OffsetX - m_Decal.m_SizeX/2, 0, m_Decal.m_OffsetZ - m_Decal.m_SizeZ/2); | CVector3D corner2(m_Decal.m_OffsetX - m_Decal.m_SizeX/2, 0, m_Decal.m_OffsetZ - m_Decal.m_SizeZ/2); | ||||
Show All 14 Lines | void CModelDecal::CalcVertexExtents(ssize_t& i0, ssize_t& j0, ssize_t& i1, ssize_t& j1) | ||||
i1 = Clamp<ssize_t>(i1, 0, m_Terrain->GetVerticesPerSide() - 1); | i1 = Clamp<ssize_t>(i1, 0, m_Terrain->GetVerticesPerSide() - 1); | ||||
j1 = Clamp<ssize_t>(j1, 0, m_Terrain->GetVerticesPerSide() - 1); | j1 = Clamp<ssize_t>(j1, 0, m_Terrain->GetVerticesPerSide() - 1); | ||||
} | } | ||||
void CModelDecal::CalcBounds() | void CModelDecal::CalcBounds() | ||||
{ | { | ||||
ssize_t i0, j0, i1, j1; | ssize_t i0, j0, i1, j1; | ||||
CalcVertexExtents(i0, j0, i1, j1); | CalcVertexExtents(i0, j0, i1, j1); | ||||
m_WorldBounds = m_Terrain->GetVertexesBound(i0, j0, i1, j1); | m_WorldBounds = m_Terrain->GetVertexesBound(m_Water, i0, j0, i1, j1); | ||||
} | } | ||||
void CModelDecal::SetTerrainDirty(ssize_t i0, ssize_t j0, ssize_t i1, ssize_t j1) | void CModelDecal::SetTerrainDirty(ssize_t i0, ssize_t j0, ssize_t i1, ssize_t j1) | ||||
{ | { | ||||
// Check if there's no intersection between the dirty range and this decal | // Check if there's no intersection between the dirty range and this decal | ||||
ssize_t bi0, bj0, bi1, bj1; | ssize_t bi0, bj0, bi1, bj1; | ||||
CalcVertexExtents(bi0, bj0, bi1, bj1); | CalcVertexExtents(bi0, bj0, bi1, bj1); | ||||
if (bi1 < i0 || bi0 > i1 || bj1 < j0 || bj0 > j1) | if (bi1 < i0 || bi0 > i1 || bj1 < j0 || bj0 > j1) | ||||
▲ Show 20 Lines • Show All 49 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator