Browse Source

world: cleanup

Daniele Bartolini 10 months ago
parent
commit
117b1d5974
3 changed files with 7 additions and 9 deletions
  1. 4 3
      src/lua/lua_api.cpp
  2. 1 4
      src/world/debug_line.cpp
  3. 2 2
      src/world/debug_line.h

+ 4 - 3
src/lua/lua_api.cpp

@@ -7,6 +7,7 @@
 #include "core/guid.h"
 #include "core/guid.h"
 #include "core/math/color4.inl"
 #include "core/math/color4.inl"
 #include "core/math/constants.h"
 #include "core/math/constants.h"
+#include "core/math/frustum.inl"
 #include "core/math/intersection.h"
 #include "core/math/intersection.h"
 #include "core/math/math.h"
 #include "core/math/math.h"
 #include "core/math/matrix4x4.inl"
 #include "core/math/matrix4x4.inl"
@@ -2780,9 +2781,9 @@ void load_api(LuaEnvironment &env)
 		});
 		});
 	env.add_module_function("DebugLine", "add_frustum", [](lua_State *L) {
 	env.add_module_function("DebugLine", "add_frustum", [](lua_State *L) {
 			LuaStack stack(L);
 			LuaStack stack(L);
-			stack.get_debug_line(1)->add_frustum(stack.get_matrix4x4(2)
-				, stack.get_color4(3)
-				);
+			Frustum f;
+			frustum::from_matrix(f, stack.get_matrix4x4(2));
+			stack.get_debug_line(1)->add_frustum(f, stack.get_color4(3));
 			return 0;
 			return 0;
 		});
 		});
 	env.add_module_function("DebugLine", "reset", [](lua_State *L) {
 	env.add_module_function("DebugLine", "reset", [](lua_State *L) {

+ 1 - 4
src/world/debug_line.cpp

@@ -138,11 +138,8 @@ void DebugLine::add_sphere(const Vector3 &center, const f32 radius, const Color4
 	add_circle(center, radius, VECTOR3_ZAXIS, color, segments);
 	add_circle(center, radius, VECTOR3_ZAXIS, color, segments);
 }
 }
 
 
-void DebugLine::add_frustum(const Matrix4x4 &mvp, const Color4 &color)
+void DebugLine::add_frustum(const Frustum &f, const Color4 &color)
 {
 {
-	Frustum f;
-	frustum::from_matrix(f, mvp);
-
 	Vector3 pt[8];
 	Vector3 pt[8];
 	frustum::vertices(pt, f);
 	frustum::vertices(pt, f);
 
 

+ 2 - 2
src/world/debug_line.h

@@ -64,8 +64,8 @@ struct DebugLine
 	/// the box. @a half_extents describes the size of the box along the axis.
 	/// the box. @a half_extents describes the size of the box along the axis.
 	void add_obb(const Matrix4x4 &tm, const Vector3 &half_extents, const Color4 &color);
 	void add_obb(const Matrix4x4 &tm, const Vector3 &half_extents, const Color4 &color);
 
 
-	/// Adds a frustum defined by @mvp.
-	void add_frustum(const Matrix4x4 &mvp, const Color4 &color);
+	/// Adds the frustum @f.
+	void add_frustum(const Frustum &f, const Color4 &color);
 
 
 	/// Adds the mesh described by (vertices, stride, indices, num).
 	/// Adds the mesh described by (vertices, stride, indices, num).
 	void add_mesh(const Matrix4x4 &tm, const void *vertices, u32 stride, const u16 *indices, u32 num, const Color4 &color);
 	void add_mesh(const Matrix4x4 &tm, const void *vertices, u32 stride, const u16 *indices, u32 num, const Color4 &color);