Commit 5ecfec33 authored by hybrid's avatar hybrid

Fix problems with VC6 and Borland. Some indentation fixes.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1001 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 219e956c
...@@ -72,18 +72,25 @@ bool COpenGLDriver::initDriver(const core::dimension2d<s32>& screenSize, ...@@ -72,18 +72,25 @@ bool COpenGLDriver::initDriver(const core::dimension2d<s32>& screenSize,
if (i == 1) if (i == 1)
{ {
if (stencilBuffer) if (stencilBuffer)
{
os::Printer::log("Cannot create a GL device with stencil buffer, disabling stencil shadows.", ELL_WARNING); os::Printer::log("Cannot create a GL device with stencil buffer, disabling stencil shadows.", ELL_WARNING);
stencilBuffer = false; stencilBuffer = false;
pfd.cStencilBits = 0; pfd.cStencilBits = 0;
}
else
continue;
} }
else else
if (i == 2) if (i == 2)
{ {
pfd.cDepthBits = 24; pfd.cDepthBits = 24;
} }
if (i == 3) // might be checked twice, but shouldn't matter if (i == 3)
{ {
pfd.cDepthBits = 16; if (bits!=16)
pfd.cDepthBits = 16;
else
continue;
} }
else else
if (i == 4) if (i == 4)
......
...@@ -702,12 +702,6 @@ ITerrainSceneNode* CSceneManager::addTerrainSceneNode( ...@@ -702,12 +702,6 @@ ITerrainSceneNode* CSceneManager::addTerrainSceneNode(
bool addAlsoIfHeightmapEmpty) bool addAlsoIfHeightmapEmpty)
{ {
io::IReadFile* file = FileSystem->createAndOpenFile(heightMapFileName); io::IReadFile* file = FileSystem->createAndOpenFile(heightMapFileName);
if (!file && !addAlsoIfHeightmapEmpty)
{
os::Printer::log("Could not load terrain, because file could not be opened.",
heightMapFileName, ELL_ERROR);
return 0;
}
ITerrainSceneNode* terrain = addTerrainSceneNode(file, parent, id, ITerrainSceneNode* terrain = addTerrainSceneNode(file, parent, id,
position, rotation, scale, vertexColor, maxLOD, patchSize, position, rotation, scale, vertexColor, maxLOD, patchSize,
...@@ -734,6 +728,13 @@ ITerrainSceneNode* CSceneManager::addTerrainSceneNode( ...@@ -734,6 +728,13 @@ ITerrainSceneNode* CSceneManager::addTerrainSceneNode(
if (!parent) if (!parent)
parent = this; parent = this;
if (!heightMapFile && !addAlsoIfHeightmapEmpty)
{
os::Printer::log("Could not load terrain, because file could not be opened.",
heightMapFile->getFileName(), ELL_ERROR);
return 0;
}
CTerrainSceneNode* node = new CTerrainSceneNode(parent, this, FileSystem, id, CTerrainSceneNode* node = new CTerrainSceneNode(parent, this, FileSystem, id,
maxLOD, patchSize, position, rotation, scale); maxLOD, patchSize, position, rotation, scale);
......
...@@ -241,7 +241,7 @@ void CTRTextureGouraud2::scanline_bilinear () ...@@ -241,7 +241,7 @@ void CTRTextureGouraud2::scanline_bilinear ()
tx0 = f32_to_fixPoint ( line.t0[0].x ); tx0 = f32_to_fixPoint ( line.t0[0].x );
ty0 = f32_to_fixPoint ( line.t0[0].y ); ty0 = f32_to_fixPoint ( line.t0[0].y );
#ifdef IPOL_C0 #ifdef IPOL_C0
getTexel_plain ( r1, g1, b1, line.c[0] ); getTexel_plain2 ( r1, g1, b1, line.c[0] );
#endif #endif
#endif #endif
......
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
// The code for the TerrainSceneNode is based on the GeoMipMapSceneNode // The code for the TerrainSceneNode is based on the GeoMipMapSceneNode
// developed by Spintz. He made it available for Irrlicht and allowed it to be // developed by Spintz. He made it available for Irrlicht and allowed it to be
// distributed under this licence. I only modified some parts. A lot of thanks go to him. // distributed under this licence. I only modified some parts. A lot of thanks
// go to him.
#include "CTerrainSceneNode.h" #include "CTerrainSceneNode.h"
#include "CTerrainTriangleSelector.h" #include "CTerrainTriangleSelector.h"
...@@ -49,6 +50,7 @@ namespace scene ...@@ -49,6 +50,7 @@ namespace scene
setAutomaticCulling( scene::EAC_OFF ); setAutomaticCulling( scene::EAC_OFF );
} }
//! destructor //! destructor
CTerrainSceneNode::~CTerrainSceneNode ( ) CTerrainSceneNode::~CTerrainSceneNode ( )
{ {
...@@ -62,6 +64,7 @@ namespace scene ...@@ -62,6 +64,7 @@ namespace scene
FileSystem->drop(); FileSystem->drop();
} }
//! Initializes the terrain data. Loads the vertices from the heightMapFile //! Initializes the terrain data. Loads the vertices from the heightMapFile
bool CTerrainSceneNode::loadHeightMap( io::IReadFile* file, video::SColor vertexColor, s32 smoothFactor ) bool CTerrainSceneNode::loadHeightMap( io::IReadFile* file, video::SColor vertexColor, s32 smoothFactor )
{ {
...@@ -84,35 +87,35 @@ namespace scene ...@@ -84,35 +87,35 @@ namespace scene
switch( TerrainData.PatchSize ) switch( TerrainData.PatchSize )
{ {
case ETPS_9: case ETPS_9:
if( TerrainData.MaxLOD > 3 ) if( TerrainData.MaxLOD > 3 )
{ {
TerrainData.MaxLOD = 3; TerrainData.MaxLOD = 3;
} }
break; break;
case ETPS_17: case ETPS_17:
if( TerrainData.MaxLOD > 4 ) if( TerrainData.MaxLOD > 4 )
{ {
TerrainData.MaxLOD = 4; TerrainData.MaxLOD = 4;
} }
break; break;
case ETPS_33: case ETPS_33:
if( TerrainData.MaxLOD > 5 ) if( TerrainData.MaxLOD > 5 )
{ {
TerrainData.MaxLOD = 5; TerrainData.MaxLOD = 5;
} }
break; break;
case ETPS_65: case ETPS_65:
if( TerrainData.MaxLOD > 6 ) if( TerrainData.MaxLOD > 6 )
{ {
TerrainData.MaxLOD = 6; TerrainData.MaxLOD = 6;
} }
break; break;
case ETPS_129: case ETPS_129:
if( TerrainData.MaxLOD > 7 ) if( TerrainData.MaxLOD > 7 )
{ {
TerrainData.MaxLOD = 7; TerrainData.MaxLOD = 7;
} }
break; break;
} }
...@@ -180,12 +183,12 @@ namespace scene ...@@ -180,12 +183,12 @@ namespace scene
// add the MeshBuffer to the mesh // add the MeshBuffer to the mesh
Mesh.addMeshBuffer( pMeshBuffer ); Mesh.addMeshBuffer( pMeshBuffer );
s32 vertexCount = pMeshBuffer->getVertexCount(); const u32 vertexCount = pMeshBuffer->getVertexCount();
// We copy the data to the renderBuffer, after the normals have been calculated. // We copy the data to the renderBuffer, after the normals have been calculated.
RenderBuffer.Vertices.set_used( vertexCount ); RenderBuffer.Vertices.set_used( vertexCount );
for( s32 i = 0; i < vertexCount; ++i ) for( u32 i = 0; i < vertexCount; ++i )
{ {
RenderBuffer.Vertices[i] = pMeshBuffer->Vertices[i]; RenderBuffer.Vertices[i] = pMeshBuffer->Vertices[i];
RenderBuffer.Vertices[i].Pos *= TerrainData.Scale; RenderBuffer.Vertices[i].Pos *= TerrainData.Scale;
...@@ -203,16 +206,16 @@ namespace scene ...@@ -203,16 +206,16 @@ namespace scene
// set the default rotation pivot point to the terrain nodes center // set the default rotation pivot point to the terrain nodes center
TerrainData.RotationPivot = TerrainData.Center; TerrainData.RotationPivot = TerrainData.Center;
// Rotate the vertices of the terrain by the rotation specified. Must be done // Rotate the vertices of the terrain by the rotation
// after calculating the terrain data, so we know what the current center of the // specified. Must be done after calculating the terrain data,
// terrain is. // so we know what the current center of the terrain is.
setRotation( TerrainData.Rotation ); setRotation( TerrainData.Rotation );
// Pre-allocate memory for indices // Pre-allocate memory for indices
RenderBuffer.Indices.set_used( TerrainData.PatchCount * TerrainData.PatchCount * RenderBuffer.Indices.set_used( TerrainData.PatchCount * TerrainData.PatchCount *
TerrainData.CalcPatchSize * TerrainData.CalcPatchSize * 6 ); TerrainData.CalcPatchSize * TerrainData.CalcPatchSize * 6 );
u32 endTime = os::Timer::getRealTime(); const u32 endTime = os::Timer::getRealTime();
c8 tmp[255]; c8 tmp[255];
sprintf(tmp, "Generated terrain data (%dx%d) in %.4f seconds", sprintf(tmp, "Generated terrain data (%dx%d) in %.4f seconds",
...@@ -240,35 +243,35 @@ namespace scene ...@@ -240,35 +243,35 @@ namespace scene
switch( TerrainData.PatchSize ) switch( TerrainData.PatchSize )
{ {
case ETPS_9: case ETPS_9:
if( TerrainData.MaxLOD > 3 ) if( TerrainData.MaxLOD > 3 )
{ {
TerrainData.MaxLOD = 3; TerrainData.MaxLOD = 3;
} }
break; break;
case ETPS_17: case ETPS_17:
if( TerrainData.MaxLOD > 4 ) if( TerrainData.MaxLOD > 4 )
{ {
TerrainData.MaxLOD = 4; TerrainData.MaxLOD = 4;
} }
break; break;
case ETPS_33: case ETPS_33:
if( TerrainData.MaxLOD > 5 ) if( TerrainData.MaxLOD > 5 )
{ {
TerrainData.MaxLOD = 5; TerrainData.MaxLOD = 5;
} }
break; break;
case ETPS_65: case ETPS_65:
if( TerrainData.MaxLOD > 6 ) if( TerrainData.MaxLOD > 6 )
{ {
TerrainData.MaxLOD = 6; TerrainData.MaxLOD = 6;
} }
break; break;
case ETPS_129: case ETPS_129:
if( TerrainData.MaxLOD > 7 ) if( TerrainData.MaxLOD > 7 )
{ {
TerrainData.MaxLOD = 7; TerrainData.MaxLOD = 7;
} }
break; break;
} }
...@@ -337,12 +340,12 @@ namespace scene ...@@ -337,12 +340,12 @@ namespace scene
// add the MeshBuffer to the mesh // add the MeshBuffer to the mesh
Mesh.addMeshBuffer( pMeshBuffer ); Mesh.addMeshBuffer( pMeshBuffer );
s32 vertexCount = pMeshBuffer->getVertexCount(); const u32 vertexCount = pMeshBuffer->getVertexCount();
// We copy the data to the renderBuffer, after the normals have been calculated. // We copy the data to the renderBuffer, after the normals have been calculated.
RenderBuffer.Vertices.set_used( vertexCount ); RenderBuffer.Vertices.set_used( vertexCount );
for( s32 i = 0; i < vertexCount; i++ ) for( u32 i = 0; i < vertexCount; i++ )
{ {
RenderBuffer.Vertices[i] = pMeshBuffer->Vertices[i]; RenderBuffer.Vertices[i] = pMeshBuffer->Vertices[i];
RenderBuffer.Vertices[i].Pos *= TerrainData.Scale; RenderBuffer.Vertices[i].Pos *= TerrainData.Scale;
...@@ -992,6 +995,7 @@ namespace scene ...@@ -992,6 +995,7 @@ namespace scene
core::vector3df a, b, c, t; core::vector3df a, b, c, t;
for (s32 x=0; x<TerrainData.Size; ++x) for (s32 x=0; x<TerrainData.Size; ++x)
{
for (s32 z=0; z<TerrainData.Size; ++z) for (s32 z=0; z<TerrainData.Size; ++z)
{ {
count = 0; count = 0;
...@@ -1104,6 +1108,7 @@ namespace scene ...@@ -1104,6 +1108,7 @@ namespace scene
pMeshBuffer->Vertices[x * TerrainData.Size + z].Normal = normal; pMeshBuffer->Vertices[x * TerrainData.Size + z].Normal = normal;
} }
}
} }
//! create patches, stuff that needs to be done only once for patches goes here. //! create patches, stuff that needs to be done only once for patches goes here.
...@@ -1282,7 +1287,7 @@ namespace scene ...@@ -1282,7 +1287,7 @@ namespace scene
//! Reads attributes of the scene node. //! Reads attributes of the scene node.
void CTerrainSceneNode::deserializeAttributes(io::IAttributes* in, void CTerrainSceneNode::deserializeAttributes(io::IAttributes* in,
io::SAttributeReadWriteOptions* options) io::SAttributeReadWriteOptions* options)
{ {
core::stringc newHeightmap = in->getAttributeAsString("Heightmap"); core::stringc newHeightmap = in->getAttributeAsString("Heightmap");
f32 tcoordScale1 = in->getAttributeAsFloat("TextureScale1"); f32 tcoordScale1 = in->getAttributeAsFloat("TextureScale1");
...@@ -1324,12 +1329,14 @@ namespace scene ...@@ -1324,12 +1329,14 @@ namespace scene
//! Creates a clone of this scene node and its children. //! Creates a clone of this scene node and its children.
ISceneNode* CTerrainSceneNode::clone(ISceneNode* newParent, ISceneManager* newManager) ISceneNode* CTerrainSceneNode::clone(ISceneNode* newParent, ISceneManager* newManager)
{ {
if (!newParent) newParent = Parent; if (!newParent)
if (!newManager) newManager = SceneManager; newParent = Parent;
if (!newManager)
newManager = SceneManager;
CTerrainSceneNode* nb = new CTerrainSceneNode( CTerrainSceneNode* nb = new CTerrainSceneNode(
newParent, newManager, FileSystem, ID, newParent, newManager, FileSystem, ID,
4, ETPS_17, getPosition(), getRotation(), getScale()); 4, ETPS_17, getPosition(), getRotation(), getScale());
nb->cloneMembers(this, newManager); nb->cloneMembers(this, newManager);
......
...@@ -55,7 +55,7 @@ BOOL APIENTRY DllMain( HANDLE hModule, ...@@ -55,7 +55,7 @@ BOOL APIENTRY DllMain( HANDLE hModule,
switch (ul_reason_for_call) switch (ul_reason_for_call)
{ {
case DLL_PROCESS_ATTACH: case DLL_PROCESS_ATTACH:
#if defined(_DEBUG) && !defined(__GNUWIN32__) #if defined(_DEBUG) && !defined(__GNUWIN32__) && !defined(__BORLANDC__)
_CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF | _CRTDBG_ALLOC_MEM_DF); _CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF | _CRTDBG_ALLOC_MEM_DF);
#endif #endif
break; break;
......
...@@ -457,7 +457,7 @@ struct sScanLineData ...@@ -457,7 +457,7 @@ struct sScanLineData
/* /*
load a color value load a color value
*/ */
inline void getTexel_plain ( tFixPoint &r, tFixPoint &g, tFixPoint &b, inline void getTexel_plain2 ( tFixPoint &r, tFixPoint &g, tFixPoint &b,
const sVec4 &v const sVec4 &v
) )
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment