Răsfoiți Sursa

- Changing shape for visibility tests
- Collision d. stuff

Panagiotis Christopoulos Charitos 15 ani în urmă
părinte
comite
0dee79cec5

+ 30 - 30
.cproject

@@ -5,35 +5,35 @@
 	<storageModule moduleId="org.eclipse.cdt.core.settings">
 		<cconfiguration id="cdt.managedbuild.toolchain.gnu.cross.base.1593777304">
 			<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.gnu.cross.base.1593777304" moduleId="org.eclipse.cdt.core.settings" name="Default">
-				<externalSettings/>
-				<extensions>
-					<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
-					<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-					<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
-					<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-					<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-				</extensions>
-			</storageModule>
+<externalSettings/>
+<extensions>
+<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
+<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
+<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+</extensions>
+</storageModule>
 			<storageModule moduleId="cdtBuildSystem" version="4.0.0">
-				<configuration artifactName="anki" buildProperties="" description="" errorParsers="org.eclipse.cdt.core.GmakeErrorParser;org.eclipse.cdt.core.CWDLocator;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser" id="cdt.managedbuild.toolchain.gnu.cross.base.1593777304" name="Default" parent="org.eclipse.cdt.build.core.emptycfg">
-					<folderInfo id="cdt.managedbuild.toolchain.gnu.cross.base.1593777304.1771284297" name="/" resourcePath="">
-						<toolChain errorParsers="" id="cdt.managedbuild.toolchain.gnu.cross.base.652528495" name="cdt.managedbuild.toolchain.gnu.cross.base" resourceTypeBasedDiscovery="false">
-							<option id="cdt.managedbuild.option.gnu.cross.prefix.124248385" name="Prefix" superClass="cdt.managedbuild.option.gnu.cross.prefix"/>
-							<option id="cdt.managedbuild.option.gnu.cross.path.568633506" name="Path" superClass="cdt.managedbuild.option.gnu.cross.path"/>
-							<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.targetPlatform.gnu.cross.2099631" isAbstract="false" osList="all"/>
-							<builder arguments="make -j 4" autoBuildTarget="all" buildPath="${workspace_loc:/anki/build/debug}" cleanBuildTarget="clean" command="nice" enableAutoBuild="false" enableCleanBuild="true" enabledIncrementalBuild="true" errorParsers="org.eclipse.cdt.core.GmakeErrorParser;org.eclipse.cdt.core.CWDLocator" id="cdt.managedbuild.toolchain.gnu.cross.base.1593777304.618553305" incrementalBuildTarget="all" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" parallelizationNumber="1" superClass="org.eclipse.cdt.build.core.settings.default.builder">
-								<outputEntries>
-									<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="outputPath" name="build/debug"/>
-								</outputEntries>
-							</builder>
-						</toolChain>
-					</folderInfo>
-					<sourceEntries>
-						<entry excluding="include|src|Collision" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
-						<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="src"/>
-					</sourceEntries>
-				</configuration>
-			</storageModule>
+<configuration artifactName="anki" buildProperties="" description="" errorParsers="org.eclipse.cdt.core.GmakeErrorParser;org.eclipse.cdt.core.CWDLocator;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser" id="cdt.managedbuild.toolchain.gnu.cross.base.1593777304" name="Default" parent="org.eclipse.cdt.build.core.emptycfg">
+<folderInfo id="cdt.managedbuild.toolchain.gnu.cross.base.1593777304.1771284297" name="/" resourcePath="">
+<toolChain errorParsers="" id="cdt.managedbuild.toolchain.gnu.cross.base.652528495" name="cdt.managedbuild.toolchain.gnu.cross.base" resourceTypeBasedDiscovery="false">
+<option id="cdt.managedbuild.option.gnu.cross.prefix.124248385" name="Prefix"/>
+<option id="cdt.managedbuild.option.gnu.cross.path.568633506" name="Path"/>
+<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.targetPlatform.gnu.cross.2099631" isAbstract="false" osList="all"/>
+<builder arguments="make -j 4" autoBuildTarget="all" buildPath="${workspace_loc:/anki/build/debug}" cleanBuildTarget="clean" command="nice" enableAutoBuild="false" enableCleanBuild="true" enabledIncrementalBuild="true" errorParsers="org.eclipse.cdt.core.GmakeErrorParser;org.eclipse.cdt.core.CWDLocator" id="cdt.managedbuild.toolchain.gnu.cross.base.1593777304.618553305" incrementalBuildTarget="all" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" parallelizationNumber="1" superClass="org.eclipse.cdt.build.core.settings.default.builder">
+<outputEntries>
+<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="outputPath" name="build/debug"/>
+</outputEntries>
+</builder>
+</toolChain>
+</folderInfo>
+<sourceEntries>
+<entry excluding="include|src|Collision" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
+<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="src"/>
+</sourceEntries>
+</configuration>
+</storageModule>
 			<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
 			<storageModule moduleId="org.eclipse.cdt.core.language.mapping"/>
 			<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
