Replace template function by direct position access
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2112 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
d021013af2
commit
a771f88caf
|
@ -518,14 +518,13 @@ namespace scene
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TerrainData.Position = TerrainData.Position;
|
TerrainData.Position = TerrainData.Position;
|
||||||
video::S3DVertex2TCoords* meshVertices = (video::S3DVertex2TCoords*)Mesh.getMeshBuffer(0)->getVertices();
|
|
||||||
s32 vtxCount = Mesh.getMeshBuffer(0)->getVertexCount();
|
s32 vtxCount = Mesh.getMeshBuffer(0)->getVertexCount();
|
||||||
core::matrix4 rotMatrix;
|
core::matrix4 rotMatrix;
|
||||||
rotMatrix.setRotationDegrees(TerrainData.Rotation);
|
rotMatrix.setRotationDegrees(TerrainData.Rotation);
|
||||||
|
|
||||||
for (s32 i = 0; i < vtxCount; ++i)
|
for (s32 i = 0; i < vtxCount; ++i)
|
||||||
{
|
{
|
||||||
RenderBuffer->getVertexBuffer()[i].Pos = meshVertices[i].Pos * TerrainData.Scale + TerrainData.Position;
|
RenderBuffer->getVertexBuffer()[i].Pos = Mesh.getMeshBuffer(0)->getPosition(i) * TerrainData.Scale + TerrainData.Position;
|
||||||
|
|
||||||
RenderBuffer->getVertexBuffer()[i].Pos -= TerrainData.RotationPivot;
|
RenderBuffer->getVertexBuffer()[i].Pos -= TerrainData.RotationPivot;
|
||||||
rotMatrix.inverseRotateVect(RenderBuffer->getVertexBuffer()[i].Pos);
|
rotMatrix.inverseRotateVect(RenderBuffer->getVertexBuffer()[i].Pos);
|
||||||
|
@ -634,29 +633,16 @@ namespace scene
|
||||||
|
|
||||||
void CTerrainSceneNode::preRenderIndicesCalculations()
|
void CTerrainSceneNode::preRenderIndicesCalculations()
|
||||||
{
|
{
|
||||||
switch (RenderBuffer->getIndexBuffer().getType())
|
scene::IIndexBuffer& indexBuffer = RenderBuffer->getIndexBuffer();
|
||||||
{
|
|
||||||
case video::EIT_16BIT:
|
|
||||||
preRenderIndicesCalculationsDirect<u16>((u16*)RenderBuffer->getIndexBuffer().pointer());
|
|
||||||
break;
|
|
||||||
case video::EIT_32BIT:
|
|
||||||
preRenderIndicesCalculationsDirect<u32>((u32*)RenderBuffer->getIndexBuffer().pointer());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class INDEX_TYPE>
|
|
||||||
void CTerrainSceneNode::preRenderIndicesCalculationsDirect(INDEX_TYPE* IndexBuffer)
|
|
||||||
{
|
|
||||||
IndicesToRender = 0;
|
IndicesToRender = 0;
|
||||||
|
indexBuffer.set_used(0);
|
||||||
|
|
||||||
|
s32 index = 0;
|
||||||
// Then generate the indices for all patches that are visible.
|
// Then generate the indices for all patches that are visible.
|
||||||
for (s32 i = 0; i < TerrainData.PatchCount; ++i)
|
for (s32 i = 0; i < TerrainData.PatchCount; ++i)
|
||||||
{
|
{
|
||||||
for (s32 j = 0; j < TerrainData.PatchCount; ++j)
|
for (s32 j = 0; j < TerrainData.PatchCount; ++j)
|
||||||
{
|
{
|
||||||
const s32 index = i * TerrainData.PatchCount + j;
|
|
||||||
if (TerrainData.Patches[index].CurrentLOD >= 0)
|
if (TerrainData.Patches[index].CurrentLOD >= 0)
|
||||||
{
|
{
|
||||||
s32 x = 0;
|
s32 x = 0;
|
||||||
|
@ -673,12 +659,13 @@ namespace scene
|
||||||
const s32 index12 = getIndex(j, i, index, x, z + step);
|
const s32 index12 = getIndex(j, i, index, x, z + step);
|
||||||
const s32 index22 = getIndex(j, i, index, x + step, z + step);
|
const s32 index22 = getIndex(j, i, index, x + step, z + step);
|
||||||
|
|
||||||
IndexBuffer[IndicesToRender++]= static_cast<INDEX_TYPE>(index12);
|
indexBuffer.push_back(index12);
|
||||||
IndexBuffer[IndicesToRender++]= static_cast<INDEX_TYPE>(index11);
|
indexBuffer.push_back(index11);
|
||||||
IndexBuffer[IndicesToRender++]= static_cast<INDEX_TYPE>(index22);
|
indexBuffer.push_back(index22);
|
||||||
IndexBuffer[IndicesToRender++]= static_cast<INDEX_TYPE>(index22);
|
indexBuffer.push_back(index22);
|
||||||
IndexBuffer[IndicesToRender++]= static_cast<INDEX_TYPE>(index11);
|
indexBuffer.push_back(index11);
|
||||||
IndexBuffer[IndicesToRender++]= static_cast<INDEX_TYPE>(index21);
|
indexBuffer.push_back(index21);
|
||||||
|
IndicesToRender+=6;
|
||||||
|
|
||||||
// increment index position horizontally
|
// increment index position horizontally
|
||||||
x += step;
|
x += step;
|
||||||
|
@ -691,6 +678,7 @@ namespace scene
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
++index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -278,9 +278,6 @@ namespace scene
|
||||||
virtual void preRenderLODCalculations();
|
virtual void preRenderLODCalculations();
|
||||||
virtual void preRenderIndicesCalculations();
|
virtual void preRenderIndicesCalculations();
|
||||||
|
|
||||||
template<class INDEX_TYPE>
|
|
||||||
void preRenderIndicesCalculationsDirect(INDEX_TYPE* IndexBuffer);
|
|
||||||
|
|
||||||
//! get indices when generating index data for patches at varying levels of detail.
|
//! get indices when generating index data for patches at varying levels of detail.
|
||||||
u32 getIndex(const s32 PatchX, const s32 PatchZ, const s32 PatchIndex, u32 vX, u32 vZ) const;
|
u32 getIndex(const s32 PatchX, const s32 PatchZ, const s32 PatchIndex, u32 vX, u32 vZ) const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue