Browse Source

python additions

Panagiotis Christopoulos Charitos 14 years ago
parent
commit
9e37ad81bc

File diff suppressed because it is too large
+ 1 - 2
build/debug/Makefile


+ 1 - 1
build/debug/gen.cfg.py

@@ -9,6 +9,6 @@ executableName = "anki"
 
 compiler = "g++"
 
-compilerFlags = "-DDEBUG_ENABLED=1 -DPLATFORM_LINUX -DMATH_INTEL_SIMD -DREVISION=\\\"`svnversion -c ../..`\\\" -c -pedantic-errors -pedantic -ansi -Wall -Wextra -W -Wno-long-long -pipe -g3 -pg -fsingle-precision-constant -msse4"
+compilerFlags = "-DPLATFORM_LINUX -DMATH_INTEL_SIMD -DREVISION=\\\"`svnversion -c ../..`\\\" -c -pedantic-errors -pedantic -ansi -Wall -Wextra -W -Wno-long-long -pipe -g3 -pg -fsingle-precision-constant -msse4"
 
 linkerFlags = "-rdynamic -pg -L../../extern/lib-x86-64-linux -Wl,-Bstatic -lBulletSoftBody -lBulletDynamics -lBulletCollision -lLinearMath -lGLEW -lGLU -Wl,-Bdynamic -lGL -ljpeg -lSDL -lpng -lpython2.6 -lboost_system -lboost_python -lboost_filesystem -lboost_thread"

+ 2 - 2
src/Core/App.cpp

@@ -265,8 +265,8 @@ void App::quit(int code)
 void App::printAppInfo()
 {
 	std::stringstream msg;
-	msg << "App info: debugging ";
-	#if DEBUG_ENABLED == 1
+	msg << "App info: NDEBUG ";
+	#if defined(NDEBUG)
 		msg << "on, ";
 	#else
 		msg << "off, ";

+ 2 - 2
src/Math/MathFuncs.inl.h

@@ -79,13 +79,13 @@ inline float sqrt(float f)
 
 inline float toRad(float degrees)
 {
-	return degrees*(PI/180.0);
+	return degrees * (PI / 180.0);
 }
 
 
 inline float toDegrees(float rad)
 {
-	return rad*(180.0/PI);
+	return rad * (180.0 / PI);
 }
 
 

+ 2 - 0
src/Scripting/BoostPythonInterfaces.cpp

@@ -14,6 +14,8 @@ BOOST_PYTHON_MODULE(Anki)
 	CALL_WRAP(Logger);
 	CALL_WRAP(LoggerSingleton);
 
+	CALL_WRAP(SceneNode);
+	CALL_WRAP(Camera);
 	CALL_WRAP(Scene);
 	CALL_WRAP(SceneSingleton);
 

+ 1 - 1
src/Scripting/Scene/Camera.bpi.cpp

@@ -4,7 +4,7 @@
 
 WRAP(Camera)
 {
-	class_<Camera, noncopyable>("Camera", no_init)
+	class_<Camera, bases<SceneNode>, noncopyable>("Camera", no_init)
 		.def("setFovX", &Camera::setFovX)
 		.def("getFovX", &Camera::getFovX)
 	;

+ 3 - 0
src/Scripting/Scene/Scene.bpi.cpp

@@ -1,9 +1,12 @@
 #include "ScriptingCommon.h"
 #include "Scene.h"
+#include "Camera.h"
 
 
 WRAP(Scene)
 {
+	WRAP_CONTAINER(Scene::Types<Camera>::Container)
+
 	class_<Scene, noncopyable>("Scene", no_init)
 		.def("setAmbientCol", &Scene::setAmbientCol)
 		.def("getAmbientCol", (const Vec3& (Scene::*)() const)(&Scene::getAmbientCol),

+ 10 - 0
src/Scripting/Scene/SceneNode.bpi.cpp

@@ -0,0 +1,10 @@
+#include "ScriptingCommon.h"
+#include "SceneNode.h"
+
+
+WRAP(SceneNode)
+{
+	class_<SceneNode, noncopyable>("SceneNode", no_init)
+		.def("getSceneNodeName", &SceneNode::getSceneNodeName, return_value_policy<reference_existing_object>())
+	;
+}

+ 7 - 0
src/Scripting/ScriptingCommon.h

@@ -1,6 +1,7 @@
 /// @file
 /// This file is included by all the *.bpi.cpp files
 #include <boost/python.hpp>
+#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
 
 
 using namespace boost;
@@ -22,6 +23,12 @@ using namespace boost::python;
 	}
 
 
+#define WRAP_CONTAINER(x) \
+	class_<x >(#x) \
+		.def(vector_indexing_suite<x >()) \
+	;
+
+
 //======================================================================================================================
 // Property for simple types                                                                                           =
 //======================================================================================================================

+ 3 - 3
src/Util/Assert.h

@@ -6,7 +6,9 @@
 
 
 /// Assertion. Print an error and stop the debugger and then abort
-#if DEBUG_ENABLED == 1
+#if defined(NDEBUG)
+	#define ASSERT(x) ((void)0)
+#else
 	#define ASSERT(x) \
 		if(!(x)) { \
 			std::cerr << "(" << __FILE__ << ":" << __LINE__ << " " << __func__ << ") " << \
@@ -14,8 +16,6 @@
 			asm("int $3"); \
 			abort(); \
 		}
-#else
-	#define ASSERT(x) ((void)0)
 #endif
 
 

+ 30 - 45
src/Util/Vec.h

@@ -5,77 +5,62 @@
 #include "Assert.h"
 
 
-/// This is a wrapper of std::std::vector that adds new functionality
-template<typename Type>
-class Vec: public std::vector<Type>
+/// This is a wrapper of std::vector that adds new functionality and assertions in operator[]
+template<typename Type, typename Allocator = std::allocator<Type> >
+class Vec: public std::vector<Type, Allocator>
 {
 	public:
-		Vec();
-		Vec(size_t size);
-		Vec(size_t size, Type val);
-		~Vec() {std::vector<Type>::clear();}
-		Type& operator[](size_t n);
-		const Type& operator[](size_t n) const;
-		size_t getSizeInBytes() const;
-};
-
-
-//======================================================================================================================
-// Constructor []                                                                                                      =
-//======================================================================================================================
-template<typename Type>
-Vec<Type>::Vec():
-	std::vector<Type>()
-{}
+		typedef std::vector<Type, Allocator> Base;
 
+		/// @name Constructors/destructors
+		/// @{
+		Vec(const Allocator& al = Allocator()): Base(al) {}
+		Vec(size_t size, const Type& value = Type(), const Allocator& al = Allocator()): Base(size, value, al) {}
 
-//======================================================================================================================
-// Constructor [size]                                                                                                  =
-//======================================================================================================================
-template<typename Type>
-Vec<Type>::Vec(size_t size):
-	std::vector<Type>(size)
-{}
+		template <typename InputIterator>
+		Vec(InputIterator first, InputIterator last, const Allocator& al = Allocator()): Base(first, last, al) {}
 
+		Vec(const Vec<Type, Allocator>& b): Base(b) {}
+		/// @}
 
-//======================================================================================================================
-// Constructor [size, val]                                                                                             =
-//======================================================================================================================
-template<typename Type>
-Vec<Type>::Vec(size_t size, Type val):
-	std::vector<Type>(size,val)
-{}
+		/// @name Accessors
+		/// @{
+		Type& operator[](size_t n);
+		const Type& operator[](size_t n) const;
+		size_t getSizeInBytes() const;
+		/// @}
+};
 
 
 //======================================================================================================================
 // operator[]                                                                                                          =
 //======================================================================================================================
-template<typename Type>
-Type& Vec<Type>::operator[](size_t n)
+template<typename Type, typename Allocator>
+Type& Vec<Type, Allocator>::operator[](size_t n)
 {
-	ASSERT(n < std::vector<Type>::size());
-	return std::vector<Type>::operator [](n);
+	ASSERT(n < Base::size());
+	return Base::operator [](n);
 }
 
 
 //======================================================================================================================
 // operator[]                                                                                                          =
 //======================================================================================================================
-template<typename Type>
-const Type& Vec<Type>::operator[](size_t n) const
+template<typename Type, typename Allocator>
+const Type& Vec<Type, Allocator>::operator[](size_t n) const
 {
-	ASSERT(n < std::vector<Type>::size());
-	return std::vector<Type>::operator [](n);
+	ASSERT(n < Base::size());
+	return Base::operator [](n);
 }
 
 
 //======================================================================================================================
 // getSizeInBytes                                                                                                      =
 //======================================================================================================================
-template<typename Type>
-size_t Vec<Type>::getSizeInBytes() const
+template<typename Type, typename Allocator>
+size_t Vec<Type, Allocator>::getSizeInBytes() const
 {
-	return std::vector<Type>::size() * sizeof(Type);
+	return Base::size() * sizeof(Type);
 }
 
 

Some files were not shown because too many files changed in this diff