@@ -289,6 +289,6 @@
 		</cconfiguration>
 	</storageModule>
 	<storageModule moduleId="cdtBuildSystem" version="4.0.0">
-		<project id="anki.null.323176720" name="anki"/>
-	</storageModule>
+<project id="anki.null.323176720" name="anki"/>
+</storageModule>
 </cproject>

Fișier diff suprimat deoarece este prea mare
+ 0 - 1
build/debug/Makefile


Fișier diff suprimat deoarece este prea mare
+ 0 - 0
build/release/Makefile


+ 7 - 7
src/Collision/Obb.cpp

@@ -95,15 +95,15 @@ void Obb::getExtremePoints(boost::array<Vec3, 8>& points) const
 	Vec3 yAxis = rotation.getColumn(1);
 	Vec3 zAxis = rotation.getColumn(2);
 
-	// Reflection: x1' = x1 - 2n|x1.n|
+	// Reflection: x1' = 2n|x1.n| - x1
 
-	points[RBB] = er - 2.0 * er.dot(xAxis) * xAxis;
-	points[LTB] = er - 2.0 * er.dot(yAxis) * yAxis;
-	points[LBF] = er - 2.0 * er.dot(zAxis) * zAxis;
+	points[RBB] = 2.0 * er.dot(xAxis) * xAxis - er;
+	points[LTB] = 2.0 * er.dot(yAxis) * yAxis - er;
+	points[LBF] = 2.0 * er.dot(zAxis) * zAxis - er;
 
-	points[LTF] = points[LBB] - 2.0 * points[LBB].dot(-xAxis) * -xAxis;
-	points[RTB] = points[LTF] - 2.0 * points[LTF].dot(yAxis) * yAxis;
-	points[RBF] = points[LTF] - 2.0 * points[LTF].dot(zAxis) * zAxis;
+	points[LTF] = 2.0 * points[LBB].dot(-xAxis) * -xAxis - points[LBB];
+	points[RTB] = 2.0 * points[LTF].dot(yAxis) * yAxis - points[LTF];
+	points[RBF] = 2.0 * points[LTF].dot(zAxis) * zAxis - points[LTF];
 
 	BOOST_FOREACH(Vec3& point, points)
 	{

+ 1 - 1
src/Collision/Obb.h

@@ -44,7 +44,7 @@ class Obb: public CollisionShape
 		template<typename Container>
 		void set(const Container& container);
 
-	private:
+	public:
 		/// @name Data
 		/// @{
 		Vec3 center;

+ 49 - 6
src/Renderer/Dbg.cpp

@@ -163,7 +163,7 @@ void Dbg::drawCube(float size)
 	Vec3 maxPos = Vec3(0.5 * size);
 	Vec3 minPos = Vec3(-0.5 * size);
 
-	Vec3 points[] = {
+	boost::array<Vec3, 8> points = {{
 		Vec3(maxPos.x(), maxPos.y(), maxPos.z()),  // right top front
 		Vec3(minPos.x(), maxPos.y(), maxPos.z()),  // left top front
 		Vec3(minPos.x(), minPos.y(), maxPos.z()),  // left bottom front
@@ -172,14 +172,14 @@ void Dbg::drawCube(float size)
 		Vec3(minPos.x(), maxPos.y(), minPos.z()),  // left top back
 		Vec3(minPos.x(), minPos.y(), minPos.z()),  // left bottom back
 		Vec3(maxPos.x(), minPos.y(), minPos.z())   // right bottom back
-	};
+	}};
 
-	const uint indeces[] = {0, 1, 2, 3, 4, 0, 3, 7, 1, 5, 6, 2, 5, 4, 7, 6, 0, 4, 5, 1, 3, 2, 6, 7};
+	boost::array<uint, 24> indeces = {{0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7}};
 
 	begin();
-		for(const uint* p = indeces; p != indeces + sizeof(indeces); p++)
+		BOOST_FOREACH(uint id, indeces)
 		{
-			pushBackVertex(points[*p]);
+			pushBackVertex(points[id]);
 		}
 	end();
 }
