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

Binds now uses references instead of pointers

mikymod 12 лет назад
Родитель
Сommit
45446347bc

+ 1 - 0
src/CMakeLists.txt

@@ -235,6 +235,7 @@ set (NETWORK_HEADERS
 set (SCRIPT_SRC
 	script/ScriptSystem.cpp
 	script/binds/MathBinds.cpp
+	script/binds/Vec2Binds.cpp
 	script/binds/Vec3Binds.cpp
 	script/binds/QuatBinds.cpp
 	script/binds/Mat4Binds.cpp

+ 31 - 7
src/script/ScriptSystem.cpp

@@ -52,6 +52,7 @@ int32_t LuaState::execute()
 //-----------------------------------------------------------
 ScriptSystem::ScriptSystem() :
 m_state(),
+m_vec2_count(0),
 m_vec3_count(0),
 m_mat4_count(0),
 m_quat_count(0)
@@ -78,7 +79,20 @@ void ScriptSystem::unload(ScriptResource* resource)
 }
 
 //-----------------------------------------------------------
-Vec3* ScriptSystem::next_vec3(float nx, float ny, float nz)
+Vec2& ScriptSystem::next_vec2(float nx, float ny)
+{
+	uint32_t current = m_vec2_count;
+
+	m_vec2_list[current].x = nx;
+	m_vec2_list[current].y = ny;
+
+	m_vec2_count++;
+
+	return m_vec2_list[current];
+}
+
+//-----------------------------------------------------------
+Vec3& ScriptSystem::next_vec3(float nx, float ny, float nz)
 {
 	uint32_t current = m_vec3_count;
 
@@ -88,11 +102,11 @@ Vec3* ScriptSystem::next_vec3(float nx, float ny, float nz)
 
 	m_vec3_count++;
 
-	return &m_vec3_list[current];
+	return m_vec3_list[current];
 }
 
 //-----------------------------------------------------------
-Mat4* ScriptSystem::next_mat4(float r1c1, float r2c1, float r3c1, float r1c2, float r2c2, float r3c2, float r1c3, float r2c3, float r3c3)
+Mat4& ScriptSystem::next_mat4(float r1c1, float r2c1, float r3c1, float r1c2, float r2c2, float r3c2, float r1c3, float r2c3, float r3c3)
 {
 	uint32_t current = m_mat4_count;
 
@@ -115,22 +129,27 @@ Mat4* ScriptSystem::next_mat4(float r1c1, float r2c1, float r3c1, float r1c2, fl
 
 	m_mat4_count++;
 
-	return &m_mat4_list[current];
+	return m_mat4_list[current];
 }
 
 //-----------------------------------------------------------
-Quat* ScriptSystem::next_quat(float angle, const Vec3* v)
+Quat& ScriptSystem::next_quat(float angle, const Vec3& v)
 {
 	uint32_t current = m_quat_count;
 
 	m_quat_list[current].w = angle;
-	m_quat_list[current].v = *v;
+	m_quat_list[current].v = v;
 
 	m_quat_count++;
 
-	return &m_quat_list[current];
+	return m_quat_list[current];
 }
 
+//-----------------------------------------------------------
+uint32_t ScriptSystem::vec2_used()
+{
+	return m_vec2_count;
+}
 //-----------------------------------------------------------
 uint32_t ScriptSystem::vec3_used()
 {
@@ -149,6 +168,7 @@ uint32_t ScriptSystem::quat_used()
 	return m_quat_count;
 }
 
+//-----------------------------------------------------------
 ScriptSystem g_script;
 
 ScriptSystem* scripter()
@@ -159,6 +179,10 @@ ScriptSystem* scripter()
 //-----------------------------------------------------------
 extern "C"
 {
+uint32_t script_system_vec2_used()
+{
+	return scripter()->vec2_used();
+}
 
 uint32_t script_system_vec3_used()
 {

+ 14 - 6
src/script/ScriptSystem.h

@@ -6,6 +6,7 @@
 #include "String.h"
 #include "ScriptResource.h"
 
+#include "Vec2.h"
 #include "Vec3.h"
 #include "Mat4.h"
 #include "Quat.h"
@@ -51,12 +52,16 @@ public:
 	void						execute();
 								/// Unloads script resource
 	void						unload(ScriptResource* script);
+								/// Returns the first free Vec2
+	Vec2&						next_vec2(float nx, float ny);
 								/// Returns the first free Vec3
-	Vec3*						next_vec3(float nx, float ny, float nz);
+	Vec3&						next_vec3(float nx, float ny, float nz);
 								/// Returns the first free Mat4
-	Mat4*						next_mat4(float r1c1, float r2c1, float r3c1, float r1c2, float r2c2, float r3c2, float r1c3, float r2c3, float r3c3);	
+	Mat4&						next_mat4(float r1c1, float r2c1, float r3c1, float r1c2, float r2c2, float r3c2, float r1c3, float r2c3, float r3c3);	
 								/// Returns the first free Quat
-	Quat*						next_quat(float angle, const Vec3* v);
+	Quat&						next_quat(float angle, const Vec3& v);
+								/// Returns the number of vec2 used in lua environment
+	uint32_t					vec2_used();
 								/// Returns the number of vec3 used in lua environment
 	uint32_t					vec3_used();
 								/// Returns the number of mat4 used in lua environment
@@ -74,12 +79,15 @@ private:
 								ScriptSystem& operator=(const ScriptSystem&);
 
 	LuaState 					m_state;
-
-								/// Vectors used by lua environment
+								/// Vec2 used by lua environment
+	Vec2 						m_vec2_list[MAX_TEMP_OBJECTS];
+								/// Counter which points to the next free Vec2
+	uint32_t					m_vec2_count;
+								/// Vec3 used by lua environment
 	Vec3						m_vec3_list[MAX_TEMP_OBJECTS];
 								/// Counter which points to the next free Vec3
 	uint32_t					m_vec3_count;
-								/// Matrix used by lua environment
+								/// Mat4 used by lua environment
 	Mat4						m_mat4_list[MAX_TEMP_OBJECTS];
 								/// Counter which points to the next free Mat4
 	uint32_t					m_mat4_count;

+ 90 - 87
src/script/binds/Mat4Binds.cpp

@@ -6,218 +6,221 @@ namespace crown
 
 extern "C"
 {
-	Mat4*				mat4(float r1c1, float r2c1, float r3c1, float r1c2, float r2c2, float r3c2, float r1c3, float r2c3, float r3c3);
+	Mat4&				mat4(float r1c1, float r2c1, float r3c1, float r1c2, float r2c2, float r3c2, float r1c3, float r2c3, float r3c3);
 						
-	Mat4*				mat4_add(Mat4* self, Mat4* m);
+	Mat4&				mat4_add(Mat4& self, Mat4& m);
 
-	Mat4*				mat4_subtract(Mat4* self, Mat4* m);
+	Mat4&				mat4_subtract(Mat4& self, Mat4& m);
 
-	Mat4*				mat4_multiply(Mat4* self, Mat4* m);
+	Mat4&				mat4_multiply(Mat4& self, Mat4& m);
 
-	Mat4*				mat4_multiply_by_scalar(Mat4* self, float k);
+	Mat4&				mat4_multiply_by_scalar(Mat4& self, float k);
 
-	Mat4*				mat4_divide_by_scalar(Mat4* self, float k);
+	Mat4&				mat4_divide_by_scalar(Mat4& self, float k);
 
-	void				mat4_build_rotation_x(Mat4* self, float radians);
+	void				mat4_build_rotation_x(Mat4& self, float radians);
 
-	void				mat4_build_rotation_y(Mat4* self, float radians);	
+	void				mat4_build_rotation_y(Mat4& self, float radians);	
 
-	void				mat4_build_rotation_z(Mat4* self, float radians);
+	void				mat4_build_rotation_z(Mat4& self, float radians);
 
-	void				mat4_build_rotation(Mat4* self, const Vec3* n, float radians);
+	void				mat4_build_rotation(Mat4& self, const Vec3& n, float radians);
 
-	void				mat4_build_projection_perspective_rh(Mat4* self, float fovy, float aspect, float near, float far);
+	void				mat4_build_projection_perspective_rh(Mat4& self, float fovy, float aspect, float near, float far);
 
-	void				mat4_build_projection_perspective_lh(Mat4* self, float fovy, float aspect, float near, float far);
+	void				mat4_build_projection_perspective_lh(Mat4& self, float fovy, float aspect, float near, float far);
 
-	void				mat4_build_projection_ortho_rh(Mat4* self, float width, float height, float near, float far);
+	void				mat4_build_projection_ortho_rh(Mat4& self, float width, float height, float near, float far);
 
-	void				mat4_build_projection_ortho_lh(Mat4* self, float width, float height, float near, float far);
+	void				mat4_build_projection_ortho_lh(Mat4& self, float width, float height, float near, float far);
 
-	void				mat4_build_projection_ortho_2d_rh(Mat4* self, float width, float height, float near, float far);
+	void				mat4_build_projection_ortho_2d_rh(Mat4& self, float width, float height, float near, float far);
 
-	void				mat4_build_look_at_rh(Mat4* self, const Vec3* pos, const Vec3* target, const Vec3* up);
+	void				mat4_build_look_at_rh(Mat4& self, const Vec3& pos, const Vec3& target, const Vec3& up);
 
-	void				mat4_build_look_at_lh(Mat4* self, const Vec3* pos, const Vec3* target, const Vec3* up);
+	void				mat4_build_look_at_lh(Mat4& self, const Vec3& pos, const Vec3& target, const Vec3& up);
 
-	void				mat4_build_viewpoint_billboard(Mat4* self, const Vec3* pos, const Vec3* target, const Vec3* up);
+	void				mat4_build_viewpoint_billboard(Mat4& self, const Vec3& pos, const Vec3& target, const Vec3& up);
 
-	void				mat4_build_axis_billboard(Mat4* self, const Vec3* pos, const Vec3* target, const Vec3* axis);
+	void				mat4_build_axis_billboard(Mat4& self, const Vec3& pos, const Vec3& target, const Vec3& axis);
 
-	Mat4*				mat4_transpose(Mat4* self);
+	Mat4&				mat4_transpose(Mat4& self);
 
-	float				mat4_determinant(Mat4* self);
+	float				mat4_determinant(Mat4& self);
 
-	Mat4*				mat4_invert(Mat4* self);
+	Mat4&				mat4_invert(Mat4& self);
 
-	void				mat4_load_identity(Mat4* self);
+	void				mat4_load_identity(Mat4& self);
 
-	Vec3*				mat4_get_translation(Mat4* self);
+	Vec3&				mat4_get_translation(Mat4& self);
 
-	void				mat4_set_translation(Mat4* self, const Vec3* trans);
+	void				mat4_set_translation(Mat4& self, const Vec3& trans);
 
-	Vec3*				mat4_get_scale(Mat4* self);
+	Vec3&				mat4_get_scale(Mat4& self);
 
-	void				mat4_set_scale(Mat4* self, const Vec3* scale);
+	void				mat4_set_scale(Mat4& self, const Vec3& scale);
 
-	void 				mat4_print(Mat4* self);
+	void 				mat4_print(Mat4& self);
 }
 
-Mat4* mat4(float r1c1, float r2c1, float r3c1, float r1c2, float r2c2, float r3c2, float r1c3, float r2c3, float r3c3)
+Mat4& mat4(float r1c1, float r2c1, float r3c1, float r1c2, float r2c2, float r3c2, float r1c3, float r2c3, float r3c3)
 {
 	return scripter()->next_mat4(r1c1, r2c1, r3c1, r1c2, r2c2, r3c2, r1c3, r2c3, r3c3);
 }
 					
-Mat4* mat4_add(Mat4* self, Mat4* m)
+Mat4& mat4_add(Mat4& self, Mat4& m)
 {
-	*self += *m;
+	self += m;
 
 	return self;
 }
 
-Mat4* mat4_subtract(Mat4* self, Mat4* m)
+Mat4& mat4_subtract(Mat4& self, Mat4& m)
 {
-	*self -= *m;
+	self -= m;
 
 	return self;
 }
 
-Mat4* mat4_multiply(Mat4* self, Mat4* m)
+Mat4& mat4_multiply(Mat4& self, Mat4& m)
 {
-	*self *= *m;
+	self *= m;
 
 	return self;
 }	
 
-Mat4* mat4_multiply_by_scalar(Mat4* self, float k)
+Mat4& mat4_multiply_by_scalar(Mat4& self, float k)
 {
-	*self *= k;
+	self *= k;
 
 	return self;
 }
 
-Mat4* mat4_divide_by_scalar(Mat4* self, float k)
+Mat4& mat4_divide_by_scalar(Mat4& self, float k)
 {
-	*self /= k;
+	self /= k;
 
 	return self;
 }
 
-void mat4_build_rotation_x(Mat4* self, float radians)
+void mat4_build_rotation_x(Mat4& self, float radians)
 {
-	self->build_rotation_x(radians);
+	self.build_rotation_x(radians);
 }
 
-void mat4_build_rotation_y(Mat4* self, float radians)
+void mat4_build_rotation_y(Mat4& self, float radians)
 {
-	self->build_rotation_y(radians);
+	self.build_rotation_y(radians);
 }
 
-void mat4_build_rotation_z(Mat4* self, float radians)
+void mat4_build_rotation_z(Mat4& self, float radians)
 {
-	self->build_rotation_z(radians);
+	self.build_rotation_z(radians);
 }
 
-void mat4_build_rotation(Mat4* self, const Vec3* n, float radians)
+void mat4_build_rotation(Mat4& self, const Vec3& n, float radians)
 {
-	self->build_rotation(*n, radians);
+	self.build_rotation(n, radians);
 }
 
-void mat4_build_projection_perspective_rh(Mat4* self, float fovy, float aspect, float near, float far)
+void mat4_build_projection_perspective_rh(Mat4& self, float fovy, float aspect, float near, float far)
 {
-	self->build_projection_perspective_rh(fovy, aspect, near, far);
+	self.build_projection_perspective_rh(fovy, aspect, near, far);
 }
 
-void mat4_build_projection_perspective_lh(Mat4* self, float fovy, float aspect, float near, float far)
+void mat4_build_projection_perspective_lh(Mat4& self, float fovy, float aspect, float near, float far)
 {
-	self->build_projection_perspective_lh(fovy, aspect, near, far);
+	self.build_projection_perspective_lh(fovy, aspect, near, far);
 }
 
-void mat4_build_projection_ortho_rh(Mat4* self, float width, float height, float near, float far)
+void mat4_build_projection_ortho_rh(Mat4& self, float width, float height, float near, float far)
 {
-	self->build_projection_ortho_rh(width, height, near, far);
+	self.build_projection_ortho_rh(width, height, near, far);
 }
 
-void mat4_build_projection_ortho_lh(Mat4* self, float width, float height, float near, float far)
+void mat4_build_projection_ortho_lh(Mat4& self, float width, float height, float near, float far)
 {
-	self->build_projection_ortho_lh(width, height, near, far);
+	self.build_projection_ortho_lh(width, height, near, far);
 }
 
-void mat4_build_projection_ortho_2d_rh(Mat4* self, float width, float height, float near, float far)
+void mat4_build_projection_ortho_2d_rh(Mat4& self, float width, float height, float near, float far)
 {
-	self->build_projection_ortho_2d_rh(width, height, near, far);
+	self.build_projection_ortho_2d_rh(width, height, near, far);
 }
 
-void mat4_build_look_at_rh(Mat4* self, const Vec3* pos, const Vec3* target, const Vec3* up)
+void mat4_build_look_at_rh(Mat4& self, const Vec3& pos, const Vec3& target, const Vec3& up)
 {
-	self->build_look_at_rh(*pos, *target, *up);
+	self.build_look_at_rh(pos, target, up);
 }
 
-void mat4_build_look_at_lh(Mat4* self, const Vec3* pos, const Vec3* target, const Vec3* up)
+void mat4_build_look_at_lh(Mat4& self, const Vec3& pos, const Vec3& target, const Vec3& up)
 {
-	self->build_look_at_lh(*pos, *target, *up);
+	self.build_look_at_lh(pos, target, up);
 }
 
-void mat4_build_viewpoint_billboard(Mat4* self, const Vec3* pos, const Vec3* target, const Vec3* up)
+void mat4_build_viewpoint_billboard(Mat4& self, const Vec3& pos, const Vec3& target, const Vec3& up)
 {
-	self->build_viewpoint_billboard(*pos, *target, *up);
+	self.build_viewpoint_billboard(pos, target, up);
 }
 
-void mat4_build_axis_billboard(Mat4* self, const Vec3* pos, const Vec3* target, const Vec3* axis)
+void mat4_build_axis_billboard(Mat4& self, const Vec3& pos, const Vec3& target, const Vec3& axis)
 {
-	self->build_axis_billboard(*pos, *target, *axis);
+	self.build_axis_billboard(pos, target, axis);
 }
 
-Mat4* mat4_transpose(Mat4* self)
+Mat4& mat4_transpose(Mat4& self)
 {
-	self->transpose();
+	self.transpose();
 
 	return self;
 }
 
-float mat4_determinant(Mat4* self)
+float mat4_determinant(Mat4& self)
 {
-	return self->get_determinant();
+	return self.get_determinant();
 }
 
-Mat4* mat4_invert(Mat4* self)
+Mat4& mat4_invert(Mat4& self)
 {
-	self->invert();
+	self.invert();
 
 	return self;
 }
 
-void mat4_load_identity(Mat4* self)
+void mat4_load_identity(Mat4& self)
 {
-	self->load_identity();
+	self.load_identity();
 }
 
-Vec3* mat4_get_translation(Mat4* self)
-{
-	return new Vec3(self->get_translation());
+Vec3& mat4_get_translation(Mat4& self)
+{	
+	Vec3 tmp = self.get_translation();
+
+	return scripter()->next_vec3(tmp.x, tmp.y, tmp.z);
 }
 
-void mat4_set_translation(Mat4* self, const Vec3* trans)
+void mat4_set_translation(Mat4& self, const Vec3& trans)
 {
-	self->set_translation(*trans);
+	self.set_translation(trans);
 }
 
-Vec3* mat4_get_scale(Mat4* self)
+Vec3& mat4_get_scale(Mat4& self)
 {
-	return new Vec3(self->get_scale());
+	Vec3 tmp = self.get_scale();
+	return scripter()->next_vec3(tmp.x, tmp.y, tmp.z);	
 }
 
-void mat4_set_scale(Mat4* self, const Vec3* scale)
+void mat4_set_scale(Mat4& self, const Vec3& scale)
 {
-	self->set_scale(*scale);
+	self.set_scale(scale);
 }
 
-void mat4_print(Mat4* self)
+void mat4_print(Mat4& self)
 {
-	os::printf("|%.1f|%.1f|%.1f|%.1f|\n", self->m[0], self->m[1], self->m[2], self->m[3]);
-	os::printf("|%.1f|%.1f|%.1f|%.1f|\n", self->m[4], self->m[5], self->m[6], self->m[7]);
-	os::printf("|%.1f|%.1f|%.1f|%.1f|\n", self->m[8], self->m[9], self->m[10], self->m[11]);
-	os::printf("|%.1f|%.1f|%.1f|%.1f|\n", self->m[12], self->m[13], self->m[14], self->m[15]);
+	os::printf("|%.1f|%.1f|%.1f|%.1f|\n", self.m[0], self.m[4], self.m[8], self.m[12]);
+	os::printf("|%.1f|%.1f|%.1f|%.1f|\n", self.m[1], self.m[5], self.m[9], self.m[13]);
+	os::printf("|%.1f|%.1f|%.1f|%.1f|\n", self.m[2], self.m[6], self.m[10], self.m[14]);
+	os::printf("|%.1f|%.1f|%.1f|%.1f|\n", self.m[3], self.m[7], self.m[11], self.m[15]);
 }
 
 

+ 29 - 27
src/script/binds/QuatBinds.cpp

@@ -7,74 +7,76 @@ namespace crown
 
 extern "C"
 {
-	Quat*		quat(float angle, const Vec3* v);
+	Quat&		quat(float angle, const Vec3& v);
 
-	void		quat_negate(Quat* self);
+	void		quat_negate(Quat& self);
 
-	void		quat_load_identity(Quat* self);
+	void		quat_load_identity(Quat& self);
 
-	float		quat_length(Quat* self);	
+	float		quat_length(Quat& self);	
 
-	void		quat_conjugate(Quat* self);
+	void		quat_conjugate(Quat& self);
 
-	Quat*		quat_inverse(Quat* self);			
+	Quat&		quat_inverse(Quat& self);			
 
-	Quat*		quat_cross(Quat* self, const Quat* b);
+	Quat&		quat_cross(Quat& self, const Quat& b);
 
-	Quat*		quat_multiply(Quat* self, const float& k);
+	Quat&		quat_multiply(Quat& self, const float& k);
 
-	Quat*		quat_power(Quat* self, float exp);
+	Quat&		quat_power(Quat& self, float exp);
 }
 
-Quat* quat(float angle, const Vec3* v)
+Quat& quat(float angle, const Vec3& v)
 {
 	return scripter()->next_quat(angle, v);
 }
 
-void quat_negate(Quat* self)
+void quat_negate(Quat& self)
 {
-	self->negate();
+	self.negate();
 }
 
-void quat_load_identity(Quat* self)
+void quat_load_identity(Quat& self)
 {
-	self->load_identity();
+	self.load_identity();
 }
 
-float quat_length(Quat* self)
+float quat_length(Quat& self)
 {
-	return self->length();
+	return self.length();
 }
 
-void quat_conjugate(Quat* self)
+void quat_conjugate(Quat& self)
 {
-	self->conjugate();
+	self.conjugate();
 }
 
-Quat* quat_inverse(Quat* self)
+Quat& quat_inverse(Quat& self)
 {
-	Quat tmp = self->get_inverse();
+	self.conjugate(); 
+	
+	self = self * (1.0f / self.length());
 
-	return new Quat(tmp.w, tmp.v);
+	return self;
 }
 
-Quat* quat_cross(Quat* self, const Quat* b)
+Quat& quat_cross(Quat& self, const Quat& b)
 {
-	*self = *self * (*b);
+	self = self * b;
 
 	return self;
 }
 
-Quat* quat_multiply(Quat* self, const float& k)
+Quat& quat_multiply(Quat& self, const float& k)
 {
-	*self = *self * k;
+	self = self * k;
 
 	return self;
 }
 
-Quat* quat_power(Quat* self, float exp)
+Quat& quat_power(Quat& self, float exp)
 {
-	self->power(exp);
+	self.power(exp);
 
 	return self;
 }

+ 55 - 53
src/script/binds/Vec3Binds.cpp

@@ -8,163 +8,165 @@ namespace crown
 extern "C"
 {
 	/// Constructor
-	Vec3* 				vec3(float nx, float ny, float nz);
+	Vec3&				vec3(float nx, float ny, float nz);
 
-	Vec3*				vec3_add(Vec3* self, const Vec3* v);
+	Vec3&				vec3_add(Vec3& self, const Vec3& v);
 
-	Vec3*				vec3_subtract(Vec3* self, const Vec3* v);
+	Vec3&				vec3_subtract(Vec3& self, const Vec3& v);
 
-	Vec3*				vec3_multiply(Vec3* self, const float s);
+	Vec3&				vec3_multiply(Vec3& self, const float s);
 
-	Vec3*				vec3_divide(Vec3* self, const float s);
+	Vec3&				vec3_divide(Vec3& self, const float s);
 
-	float				vec3_dot(Vec3* self, const Vec3* v);
+	float				vec3_dot(Vec3& self, const Vec3& v);
 
-	Vec3*				vec3_cross(Vec3* self, const Vec3* v);
+	Vec3&				vec3_cross(Vec3& self, const Vec3& v);
 
-	bool				vec3_equal(Vec3* self, const Vec3* other);	
+	bool				vec3_equal(Vec3& self, const Vec3& other);	
 	
-	bool				vec3_lower(Vec3* self, const Vec3* other);
+	bool				vec3_lower(Vec3& self, const Vec3& other);
 
-	bool				vec3_greater(Vec3* self, const Vec3* other);		
+	bool				vec3_greater(Vec3& self, const Vec3& other);		
 
-	float				vec3_length(Vec3* self);	
+	float				vec3_length(Vec3& self);	
 
-	float				vec3_squared_length(Vec3* self);
+	float				vec3_squared_length(Vec3& self);
 
-	void				vec3_set_length(Vec3* self, float len);
+	void				vec3_set_length(Vec3& self, float len);
 
-	Vec3*				vec3_normalize(Vec3* self);
+	Vec3&				vec3_normalize(Vec3& self);
 
-	Vec3*				vec3_negate(Vec3* self);					
+	Vec3&				vec3_negate(Vec3& self);					
 
-	float				vec3_get_distance_to(Vec3* self, const Vec3* a);	
+	float				vec3_get_distance_to(Vec3& self, const Vec3& a);	
 
-	float				vec3_get_angle_between(Vec3* self, const Vec3* a);	
+	float				vec3_get_angle_between(Vec3& self, const Vec3& a);	
 
-	void				vec3_zero(Vec3* self);										
+	void				vec3_zero(Vec3& self);										
 } // extern "C"
 
 //------------------------------------------------------------
-Vec3* vec3(float nx, float ny, float nz)
+Vec3& vec3(float nx, float ny, float nz)
 {
 	return scripter()->next_vec3(nx, ny, nz);
 }
 
 //------------------------------------------------------------
-Vec3* vec3_add(Vec3* self, const Vec3* v)
+Vec3& vec3_add(Vec3& self, const Vec3& v)
 {
-	*self += *v;
+	self += v;
 
 	return self;
 }
 
 //------------------------------------------------------------
-Vec3* vec3_subtract(Vec3* self, const Vec3* v)
+Vec3& vec3_subtract(Vec3& self, const Vec3& v)
 {
-	*self -= *v;
+	self -= v;
 
 	return self;
 }
 
 //------------------------------------------------------------
-Vec3* vec3_multiply(Vec3* self, const float s)
+Vec3& vec3_multiply(Vec3& self, const float s)
 {
-	*self *= s;
+	self *= s;
 
 	return self;
 }
 
 //------------------------------------------------------------
-Vec3* vec3_divide(Vec3* self, const float s)
+Vec3& vec3_divide(Vec3& self, const float s)
 {
-	*self /= s;
+	self /= s;
 
 	return self;
 }
 
 //------------------------------------------------------------
-float vec3_dot(Vec3* self, const Vec3* v)
+float vec3_dot(Vec3& self, const Vec3& v)
 {
-	return self->dot(*v);
+	return self.dot(v);
+
+
 }
 
 //------------------------------------------------------------
-Vec3* vec3_cross(Vec3* self, const Vec3* v)
+Vec3& vec3_cross(Vec3& self, const Vec3& v)
 {
-	self->cross(*v);
+	self.cross(v);
 
 	return self;
 }
 
 //------------------------------------------------------------
-bool vec3_equal(Vec3* self, const Vec3* other)
+bool vec3_equal(Vec3& self, const Vec3& other)
 {
-	return *self == *other;
+	return self == other;
 }
 
 //------------------------------------------------------------
-bool vec3_lower(Vec3* self, const Vec3* other)
+bool vec3_lower(Vec3& self, const Vec3& other)
 {
-	return *self < *other;
+	return self < other;
 }
 
 //------------------------------------------------------------
-bool vec3_greater(Vec3* self, const Vec3* other)
+bool vec3_greater(Vec3& self, const Vec3& other)
 {
-	return *self > *other;
+	return self > other;
 }
 
 //------------------------------------------------------------
-float vec3_length(Vec3* self)
+float vec3_length(Vec3& self)
 {
-	return self->length();
+	return self.length();
 }
 
 //------------------------------------------------------------
-float vec3_squared_length(Vec3* self)
+float vec3_squared_length(Vec3& self)
 {
-	return self->squared_length();
+	return self.squared_length();
 }
 
 //------------------------------------------------------------
-void vec3_set_length(Vec3* self, float len)
+void vec3_set_length(Vec3& self, float len)
 {
-	self->set_length(len);
+	self.set_length(len);
 }
 
 //------------------------------------------------------------
-Vec3* vec3_normalize(Vec3* self)
+Vec3& vec3_normalize(Vec3& self)
 {
-	self->normalize();
+	self.normalize();
 
 	return self;
 }
 
 //------------------------------------------------------------
-Vec3* vec3_negate(Vec3* self)
+Vec3& vec3_negate(Vec3& self)
 {
-	self->negate();
+	self.negate();
 
 	return self;
 }
 
 //------------------------------------------------------------
-float vec3_get_distance_to(Vec3* self, const Vec3* a)
+float vec3_get_distance_to(Vec3& self, const Vec3& a)
 {
-	return self->get_distance_to(*a);
+	return self.get_distance_to(a);
 }
 
 //------------------------------------------------------------
-float vec3_get_angle_between(Vec3* self, const Vec3* a)
+float vec3_get_angle_between(Vec3& self, const Vec3& a)
 {
-	return self->get_angle_between(*a);
+	return self.get_angle_between(a);
 }
 
 //------------------------------------------------------------
-void vec3_zero(Vec3* self)
+void vec3_zero(Vec3& self)
 {
-	self->zero();
+	self.zero();
 }	
 
 } // namespace crown