Просмотр исходного кода

- Scene
- Optimizing Smo (untested)

Panagiotis Christopoulos Charitos 15 лет назад
Родитель
Сommit
5c74cd1564

Разница между файлами не показана из-за своего большого размера
+ 0 - 1
build/debug/Makefile


+ 2 - 2
src/Collision/Sphere.cpp

@@ -15,9 +15,9 @@ Sphere Sphere::getTransformed(const Transform& transform) const
 
 
 //======================================================================================================================
-// getCompoundSphere                                                                                                   =
+// getCompoundShape                                                                                                   =
 //======================================================================================================================
-Sphere Sphere::getCompoundSphere(const Sphere& b) const
+Sphere Sphere::getCompoundShape(const Sphere& b) const
 {
 	const Sphere& a = *this;
 

+ 8 - 4
src/Collision/Sphere.h

@@ -2,7 +2,6 @@
 #define SPHERE_H
 
 #include "CollisionShape.h"
-#include "Properties.h"
 #include "Math.h"
 
 
@@ -24,15 +23,20 @@ class Sphere: public CollisionShape
 
 		/// @name Accessors
 		/// @{
-		GETTER_SETTER(Vec3, center, getCenter, setCenter)
-		GETTER_SETTER_BY_VAL(float, radius, getRadius, setRadius)
+		const Vec3& getCenter() const {return center;}
+		Vec3& getCenter() {return center;}
+		void setCenter(const Vec3& c) {center = c;}
+
+		float getRadius() const {return radius;}
+		float& getRadius() {return radius;}
+		void setRadius(float f) {radius = f;}
 		/// @}
 
 		Sphere getTransformed(const Transform& transform) const;
 
 		/// Get the sphere that includes this sphere and the given. See a drawing in the docs dir for more info about the
 		/// algorithm
-		Sphere getCompoundSphere(const Sphere& b) const;
+		Sphere getCompoundShape(const Sphere& b) const;
 
 		/// @see CollisionShape::testPlane
 		float testPlane(const Plane& plane) const;

+ 3 - 3
src/Math/Mat4.inl.h

@@ -553,9 +553,9 @@ inline Vec4 Mat4::operator*(const Vec4& b) const
 		return v;
 	#else
 		return Vec4(SELF(0, 0) * b.x() + SELF(0, 1) * b.y() + SELF(0, 2) * b.z() + SELF(0, 3) * b.w(),
-	              SELF(1, 0) * b.x() + SELF(1, 1) * b.y() + SELF(1, 2) * b.z() + SELF(1, 3) * b.w(),
-	              SELF(2, 0) * b.x() + SELF(2, 1) * b.y() + SELF(2, 2) * b.z() + SELF(2, 3) * b.w(),
-	              SELF(3, 0) * b.x() + SELF(3, 1) * b.y() + SELF(3, 2) * b.z() + SELF(3, 3) * b.w());
+		            SELF(1, 0) * b.x() + SELF(1, 1) * b.y() + SELF(1, 2) * b.z() + SELF(1, 3) * b.w(),
+		            SELF(2, 0) * b.x() + SELF(2, 1) * b.y() + SELF(2, 2) * b.z() + SELF(2, 3) * b.w(),
+		            SELF(3, 0) * b.x() + SELF(3, 1) * b.y() + SELF(3, 2) * b.z() + SELF(3, 3) * b.w());
 	#endif
 }
 

Разница между файлами не показана из-за своего большого размера
+ 1 - 0
src/Renderer/Smo.cpp


+ 1 - 0
src/Renderer/Smo.h

@@ -32,6 +32,7 @@ class Smo: public RenderingPass
 
 		/// @name Camera shape stuff
 		/// @{
+		static float camPositions[];
 		Vbo cameraPositionsVbo; ///< A camera shape
 		Vbo cameraVertIndecesVbo; ///< The vertex indeces
 		Vao cameraVao; ///< And another VAO

+ 2 - 2
src/Resources/Model.cpp

@@ -40,14 +40,14 @@ void Model::load(const char* filename)
   		modelPatches.push_back(patch);
   		patch->load(mesh.c_str(), material.c_str(), dpMaterial.c_str());
 
-  		boundingShape = boundingShape.getCompoundSphere(patch->getMesh().getBoundingShape());
+  		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.getCompoundSphere(patch.getMesh().getBoundingShape());
+  		boundingShape = boundingShape.getCompoundShape(patch.getMesh().getBoundingShape());
   	}
 	}
 	catch(std::exception& e)

+ 2 - 0
src/Scene/Camera.h