@@ -278,7 +278,7 @@ void Dbg::run()
 				if(showVisibilityBoundingShapesFlag)
 				{
 					const RenderableNode& rnode = static_cast<const RenderableNode&>(*node);
-					collisionDbgDrawer.draw(rnode.getBoundingShapeWSpace());
+					collisionDbgDrawer.draw(rnode.getVisibilityShapeWSpace());
 				}
 				break;
 			default:
@@ -286,6 +286,49 @@ void Dbg::run()
 		}
 	}
 
+	///////////////
+	/*setColor(Vec3(1));
+	Obb obb(Vec3(0.0), Mat3::getIdentity(), Vec3(1.0, 2.0, 1.0));
+	Obb obb2(Vec3(0.0), Mat3::getIdentity(), Vec3(1.0, 1.5, 1.0));
+	obb = obb.getTransformed(SceneSingleton::getInstance().getAllNodes()[1]->getWorldTransform());
+	collisionDbgDrawer.draw(obb.getCompoundShape(obb2));
+	collisionDbgDrawer.draw(obb);
+	collisionDbgDrawer.draw(obb2);
+
+	setModelMat(Mat4::getIdentity());
+	boost::array<Vec3, 8> points;
+	obb.getExtremePoints(points);
+	setColor(Vec3(1, 0, 0));
+	begin();
+
+	enum
+	{
+		RTF,
+		LTF,
+		LBF,
+		RBF,
+		RTB,
+		LTB,
+		LBB,
+		RBB
+	};
+
+	Vec3 xAxis = obb.getRotation().getColumn(0);
+	Vec3 yAxis = obb.getRotation().getColumn(1);
+	Vec3 zAxis = obb.getRotation().getColumn(2);
+
+	Vec3 er = obb.getRotation() * obb.getExtend();
+
+	boost::array<uint, 24> indeces = {{0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7}};
+
+	BOOST_FOREACH(uint id, indeces)
+	{
+		pushBackVertex(points[id]);
+	}
+	end();*/
+	///////////////
+
+
 	// Physics
 	/*glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
 	setModelMat(Mat4::getIdentity());

+ 10 - 1
src/Renderer/Drawers/CollisionDbgDrawer.cpp

@@ -32,5 +32,14 @@ void CollisionDbgDrawer::draw(const Obb& obb)
 	tsl = Mat4::combineTransformations(trs, tsl);
 
 	dbg.setModelMat(tsl);
-	dbg.drawCube();
+	dbg.setColor(Vec3(1.0, 1.0, 0.0));
+	dbg.drawCube(2.0);
+
+	/*dbg.setModelMat(Mat4::getIdentity());
+	dbg.begin();
+	dbg.setColor(Vec3(1.0, 1.0, 1.0));
+	dbg.pushBackVertex(obb.getCenter());
+	dbg.setColor(Vec3(1.0, 1.0, 0.0));
+	dbg.pushBackVertex(obb.getCenter() + obb.getRotation() * obb.getExtend());
+	dbg.end();*/
 }

+ 2 - 0
src/Renderer/Ms.cpp

@@ -94,6 +94,8 @@ void Ms::run()
 		glDepthFunc(GL_EQUAL);
 	}
 
