Revision: 2530
http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=2530&view=rev
Author: ulteq
Date: 2012-05-09 00:09:21 +0000 (Wed, 09 May 2012)
Log Message:
-----------
-Codechange: Changed MeshObject.h ... style++
Modified Paths:
--------------
trunk/source/main/physics/flex/FlexBody.cpp
trunk/source/main/physics/flex/FlexBody.h
trunk/source/main/physics/input_output/SerializedRig.cpp
trunk/source/main/utils/MeshObject.cpp
trunk/source/main/utils/MeshObject.h
Modified: trunk/source/main/physics/flex/FlexBody.cpp
===================================================================
--- trunk/source/main/physics/flex/FlexBody.cpp 2012-05-09 00:02:48 UTC (rev
2529)
+++ trunk/source/main/physics/flex/FlexBody.cpp 2012-05-09 00:09:21 UTC (rev
2530)
@@ -19,6 +19,7 @@
*/
#include "FlexBody.h"
+#include "approxmath.h"
#include "MaterialReplacer.h"
#include "ResourceBuffer.h"
#include "Settings.h"
@@ -27,24 +28,26 @@
using namespace Ogre;
FlexBody::FlexBody(SceneManager *manager, node_t *nds, int numnds, char*
meshname, char* uname, int ref, int nx, int ny, Vector3 offset, Quaternion rot,
char* setdef, MaterialFunctionMapper *mfm, Skin *usedSkin, bool enableShadows,
MaterialReplacer *mr) :
- flexBodyCameraMode(-2)
+ cameramode(-2)
, coffset(offset)
, cref(ref)
+ , cx(nx)
+ , cy(ny)
, enabled(true)
, faulty(false)
, freenodeset(0)
- , haveblend(true)
- , havetangents(false)
+ , hasblend(true)
+ , hastangents(false)
, mr(mr)
, nodes(nds)
, numnodes(numnds)
, snode(0)
{
nodes[cref].iIsSkin=true;
- cx=nx; nodes[cx].iIsSkin=true;
- cy=ny; nodes[cy].iIsSkin=true;
+ nodes[cx].iIsSkin=true;
+ nodes[cy].iIsSkin=true;
-
haveshadows=(manager->getShadowTechnique()==SHADOWTYPE_STENCIL_MODULATIVE ||
manager->getShadowTechnique()==SHADOWTYPE_STENCIL_ADDITIVE);
+
hasshadows=(manager->getShadowTechnique()==SHADOWTYPE_STENCIL_MODULATIVE ||
manager->getShadowTechnique()==SHADOWTYPE_STENCIL_ADDITIVE);
//parsing set definition
char* pos=setdef;
@@ -151,11 +154,11 @@
msh=ent->getMesh();
//determine if we have texture coordinates everywhere
- havetexture=true;
- if (msh->sharedVertexData &&
msh->sharedVertexData->vertexDeclaration->findElementBySemantic(VES_TEXTURE_COORDINATES)==0)
havetexture=false;
- for (int i=0; i<msh->getNumSubMeshes(); i++) if
(!msh->getSubMesh(i)->useSharedVertices &&
msh->getSubMesh(i)->vertexData->vertexDeclaration->findElementBySemantic(VES_TEXTURE_COORDINATES)==0)
havetexture=false;
- if (!havetexture) LOG("FLEXBODY Warning: at least one part of this mesh
does not have texture coordinates, switching off texturing!");
- if (!havetexture) {havetangents=false;haveblend=false;}; //we can't do
this
+ hastexture=true;
+ if (msh->sharedVertexData &&
msh->sharedVertexData->vertexDeclaration->findElementBySemantic(VES_TEXTURE_COORDINATES)==0)
hastexture=false;
+ for (int i=0; i<msh->getNumSubMeshes(); i++) if
(!msh->getSubMesh(i)->useSharedVertices &&
msh->getSubMesh(i)->vertexData->vertexDeclaration->findElementBySemantic(VES_TEXTURE_COORDINATES)==0)
hastexture=false;
+ if (!hastexture) LOG("FLEXBODY Warning: at least one part of this mesh
does not have texture coordinates, switching off texturing!");
+ if (!hastexture) {hastangents=false;hasblend=false;}; //we can't do this
//detect the anomalous case where a mesh is exported without normal
vectors
bool havenormal=true;
@@ -167,9 +170,9 @@
VertexDeclaration*
optimalVD=HardwareBufferManager::getSingleton().createVertexDeclaration();
optimalVD->addElement(0, 0, VET_FLOAT3, VES_POSITION);
optimalVD->addElement(1, 0, VET_FLOAT3, VES_NORMAL);
- if (haveblend) optimalVD->addElement(2, 0, VET_COLOUR_ARGB,
VES_DIFFUSE);
- if (havetexture) optimalVD->addElement(3, 0, VET_FLOAT2,
VES_TEXTURE_COORDINATES);
- if (havetangents) optimalVD->addElement(4, 0, VET_FLOAT3, VES_TANGENT);
+ if (hasblend) optimalVD->addElement(2, 0, VET_COLOUR_ARGB, VES_DIFFUSE);
+ if (hastexture) optimalVD->addElement(3, 0, VET_FLOAT2,
VES_TEXTURE_COORDINATES);
+ if (hastangents) optimalVD->addElement(4, 0, VET_FLOAT3, VES_TANGENT);
optimalVD->sort();
optimalVD->closeGapsInSource();
@@ -181,7 +184,7 @@
//printMeshInfo(ent->getMesh().getPointer());
//adding color buffers, well get the reference later
- if (haveblend)
+ if (hasblend)
{
if (msh->sharedVertexData)
{
@@ -212,7 +215,7 @@
}
//tangents for envmapping
- if (havetangents)
+ if (hastangents)
{
LOG("FLEXBODY preparing for tangents");
unsigned short srcTex, destTex;
@@ -285,7 +288,7 @@
dstpos=(Vector3*)malloc(sizeof(Vector3)*vertex_count);
srcnormals=(Vector3*)malloc(sizeof(Vector3)*vertex_count);
dstnormals=(Vector3*)malloc(sizeof(Vector3)*vertex_count);
- if (haveblend)
+ if (hasblend)
{
srccolors=(ARGB*)malloc(sizeof(ARGB)*vertex_count);
for (int i=0; i<(int)vertex_count; i++) srccolors[i]=0x00000000;
@@ -307,7 +310,7 @@
sharednbuf->readData(0,
msh->sharedVertexData->vertexCount*sizeof(Vector3), (void*)npt);
npt+=msh->sharedVertexData->vertexCount;
//colors
- if (haveblend)
+ if (hasblend)
{
source=msh->sharedVertexData->vertexDeclaration->findElementBySemantic(VES_DIFFUSE)->getSource();
sharedcbuf=msh->sharedVertexData->vertexBufferBinding->getBuffer(source);
@@ -329,7 +332,7 @@
subnbufs[cursubmesh]->readData(0,
msh->getSubMesh(i)->vertexData->vertexCount*sizeof(Vector3), (void*)npt);
npt+=msh->getSubMesh(i)->vertexData->vertexCount;
//colors
- if (haveblend)
+ if (hasblend)
{
source=msh->getSubMesh(i)->vertexData->vertexDeclaration->findElementBySemantic(VES_DIFFUSE)->getSource();
subcbufs[cursubmesh]=msh->getSubMesh(i)->vertexData->vertexBufferBinding->getBuffer(source);
@@ -399,7 +402,8 @@
if (minnode==-1) LOG("FLEXBODY ERROR on mesh
"+String(meshname)+": VY node not found");
locs[i].ny=minnode;
nodes[minnode].iIsSkin=true;
-/*
+
+#if 0
//search the final close, orthogonal node as the Z vector
mindist=100000.0;
minnode=-1;
@@ -432,7 +436,8 @@
locs[i].nz=locs[i].ny;
locs[i].ny=t;
}
-*/
+#endif // 0
+
Vector3
vz=(nodes[locs[i].nx].smoothpos-nodes[locs[i].ref].smoothpos).crossProduct(nodes[locs[i].ny].smoothpos-nodes[locs[i].ref].smoothpos);
vz.normalise();
Matrix3 mat;
@@ -449,10 +454,10 @@
}
//shadow
- if (haveshadows)
+ if (hasshadows)
{
LOG("FLEXBODY preparing for shadow volume");
- msh->prepareForShadowVolume(); //we do this always so we have
only one datastructure format to manage
+ msh->prepareForShadowVolume(); // we do this always so we have
only one data structure format to manage
msh->buildEdgeList();
}
@@ -503,7 +508,6 @@
}
#endif //0
-
for (int i=0; i<(int)vertex_count; i++)
{
Vector3
vz=(nodes[locs[i].nx].smoothpos-nodes[locs[i].ref].smoothpos).crossProduct(nodes[locs[i].ny].smoothpos-nodes[locs[i].ref].smoothpos);
@@ -519,9 +523,7 @@
srcnormals[i]=mat*(orientation*srcnormals[i]);
}
-
LOG("FLEXBODY ready");
-
}
void FlexBody::setEnabled(bool e)
@@ -603,7 +605,7 @@
{
if(faulty) return Vector3::ZERO;
if(!enabled) return Vector3::ZERO;
- if (haveblend) updateBlend();
+ if (hasblend) updateBlend();
//compute the local center
Vector3 normal;
@@ -661,7 +663,7 @@
void FlexBody::reset()
{
if(faulty) return;
- if (haveblend)
+ if (hasblend)
{
for (int i=0; i<(int)vertex_count; i++) srccolors[i]=0x00000000;
writeBlend();
@@ -671,7 +673,7 @@
void FlexBody::writeBlend()
{
if(!enabled) return;
- if (!haveblend) return;
+ if (!hasblend) return;
ARGB *cpt=srccolors;
if (hasshared)
{
Modified: trunk/source/main/physics/flex/FlexBody.h
===================================================================
--- trunk/source/main/physics/flex/FlexBody.h 2012-05-09 00:02:48 UTC (rev
2529)
+++ trunk/source/main/physics/flex/FlexBody.h 2012-05-09 00:09:21 UTC (rev
2530)
@@ -81,10 +81,10 @@
bool enabled;
bool hasshared;
- bool haveshadows;
- bool havetangents;
- bool havetexture;
- bool haveblend;
+ bool hasshadows;
+ bool hastangents;
+ bool hastexture;
+ bool hasblend;
bool faulty;
Ogre::MeshPtr msh;
@@ -102,7 +102,7 @@
void writeBlend();
Ogre::SceneNode *getSceneNode() { return snode; };
- int flexBodyCameraMode;
+ int cameramode;
void setEnabled(bool e);
};
Modified: trunk/source/main/physics/input_output/SerializedRig.cpp
===================================================================
--- trunk/source/main/physics/input_output/SerializedRig.cpp 2012-05-09
00:02:48 UTC (rev 2529)
+++ trunk/source/main/physics/input_output/SerializedRig.cpp 2012-05-09
00:09:21 UTC (rev 2530)
@@ -30,16 +30,20 @@
#include "Console.h"
#include "Differentials.h"
#include "FlexAirfoil.h"
+#include "FlexBody.h"
#include "FlexMesh.h"
#include "FlexMeshWheel.h"
#include "FlexObj.h"
#include "InputEngine.h"
#include "JSON.h"
+#include "MaterialReplacer.h"
#include "MeshObject.h"
#include "RoRFrameListener.h"
#include "RoRVersion.h"
#include "ScopeLog.h"
#include "screwprop.h"
+#include "Settings.h"
+#include "skin.h"
#include "SlideNode.h"
#include "SoundScriptManager.h"
#include "TorqueCurve.h"
@@ -48,9 +52,6 @@
#include "utils.h"
#include "vidcam.h"
-// TODO: Not really needed for truck loading, or used very rarely
-#include "FlexBody.h"
-
using namespace Ogre;
// important: keep this in sync with TRUCK_SECTIONS enum as we iterate through
this until we reach BTS_END
@@ -924,7 +925,7 @@
// always use the last flexbody
FlexBody *flex = flexbodies[free_flexbody-1];
- if(flex) flex->flexBodyCameraMode = pmode;
+ if(flex) flex->cameramode = pmode;
continue;
}
Modified: trunk/source/main/utils/MeshObject.cpp
===================================================================
--- trunk/source/main/utils/MeshObject.cpp 2012-05-09 00:02:48 UTC (rev
2529)
+++ trunk/source/main/utils/MeshObject.cpp 2012-05-09 00:09:21 UTC (rev
2530)
@@ -20,7 +20,12 @@
// created by Thomas Fischer thomas{AT}thomasfischer{DOT}biz, 1st of May 2010
#include "MeshObject.h"
+
+#include "materialFunctionMapper.h"
+#include "MaterialReplacer.h"
#include "Ogre.h"
+#include "Settings.h"
+#include "skin.h"
using namespace Ogre;
@@ -111,9 +116,6 @@
sceneNode->setVisible(b);
}
-
-
-
void MeshObject::postProcess()
{
loaded=true;
Modified: trunk/source/main/utils/MeshObject.h
===================================================================
--- trunk/source/main/utils/MeshObject.h 2012-05-09 00:02:48 UTC (rev
2529)
+++ trunk/source/main/utils/MeshObject.h 2012-05-09 00:09:21 UTC (rev
2530)
@@ -20,17 +20,12 @@
// created by Thomas Fischer thomas{AT}thomasfischer{DOT}biz, 1st of May 2010
-#ifndef MESHOBJECT_H__
-#define MESHOBJECT_H__
+#ifndef __MeshObject_H_
+#define __MeshObject_H_
#include "RoRPrerequisites.h"
#include "Ogre.h"
-#include "materialFunctionMapper.h"
-#include "MaterialReplacer.h"
-#include "Settings.h"
-#include "skin.h"
-
class MeshObject : public Ogre::ResourceBackgroundQueue::Listener, public
Ogre::Resource::Listener
{
public:
@@ -78,4 +73,4 @@
void unloadingComplete(Ogre::Resource *r);
};
-#endif //MESHOBJECT_H__
+#endif // __MeshObject_H_
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Rigsofrods-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel