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

Switch some objects from class to struct

Daniele Bartolini 12 лет назад
Родитель
Сommit
2e5fd127ef

+ 1 - 1
engine/Device.h

@@ -51,7 +51,7 @@ class BundleCompiler;
 class ResourcePackage;
 class ConsoleServer;
 class World;
-class Camera;
+struct Camera;
 class WorldManager;
 
 typedef Id CameraId;

+ 3 - 3
engine/Mesh.h

@@ -33,9 +33,9 @@ namespace crown
 {
 
 struct MeshResource;
-class Vector3;
-class Quaternion;
-class Unit;
+struct Vector3;
+struct Quaternion;
+struct Unit;
 class SceneGraph;
 
 struct Mesh

+ 4 - 4
engine/Sound.h

@@ -32,10 +32,10 @@ OTHER DEALINGS IN THE SOFTWARE.
 namespace crown
 {
 
-class SoundResource;
-class Vector3;
-class Quaternion;
-class Unit;
+struct SoundResource;
+struct Vector3;
+struct Quaternion;
+struct Unit;
 
 struct Sound
 {

+ 1 - 1
engine/Sprite.h

@@ -34,7 +34,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 namespace crown
 {
 
-class SpriteResource;
+struct SpriteResource;
 class SceneGraph;
 class Renderer;
 class RenderWorld;

+ 2 - 2
engine/audio/SoundRenderer.h

@@ -37,8 +37,8 @@ namespace crown
 {
 //-----------------------------------------------------------------------------
 class SoundRendererImpl;
-class SoundResource;
-class Vector3;
+struct SoundResource;
+struct Vector3;
 
 //-----------------------------------------------------------------------------
 typedef Id	SoundBufferId;

+ 1 - 1
engine/core/bv/Frustum.h

@@ -47,7 +47,7 @@ struct FrustumPlane
 	};
 };
 
-class Matrix4x4;
+struct Matrix4x4;
 
 struct Frustum
 {

+ 1 - 1
engine/core/math/Color4.h

@@ -41,7 +41,7 @@ namespace crown
 /// totally transparent while a value of 1.0 means totally opaque.
 /// 
 /// It also offers a set of color name constants compliant with SVG 1.0.
-class Color4
+struct Color4
 {
 public:
 

+ 4 - 4
engine/core/math/Matrix3x3.h

@@ -31,9 +31,9 @@ OTHER DEALINGS IN THE SOFTWARE.
 namespace crown
 {
 
-class Matrix4x4;
-class Quaternion;
-class Vector3;
+struct Matrix4x4;
+struct Quaternion;
+struct Vector3;
 
 /// Column major 3x3 matrix.
 /// 
@@ -55,7 +55,7 @@ class Vector3;
 /// 2 | Xy  Yy  Zy |
 /// 3 [ Xz  Yz  Zz ]
 ///     1   2   3
-class Matrix3x3
+struct Matrix3x3
 {
 
 public:

+ 5 - 5
engine/core/math/Matrix4x4.h

@@ -31,10 +31,10 @@ OTHER DEALINGS IN THE SOFTWARE.
 namespace crown
 {
 
-class Matrix3x3;
-class Quaternion;
-class Vector3;
-class Vector4;
+struct Matrix3x3;
+struct Quaternion;
+struct Vector3;
+struct Vector4;
 
 /// Column-major 4x4 matrix.
 /// 
@@ -58,7 +58,7 @@ class Vector4;
 /// 3 | Xz  Yz  Zz  Tz |
 /// 4 [ 0   0   0   1  ]
 ///     1   2   3   4
-class Matrix4x4
+struct Matrix4x4
 {
 
 public:

+ 1 - 1
engine/core/math/Plane.h

@@ -37,7 +37,7 @@ namespace crown
 /// 
 /// The form is ax + by + cz + d = 0
 /// where: d = -n.Dot(p)
-class Plane
+struct Plane
 {
 public:
 

+ 3 - 3
engine/core/math/Quaternion.h

@@ -32,8 +32,8 @@ OTHER DEALINGS IN THE SOFTWARE.
 namespace crown
 {
 
-class Matrix3x3;
-class Matrix4x4;
+struct Matrix3x3;
+struct Matrix4x4;
 
 /// Quaternion.
 ///
@@ -46,7 +46,7 @@ class Matrix4x4;
 /// p' = (ba)p(ba)^-1 where p is the point and (ba) the concatenation of two successive rotations
 /// In this case, the point p is first rotated by the quaternion a and then by the quaternion b.
 /// The transformation order is reversed.
-class Quaternion
+struct Quaternion
 {
 public:
 

+ 1 - 1
engine/core/math/Random.h

@@ -32,7 +32,7 @@ namespace crown
 ///	Pseudo-random number generator.
 ///
 ///	Uses LCG algorithm: fast and compatible with the standard C rand().
-class Random
+struct Random
 {
 public:
 

+ 1 - 1
engine/core/math/Ray.h

@@ -35,7 +35,7 @@ namespace crown
 /// 3D Ray.
 ///
 /// Defined by the origin and the unit-length direction vector.
-class Ray
+struct Ray
 {
 public:
 

+ 1 - 1
engine/core/math/Triangle.h

@@ -37,7 +37,7 @@ namespace crown
 ///	3D Triangle.
 ///
 /// Used mainly for collision detection.
-class Triangle
+struct Triangle
 {
 public:
 

+ 1 - 1
engine/core/math/Vector2.h

@@ -34,7 +34,7 @@ namespace crown
 {
 
 /// 2D column vector.
-class Vector2
+struct Vector2
 {
 public:
 

+ 1 - 1
engine/core/math/Vector3.h

@@ -35,7 +35,7 @@ namespace crown
 {
 
 /// 3D column vector.
-class Vector3
+struct Vector3
 {
 public:
 

+ 1 - 1
engine/core/math/Vector4.h

@@ -34,7 +34,7 @@ namespace crown
 {
 
 /// 4D column vector.
-class Vector4
+struct Vector4
 {
 public:
 

+ 1 - 1
engine/lua/LuaEnvironment.h

@@ -38,7 +38,7 @@ enum LuaArgumentType
 	ARGUMENT_FLOAT
 };
 
-class LuaResource;
+struct LuaResource;
 
 /// LuaEnvironment is a wrapper of a subset of Lua functions and 
 /// provides utilities for extending Lua

+ 10 - 10
engine/lua/LuaStack.h

@@ -33,18 +33,18 @@ OTHER DEALINGS IN THE SOFTWARE.
 namespace crown
 {
 
-class Vector2;
-class Vector3;
-class Matrix4x4;
-class Quaternion;
-class Unit;
-class Camera;
+struct Vector2;
+struct Vector3;
+struct Matrix4x4;
+struct Quaternion;
+struct Unit;
+struct Camera;
 class World;
-class Mesh;
-class Sprite;
+struct Mesh;
+struct Sprite;
 class PhysicsWorld;
-class Actor;
-class Controller;
+struct Actor;
+struct Controller;
 class ResourcePackage;
 typedef Id SoundInstanceId;
 

+ 3 - 3
engine/physics/Actor.h

@@ -43,9 +43,9 @@ using physx::PxScene;
 namespace crown
 {
 
-class Quaternion;
-class Matrix4x4;
-class Unit;
+struct Quaternion;
+struct Matrix4x4;
+struct Unit;
 class PhysicsGraph;
 class SceneGraph;
 

+ 1 - 1
engine/physics/Controller.h

@@ -36,7 +36,7 @@ namespace crown
 {
 
 struct PhysicsResource;
-class Vector3;
+struct Vector3;
 class SceneGraph;
 
 struct Controller

+ 2 - 2
engine/physics/PhysicsWorld.h

@@ -49,8 +49,8 @@ typedef Id ControllerId;
 
 struct PhysicsResource;
 struct Controller;
-class Vector3;
-class Actor;
+struct Vector3;
+struct Actor;
 class SceneGraph;
 
 //-----------------------------------------------------------------------------

+ 1 - 1
engine/resource/MaterialResource.h

@@ -46,7 +46,7 @@ struct MaterialHeader
 /// A material describes the visual properties of a surface.
 /// It is primarly intended for rendering purposes but can
 /// also be used to drive other types of systems such as sounds or physics.
-class MaterialResource
+struct MaterialResource
 {
 public:
 

+ 1 - 1
engine/resource/MeshResource.h

@@ -70,7 +70,7 @@ struct MeshData
 	IndexData			indices;
 };
 
-class MeshResource
+struct MeshResource
 {
 public:
 

+ 11 - 4
engine/resource/PhysicsResource.cpp

@@ -87,8 +87,7 @@ void parse_actor(JSONElement e, PhysicsActor& actor, List<PhysicsShape>& actor_s
 	actor.node = hash::murmur2_32(node.string_value(), node.size());
 	actor.num_shapes = shapes.size();
 
-	uint32_t num_shapes = shapes.size();
-	for (uint32_t i = 0; i < num_shapes; i++)
+	for (uint32_t i = 0; i < actor.num_shapes; i++)
 	{
 		PhysicsShape ps;
 		parse_shape(shapes[i], ps);
@@ -123,17 +122,25 @@ void compile(Filesystem& fs, const char* resource_path, File* out_file)
 
 	// Read actors
 	List<PhysicsActor> m_actors(default_allocator());
+	List<uint32_t> m_shape_index(default_allocator());
 	List<PhysicsShape> m_shapes(default_allocator());
 	JSONElement actors = root.key_or_nil("actors");
 	if (!actors.is_nil())
 	{
 		for (uint32_t i = 0; i < actors.size(); i++)
 		{
+			if (m_shapes.size() == 0)
+			{
+				m_shape_index.push_back(0);
+			}
+			else
+			{
+				m_shape_index.push_back(m_shapes.size() - 1);
+			}
+			
 			PhysicsActor a;
 			parse_actor(actors[i], a, m_shapes);
 			m_actors.push_back(a);
-
-			Log::d("Actor parsed, name = %.8x, node = %.8x", a.name, a.node);
 		}
 	}
 

+ 2 - 2
engine/world/Camera.h

@@ -44,8 +44,8 @@ struct ProjectionType
 };
 
 typedef Id UnitId;
-class Quaternion;
-class Unit;
+struct Quaternion;
+struct Unit;
 class SceneGraph;
 
 /// Represents the point of view into the game world.

+ 5 - 5
engine/world/Unit.h

@@ -66,11 +66,11 @@ typedef Id ControllerId;
 typedef	Id ComponentId;
 typedef Id MaterialId;
 
-class Camera;
-class Mesh;
-class Sprite;
-class Actor;
-class Controller;
+struct Camera;
+struct Mesh;
+struct Sprite;
+struct Actor;
+struct Controller;
 class World;
 class SceneGraphManager;
 class PhysicsGraphManager;

+ 5 - 5
engine/world/World.h

@@ -74,11 +74,11 @@ struct UnitToSound
 	int32_t node;
 };
 
-class Mesh;
-class Sprite;
-class Actor;
-class Vector3;
-class Quaternion;
+struct Mesh;
+struct Sprite;
+struct Actor;
+struct Vector3;
+struct Quaternion;
 struct PhysicsResource;
 
 class World