+	glClear(GL_COLOR_BUFFER_BIT);
+
 	// render all
 	BOOST_FOREACH(const RenderableNode* node, r.getCamera().getVisibleMsRenderableNodes())
 	{

+ 31 - 28
src/Resources/Helpers/MeshData.cpp

@@ -1,6 +1,8 @@
 #include <fstream>
 #include <cstring>
 #include <boost/lexical_cast.hpp>
+#include <boost/foreach.hpp>
+
 #include "MeshData.h"
 #include "BinaryStream.h"
 
@@ -39,11 +41,11 @@ void MeshData::load(const char* filename)
 		vertCoords.resize(vertsNum);
 
 		// Vert coords
-		for(uint i=0; i<vertCoords.size(); i++)
+		BOOST_FOREACH(Vec3& vertCoord, vertCoords)
 		{
-			for(uint j=0; j<3; j++)
+			for(uint j = 0; j < 3; j++)
 			{
-				vertCoords[i][j] = bs.readFloat();
+				vertCoord[j] = bs.readFloat();
 			}
 		}
 
@@ -52,18 +54,16 @@ void MeshData::load(const char* filename)
 		tris.resize(facesNum);
 
 		// Faces IDs
-		for(uint i=0; i<tris.size(); i++)
+		BOOST_FOREACH(Triangle& tri, tris)
 		{
-			for(uint j=0; j<3; j++)
+			for(uint j = 0; j < 3; j++)
 			{
-				tris[i].vertIds[j] = bs.readUint();
+				tri.vertIds[j] = bs.readUint();
 
 				// a sanity check
-				if(tris[i].vertIds[j] >= vertCoords.size())
+				if(tri.vertIds[j] >= vertCoords.size())
 				{
-					throw EXCEPTION("Vert index out of bounds" + boost::lexical_cast<std::string>(tris[i].vertIds[j]) +
-					                     " (" + boost::lexical_cast<std::string>(i) + ", " +
-					                     boost::lexical_cast<std::string>(j) + ")");
+					throw EXCEPTION("Vert index out of bounds");
 				}
 			}
 		}
@@ -73,11 +73,11 @@ void MeshData::load(const char* filename)
 		texCoords.resize(texCoordsNum);
 
 		// Tex coords
-		for(uint i=0; i<texCoords.size(); i++)
+		BOOST_FOREACH(Vec2& texCoord, texCoords)
 		{
-			for(uint j=0; j<2; j++)
+			for(uint i = 0; i < 2; i++)
 			{
-				texCoords[i][j] = bs.readFloat();
+				texCoord[i] = bs.readFloat();
 			}
 		}
 
@@ -86,7 +86,7 @@ void MeshData::load(const char* filename)
 		vertWeights.resize(vertWeightsNum);
 
 		// Vert weights
-		for(uint i=0; i<vertWeights.size(); i++)
+		BOOST_FOREACH(VertexWeight& vw, vertWeights)
 		{
 			// get the bone connections num
 			uint boneConnections = bs.readUint();
@@ -94,7 +94,7 @@ void MeshData::load(const char* filename)
 			// we treat as error if one vert doesnt have a bone
 			if(boneConnections < 1)
 			{
-				throw EXCEPTION("Vert " + boost::lexical_cast<std::string>(i) + " sould have at least one bone");
+				throw EXCEPTION("Vert sould have at least one bone");
 			}
 
 			// and here is another possible error
@@ -104,18 +104,18 @@ void MeshData::load(const char* filename)
 				throw EXCEPTION("Cannot have more than " +
 				                boost::lexical_cast<std::string>(tmp) + " bones per vertex");
 			}
-			vertWeights[i].bonesNum = boneConnections;
+			vw.bonesNum = boneConnections;
 
 			// for all the weights of the current vertes
-			for(uint j=0; j<vertWeights[i].bonesNum; j++)
+			for(uint i = 0; i < vw.bonesNum; i++)
 			{
 				// read bone id
 				uint boneId = bs.readUint();
-				vertWeights[i].boneIds[j] = boneId;
+				vw.boneIds[i] = boneId;
 
 				// read the weight of that bone
 				float weight = bs.readFloat();
-				vertWeights[i].weights[j] = weight;
+				vw.weights[i] = weight;
 			}
 		} // end for all vert weights
 
