瀏覽代碼

Merge branch 'master' of github.com:taylor001/crown

Daniele Bartolini 10 年之前
父節點
當前提交
31c5bd75d1
共有 3 個文件被更改,包括 29 次插入3 次删除
  1. 2 0
      src/core/error/error.h
  2. 4 2
      src/core/macros.h
  3. 23 1
      src/lua/lua_math.cpp

+ 2 - 0
src/core/error/error.h

@@ -5,6 +5,8 @@
 
 #pragma once
 
+#include "config.h"
+
 namespace crown
 {
 namespace error

+ 4 - 2
src/core/macros.h

@@ -5,12 +5,14 @@
 
 #pragma once
 
-#ifdef _MSC_VER
+#include "platform.h"
+
+#ifdef CROWN_COMPILER_MSVC
 	#define CE_ALIGNOF(x) __alignof(x)
 	#define CE_EXPORT __declspec(dllexport)
 	#define CE_INLINE __inline
 	#define CE_THREAD __declspec(thread)
-#elif defined __GNUG__
+#elif CROWN_COMPILER_GCC
 	#define CE_ALIGNOF(x) __alignof__(x)
 	#define CE_EXPORT __attribute__ ((visibility("default")))
 	#define CE_INLINE inline

+ 23 - 1
src/lua/lua_math.cpp

@@ -16,6 +16,26 @@
 namespace crown
 {
 
+static int math_ray_plane_intersection(lua_State* L)
+{
+	LuaStack stack(L);
+	Plane p;
+	p.n = stack.get_vector3(3);
+	p.d = stack.get_float(4);
+	stack.push_float(ray_plane_intersection(stack.get_vector3(1), stack.get_vector3(2), p));
+	return 1;
+}
+
+static int math_ray_sphere_intersection(lua_State* L)
+{
+	LuaStack stack(L);
+	Sphere s;
+	s.c = stack.get_vector3(3);
+	s.r = stack.get_float(4);
+	stack.push_float(ray_sphere_intersection(stack.get_vector3(1), stack.get_vector3(2), s));
+	return 1;
+}
+
 static int math_ray_obb_intersection(lua_State* L)
 {
 	LuaStack stack(L);
@@ -843,7 +863,9 @@ static int lightuserdata_newindex(lua_State* L)
 
 void load_math(LuaEnvironment& env)
 {
-	env.load_module_function("Math", "ray_obb_intersection", math_ray_obb_intersection);
+	env.load_module_function("Math", "ray_plane_intersection",  math_ray_plane_intersection);
+	env.load_module_function("Math", "ray_sphere_intersection", math_ray_sphere_intersection);
+	env.load_module_function("Math", "ray_obb_intersection",    math_ray_obb_intersection);
 
 	env.load_module_function("Vector3", "new",            vector3_new);
 	env.load_module_function("Vector3", "x",              vector3_x);