@@ -3,9 +3,11 @@
 
 #include <boost/array.hpp>
 #include <deque>
+
 #include "Vec.h"
 #include "Collision.h"
 #include "SceneNode.h"
+#include "Properties.h"
 
 
 class RenderableNode;

+ 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(worldTransform);
+	boundingShapeWSpace = model->getBoundingShape().getTransformed(getWorldTransform());
 }

+ 11 - 12
src/Scene/Scene.cpp

@@ -34,7 +34,7 @@ void Scene::registerNode(SceneNode* node)
 {
 	putBackNode(nodes, node);
 	
-	switch(node->type)
+	switch(node->getSceneNodeType())
 	{
 		case SceneNode::SNT_LIGHT:
 			putBackNode(lights, static_cast<Light*>(node));
@@ -65,7 +65,7 @@ void Scene::unregisterNode(SceneNode* node)
 {
 	eraseNode(nodes, node);
 	
-	switch(node->type)
+	switch(node->getSceneNodeType())
 	{
 		case SceneNode::SNT_LIGHT:
 			eraseNode(lights, static_cast<Light*>(node));
@@ -118,28 +118,27 @@ void Scene::updateAllWorldStuff()
 
 
 	// put the roots
-	for(uint i=0; i<nodes.size(); i++)
+	BOOST_FOREACH(SceneNode* node, nodes)
 	{
-		if(nodes[i]->getObjParent() == NULL)
+		if(node->getParent() == NULL)
 		{
-			queue[tail++] = nodes[i]; // queue push
+			queue[tail++] = node; // queue push
 		}
 	}
 
 	// loop
 	while(head != tail) // while queue not empty
 	{
-		SceneNode* obj = queue[head++]; // queue pop
+		SceneNode* pnode = queue[head++]; // queue pop
 
-		obj->updateWorldTransform();
-		obj->frameUpdate();
-		obj->moveUpdate();
+		pnode->updateWorldTransform();
+		pnode->frameUpdate();
+		pnode->moveUpdate();
 		++num;
 
-		Object::Container::iterator it = obj->getObjChildren().begin();
-		for(; it != obj->getObjChildren().end(); it++)
+		BOOST_FOREACH(Object* obj, pnode->getChildren())
 		{
-			SceneNode* node = static_cast<SceneNode*>(*it);
+			SceneNode* node = static_cast<SceneNode*>(obj);
 			queue[tail++] = node;
 		}
 	}

+ 10 - 7
src/Scene/SceneNode.h

@@ -12,10 +12,8 @@ class Controller;
 
 
 /// The backbone of scene. It is also an Object for memory management reasons
-class SceneNode: private Object
+class SceneNode: public Object
 {
-	friend class Scene;
-
 	public:
 		typedef Obb VisibilityCollisionShape;
 
@@ -46,6 +44,11 @@ class SceneNode: private Object
 
 		SceneNodeType getSceneNodeType() const {return type;}
 
+		const Object* getParent() const {return getObjParent();}
+		Object* getParent() {return getObjParent();}
+		const Object::Container& getChildren() const {return getObjChildren();}
+		Object::Container& getChildren() {return getObjChildren();}
+
 		bool isVisible() const {return visible;}
 		void setVisible(bool v) {visible = v;}
 		/// @}
@@ -72,11 +75,13 @@ class SceneNode: private Object
 		void moveLocalZ(float distance);
 		/// @}
 
-	protected:
+		/// This update happens only when the object gets moved. Called only by the Scene
+		void updateWorldTransform();
+
+	private:
 		Transform localTransform; ///< The transformation in local space
 		Transform worldTransform; ///< The transformation in world space (local combined with parent's transformation)
 
-	private:
 		SceneNodeType type;
 		bool compoundFlag; ///< This means that the children will inherit the world transform of this node
 
@@ -85,8 +90,6 @@ class SceneNode: private Object
 		bool visible; ///< Visible by any camera
 		bool moved;
 		/// @}
-
-		void updateWorldTransform(); ///< This update happens only when the object gets moved
 };
 
 

+ 1 - 1
src/Scene/SkinNode.cpp

@@ -24,5 +24,5 @@ void SkinNode::init(const char* filename)
 void SkinNode::moveUpdate()
 {
 	boundingShapeWSpace.set(tails);
-	boundingShapeWSpace = boundingShapeWSpace.getTransformed(worldTransform);
+	boundingShapeWSpace = boundingShapeWSpace.getTransformed(getWorldTransform());
 }

Некоторые файлы не были показаны из-за большого количества измененных файлов