@@ -159,7 +159,7 @@ void MeshData::doPostLoad()
 void MeshData::createVertIndeces()
 {
 	vertIndeces.resize(tris.size() * 3);
-	for(uint i=0; i<tris.size(); i++)
+	for(uint i = 0; i < tris.size(); i++)
 	{
 		vertIndeces[i * 3 + 0] = tris[i].vertIds[0];
 		vertIndeces[i * 3 + 1] = tris[i].vertIds[1];
@@ -173,13 +173,17 @@ void MeshData::createVertIndeces()
 //======================================================================================================================
 void MeshData::createFaceNormals()
 {
-	for(uint i=0; i<tris.size(); i++)
+	BOOST_FOREACH(Triangle& tri, tris)
 	{
-		Triangle& tri = tris[i];
 		const Vec3& v0 = vertCoords[tri.vertIds[0]];
 		const Vec3& v1 = vertCoords[tri.vertIds[1]];
 		const Vec3& v2 = vertCoords[tri.vertIds[2]];
 
+		/*std::cout << v0 << std::endl;
+		std::cout << v1 << std::endl;
+		std::cout << v2 << std::endl;
+		std::cout << std::endl;*/
+
 		tri.normal = (v1 - v0).cross(v2 - v0);
 
 		tri.normal.normalize();
@@ -194,22 +198,21 @@ void MeshData::createVertNormals()
 {
 	vertNormals.resize(vertCoords.size());
 
-	for(uint i=0; i<vertCoords.size(); i++)
+	BOOST_FOREACH(Vec3& vertNormal, vertNormals)
 	{
-		vertNormals[i] = Vec3(0.0, 0.0, 0.0);
+		vertNormal = Vec3(0.0, 0.0, 0.0);
 	}
 
-	for(uint i=0; i<tris.size(); i++)
+	BOOST_FOREACH(Triangle& tri, tris)
 	{
-		const Triangle& tri = tris[i];
 		vertNormals[tri.vertIds[0]] += tri.normal;
 		vertNormals[tri.vertIds[1]] += tri.normal;
 		vertNormals[tri.vertIds[2]] += tri.normal;
 	}
 
-	for(uint i=0; i<vertNormals.size(); i++)
+	BOOST_FOREACH(Vec3& vertNormal, vertNormals)
 	{
-		vertNormals[i].normalize();
+		vertNormal.normalize();
 	}
 }
 

+ 27 - 14
src/Resources/Helpers/MeshData.h

@@ -2,10 +2,10 @@
 #define MESH_DATA_H
 
 #include <string>
+#include <boost/array.hpp>
 #include "Math.h"
 #include "StdTypes.h"
 #include "Vec.h"
-#include "Properties.h"
 
 
 /// Mesh data. This class loads the mesh file and the Mesh class loads it to the GPU
@@ -32,12 +32,13 @@ class MeshData
 		class VertexWeight
 		{
 			public:
-				static const uint MAX_BONES_PER_VERT = 4; ///< Dont change or change the skinning code in shader
+				/// Dont change this or prepare to change the skinning code in shader
+				static const uint MAX_BONES_PER_VERT = 4;
 
 				/// @todo change the vals to uint when change drivers
 				float bonesNum;
-				float boneIds[MAX_BONES_PER_VERT];
-				float weights[MAX_BONES_PER_VERT];
+				boost::array<float, MAX_BONES_PER_VERT> boneIds;
+				boost::array<float, MAX_BONES_PER_VERT> weights;
 		};
 
 		/// Triangle
@@ -48,20 +49,32 @@ class MeshData
 				Vec3 normal;
 		};
 
-
-	PROPERTY_R(Vec<Vec3>, vertCoords, getVertCoords) ///< Loaded from file
-	PROPERTY_R(Vec<Vec3>, vertNormals, getVertNormals) ///< Generated
-	PROPERTY_R(Vec<Vec4>, vertTangents, getVertTangents) ///< Generated
-	PROPERTY_R(Vec<Vec2>, texCoords, getTexCoords) ///< Optional. One for every vert so we can use vertex arrays & VBOs
-	PROPERTY_R(Vec<VertexWeight>, vertWeights, getVertWeights) ///< Optional
-	PROPERTY_R(Vec<Triangle>, tris, getTris) ///< Required
-	PROPERTY_R(Vec<ushort>, vertIndeces, getVertIndeces) ///< Generated. Used for vertex arrays & VBOs
-
-	public:
 		MeshData(const char* filename) {load(filename);}
 		~MeshData() {}
 
+		/// @name Accessors
+		/// @{
+		const Vec<Vec3>& getVertCoords() const {return vertCoords;}
+		const Vec<Vec3>& getVertNormals() const {return vertNormals;}
+		const Vec<Vec4>& getVertTangents() const {return vertTangents;}
+		const Vec<Vec2>& getTexCoords() const {return texCoords;}
+		const Vec<VertexWeight>& getVertWeights() const {return vertWeights;}
+		const Vec<Triangle>& getTris() const {return tris;}
+		const Vec<ushort>& getVertIndeces() const {return vertIndeces;}
+		/// @}
+
 	private:
+		/// @name Data
+		/// @{
+		Vec<Vec3> vertCoords; ///< Loaded from file
+		Vec<Vec3> vertNormals; ///< Generated
+		Vec<Vec4> vertTangents; ///< Generated
+		Vec<Vec2> texCoords; ///< Optional. One for every vert so we can use vertex arrays & VBOs
+		Vec<VertexWeight> vertWeights; ///< Optional
+		Vec<Triangle> tris; ///< Required
+		Vec<ushort> vertIndeces; ///< Generated. Used for vertex arrays & VBOs
+		/// @}
+
 		/// Load the mesh data from a binary file
 		/// @exception Exception
 		void load(const char* filename);

+ 1 - 1
src/Resources/Mesh.cpp

@@ -28,7 +28,7 @@ void Mesh::load(const char* filename)
 
 		createVbos(meshData);
 
-		boundingShape.set(meshData.getVertCoords());
+		visibilityShape.set(meshData.getVertCoords());
 	}
 	catch(std::exception& e)
 	{

+ 3 - 3
src/Resources/Mesh.h

@@ -5,7 +5,7 @@
 #include "Math.h"
 #include "RsrcPtr.h"
 #include "Vbo.h"
-#include "Sphere.h"
+#include "Obb.h"
 
 
 class MeshData;
@@ -37,7 +37,7 @@ class Mesh
 		/// @{
 		const Vbo& getVbo(Vbos id) const {return vbos[id];}
 		uint getVertIdsNum() const {return vertIdsNum;}
-		const Sphere& getBoundingShape() const {return boundingShape;}
+		const Obb& getVisibilityShape() const {return visibilityShape;}
 		/// @}
 
 		/// Implements @ref Resource::load
@@ -53,7 +53,7 @@ class Mesh
 	private:
 		boost::array<Vbo, VBOS_NUM> vbos; ///< The vertex buffer objects
 		uint vertIdsNum; ///< The number of vertex IDs
-		Sphere boundingShape;
+		Obb visibilityShape;
 
 		/// Create the VBOs
 		void createVbos(const MeshData& meshData);

+ 25 - 25
src/Resources/Model.cpp

@@ -19,36 +19,36 @@
 void Model::load(const char* filename)
 {
 	try
-  {
+	{
 		//
 		// Load
 		//
 		using namespace boost::property_tree;
 		ptree pt_;
-  	read_xml(filename, pt_);
-
-  	const ptree& pt = pt_.get_child("model");
-
-  	// modelPatches
-  	BOOST_FOREACH(const ptree::value_type& v, pt.get_child("modelPatches"))
-  	{
-  		const std::string& mesh = v.second.get<std::string>("mesh");
-  		const std::string& material = v.second.get<std::string>("material");
-  		const std::string& dpMaterial = v.second.get<std::string>("dpMaterial");
-
-  		ModelPatch* patch = new ModelPatch();
-  		modelPatches.push_back(patch);
-  		patch->load(mesh.c_str(), material.c_str(), dpMaterial.c_str());
-
-  		boundingShape = boundingShape.getCompoundShape(patch->getMesh().getBoundingShape());
-  	}
-
-  	// Bounding volume
-  	boundingShape = modelPatches[0].getMesh().getBoundingShape();
-  	BOOST_FOREACH(const ModelPatch& patch, boost::make_iterator_range(modelPatches.begin() + 1, modelPatches.end()))
-  	{
-  		boundingShape = boundingShape.getCompoundShape(patch.getMesh().getBoundingShape());
-  	}
+		read_xml(filename, pt_);
+
+		const ptree& pt = pt_.get_child("model");
+
+		// modelPatches
+		BOOST_FOREACH(const ptree::value_type& v, pt.get_child("modelPatches"))
+		{
+			const std::string& mesh = v.second.get<std::string>("mesh");
+			const std::string& material = v.second.get<std::string>("material");
+			const std::string& dpMaterial = v.second.get<std::string>("dpMaterial");
+
+			ModelPatch* patch = new ModelPatch();
+			modelPatches.push_back(patch);
+			patch->load(mesh.c_str(), material.c_str(), dpMaterial.c_str());
+
+			visibilityShape = visibilityShape.getCompoundShape(patch->getMesh().getVisibilityShape());
+		}
+
+		// Bounding volume
+		visibilityShape = modelPatches[0].getMesh().getVisibilityShape();
+		BOOST_FOREACH(const ModelPatch& patch, boost::make_iterator_range(modelPatches.begin() + 1, modelPatches.end()))
+		{
+			visibilityShape = visibilityShape.getCompoundShape(patch.getMesh().getVisibilityShape());
+		}
 	}
 	catch(std::exception& e)
 	{

+ 3 - 3
src/Resources/Model.h

@@ -5,7 +5,7 @@
 #include "RsrcPtr.h"
 #include "Vao.h"
 #include "ModelPatch.h"
-#include "Sphere.h"
+#include "Obb.h"
 
 
 /// Model is an entity that acts as a container for other resources. Models are all the non static objects in a map.
@@ -39,12 +39,12 @@ class Model
 		/// @name Accessors
 		/// @{
 		const boost::ptr_vector<ModelPatch>& getModelPatches() const {return modelPatches;}
-		const Sphere& getBoundingShape() const {return boundingShape;}
+		const Obb& getVisibilityShape() const {return visibilityShape;}
 		/// @}
 
 	private:
 		boost::ptr_vector<ModelPatch> modelPatches; ///< The vector of ModelPatch
-		Sphere boundingShape;
+		Obb visibilityShape;
 };
 
 

+ 1 - 1
src/Scene/ModelNode.cpp

@@ -24,5 +24,5 @@ void ModelNode::init(const char* filename)
 void ModelNode::moveUpdate()
 {
 	// Update bounding shape
-	boundingShapeWSpace = model->getBoundingShape().getTransformed(getWorldTransform());
+	visibilityShapeWSpace = model->getVisibilityShape().getTransformed(getWorldTransform());
 }

+ 3 - 3
src/Scene/ModelNode.h

@@ -7,7 +7,7 @@
 #include "Properties.h"
 #include "ModelPatchNode.h"
 #include "Vec.h"
-#include "Sphere.h"
+#include "Obb.h"
 
 
 class Model;
@@ -23,7 +23,7 @@ class ModelNode: public SceneNode
 		/// @{
 		const Model& getModel() const {return *model;}
 		const Vec<ModelPatchNode*>& getModelPatchNodes() const {return patches;}
-		const Sphere& getBoundingShapeWSpace() const {return boundingShapeWSpace;}
+		const Obb& getVisibilityShapeWSpace() const {return visibilityShapeWSpace;}
 		/// @}
 
 		/// Initialize the node
@@ -43,7 +43,7 @@ class ModelNode: public SceneNode
 	private:
 		RsrcPtr<Model> model;
 		Vec<ModelPatchNode*> patches;
-		Sphere boundingShapeWSpace;
+		Obb visibilityShapeWSpace;
 };
 
 

+ 1 - 1
src/Scene/PatchNode.h

@@ -44,7 +44,7 @@ class PatchNode: public RenderableNode
 
 
 inline PatchNode::PatchNode(const ModelPatch& modelPatch, SceneNode* parent):
-	RenderableNode(modelPatch.getMesh().getBoundingShape(), parent),
+	RenderableNode(modelPatch.getMesh().getVisibilityShape(), parent),
 	rsrc(modelPatch)
 {}
 

+ 3 - 3
src/Scene/RenderableNode.cpp

@@ -4,9 +4,9 @@
 //======================================================================================================================
 // Constructor                                                                                                         =
 //======================================================================================================================
-RenderableNode::RenderableNode(const Sphere& boundingShapeLSpace_, SceneNode* parent):
+RenderableNode::RenderableNode(const Obb& visibilityShapeLSpace_, SceneNode* parent):
 	SceneNode(SNT_RENDERABLE, false, parent),
-	boundingShapeLSpace(boundingShapeLSpace_)
+	visibilityShapeLSpace(visibilityShapeLSpace_)
 {}
 
 
@@ -15,5 +15,5 @@ RenderableNode::RenderableNode(const Sphere& boundingShapeLSpace_, SceneNode* pa
 //======================================================================================================================
 void RenderableNode::moveUpdate()
 {
-	boundingShapeWSpace = boundingShapeLSpace.getTransformed(getWorldTransform());
+	visibilityShapeWSpace = visibilityShapeLSpace.getTransformed(getWorldTransform());
 }

+ 5 - 5
src/Scene/RenderableNode.h

@@ -2,7 +2,7 @@
 #define RENDERABLE_NODE_H
 
 #include "SceneNode.h"
-#include "Sphere.h"
+#include "Obb.h"
 
 
 class Vao;
@@ -13,22 +13,22 @@ class Material;
 class RenderableNode: public SceneNode
 {
 	public:
-		RenderableNode(const Sphere& boundingShapeLSpace, SceneNode* parent);
+		RenderableNode(const Obb& visibilityShapeLSpace, SceneNode* parent);
 
 		virtual const Vao& getCpVao() const = 0; ///< Get color pass VAO
 		virtual const Vao& getDpVao() const = 0; ///< Get depth pass VAO
 		virtual uint getVertIdsNum() const = 0;  ///< Get vert ids number for rendering
 		virtual const Material& getCpMtl() const = 0;  ///< Get color pass material
 		virtual const Material& getDpMtl() const = 0;  ///< Get depth pass material
-		const Sphere& getBoundingShapeWSpace() const {return boundingShapeWSpace;}
+		const Obb& getVisibilityShapeWSpace() const {return visibilityShapeWSpace;}
 
 		/// Update the bounding shape
 		virtual void moveUpdate();
 		void frameUpdate() {}
 
 	private:
-		Sphere boundingShapeLSpace;
-		Sphere boundingShapeWSpace;
+		Obb visibilityShapeLSpace;
+		Obb visibilityShapeWSpace;
 };
 
 

+ 2 - 2
src/Scene/SkinNode.cpp

@@ -23,6 +23,6 @@ void SkinNode::init(const char* filename)
 //======================================================================================================================
 void SkinNode::moveUpdate()
 {
-	boundingShapeWSpace.set(tails);
-	boundingShapeWSpace = boundingShapeWSpace.getTransformed(getWorldTransform());
+	visibilityShapeWSpace.set(tails);
+	visibilityShapeWSpace = visibilityShapeWSpace.getTransformed(getWorldTransform());
 }

+ 2 - 2
src/Scene/SkinNode.h

@@ -35,7 +35,7 @@ class SkinNode: public SceneNode
 
 		const Skin& getSkin() const {return *skin;}
 
-		const Sphere& getBoundingShapeWSpace() const {return boundingShapeWSpace;}
+		const Obb& getVisibilityShapeWSpace() const {return visibilityShapeWSpace;}
 		/// @}
 
 		void init(const char* filename);
@@ -47,7 +47,7 @@ class SkinNode: public SceneNode
 	private:
 		RsrcPtr<Skin> skin; ///< The resource
 		Vec<SkinPatchNode*> patches;
-		Sphere boundingShapeWSpace;
+		Obb visibilityShapeWSpace;
 
 		Vec<Vec3> heads;
 		Vec<Vec3> tails;

+ 1 - 1
src/Scene/VisibilityTester.cpp

@@ -99,7 +99,7 @@ void VisibilityTester::test(Camera& cam)
 template<typename Type>
 bool VisibilityTester::test(const Type& tested, const Camera& cam)
 {
-	return cam.insideFrustum(tested.getBoundingShapeWSpace());
+	return cam.insideFrustum(tested.getVisibilityShapeWSpace());
 }
 
 

Unele fișiere nu au fost afișate deoarece prea multe fișiere au fost modificate în acest diff