Browse Source

Adding skeleton for physics player controller

Panagiotis Christopoulos Charitos 11 years ago
parent
commit
9dd1082e1f

+ 1 - 6
include/anki/collision/Common.h

@@ -8,7 +8,6 @@
 
 
 #include "anki/collision/Forward.h"
 #include "anki/collision/Forward.h"
 #include "anki/util/Allocator.h"
 #include "anki/util/Allocator.h"
-#include "anki/util/Vector.h"
 
 
 namespace anki {
 namespace anki {
 
 
@@ -17,11 +16,7 @@ namespace anki {
 
 
 /// The type of the collision temporary allocator
 /// The type of the collision temporary allocator
 template<typename T>
 template<typename T>
-using CollisionTempAllocator = StackAllocator<T, false>;
-
-/// A temporary vector
-template<typename T>
-using CollisionTempVector = Vector<T, CollisionTempAllocator<T>>;
+using CollisionTempAllocator = StackAllocator<T>;
 
 
 /// @}
 /// @}
 
 

+ 1 - 0
include/anki/physics/PhysicsObject.h

@@ -23,6 +23,7 @@ public:
 		COLLISION_SHAPE,
 		COLLISION_SHAPE,
 		BODY,
 		BODY,
 		JOINT,
 		JOINT,
+		PLAYER_CONTROLLER,
 		COUNT
 		COUNT
 	};
 	};
 
 

+ 46 - 0
include/anki/physics/PhysicsPlayerController.h

@@ -0,0 +1,46 @@
+// Copyright (C) 2014, Panagiotis Christopoulos Charitos.
+// All rights reserved.
+// Code licensed under the BSD License.
+// http://www.anki3d.org/LICENSE
+
+#ifndef ANKI_PHYSICS_PLAYER_CONTROLLER_H
+#define ANKI_PHYSICS_PLAYER_CONTROLLER_H
+
+#include "anki/physics/PhysicsObject.h"
+
+namespace anki {
+
+/// @addtogroup physics
+/// @{
+
+/// Initializer for PhysicsPlayerController.
+struct PhysicsPlayerControllerInitializer
+{
+	F32 m_mass = 83.0;
+	F32 m_innerRadius = 0.30;
+	F32 m_outerRadius = 0.50;
+	F32 m_height = 1.9;
+	F32 m_stepHeight = 0.5;
+};
+
+/// A player controller that walks the world.
+class PhysicsPlayerController final: public PhysicsObject
+{
+public:
+	using Initializer = PhysicsPlayerControllerInitializer;
+
+	PhysicsPlayerController(PhysicsWorld* world)
+	:	PhysicsObject(Type::PLAYER_CONTROLLER, world)
+	{}
+
+	ANKI_USE_RESULT Error create(PhysicsWorld* world, const Initializer& init);
+
+	void setVelocity(F32 forwardSpeed, F32 strafeSpeed, F32 jumpSpeed, 
+		const Vec3& forwardDir, const Vec3& gravity, F32 dt);
+};
+/// @}
+
+} // end namespace anki
+
+#endif
+

+ 24 - 0
src/physics/PhysicsPlayerController.cpp

@@ -0,0 +1,24 @@
+// Copyright (C) 2014, Panagiotis Christopoulos Charitos.
+// All rights reserved.
+// Code licensed under the BSD License.
+// http://www.anki3d.org/LICENSE
+
+#include "anki/physics/PhysicsPlayerController.h"
+
+namespace anki {
+
+//==============================================================================
+Error PhysicsPlayerController::create(
+	PhysicsWorld* world, const Initializer& init)
+{
+}
+
+//==============================================================================
+void PhysicsPlayerController::setVelocity(
+	F32 forwardSpeed, F32 strafeSpeed, F32 jumpSpeed, 
+	const Vec3& forwardDir, const Vec3& gravity, F32 dt)
+{
+}
+
+} // end namespace anki
+