Daniele Bartolini vor 11 Jahren
Ursprung
Commit
a2be5630b0
3 geänderte Dateien mit 9 neuen und 6 gelöschten Zeilen
  1. 3 3
      engine/config.h
  2. 5 2
      engine/renderers/debug_line.cpp
  3. 1 1
      engine/renderers/debug_line.h

+ 3 - 3
engine/config.h

@@ -85,9 +85,9 @@
 	#define CE_MAX_CONSOLE_CLIENTS 32
 #endif // CE_MAX
 
-#ifndef CE_MAX_DEBUG_LINES
-	#define CE_MAX_DEBUG_LINES 2 * 1024 // Per DebugLine
-#endif // CE_MAX
+#ifndef CROWN_MAX_DEBUG_LINES
+	#define CROWN_MAX_DEBUG_LINES 32768 // Per DebugLine
+#endif // CROWN_MAX_DEBUG_LINES
 
 #ifndef CROWN_MAX_LUA_VECTOR3
 	#define CROWN_MAX_LUA_VECTOR3 4096

+ 5 - 2
engine/renderers/debug_line.cpp

@@ -132,7 +132,7 @@ DebugLine::DebugLine(bool depth_test)
 
 void DebugLine::add_line(const Vector3& start, const Vector3& end, const Color4& color)
 {
-	if (_num >= CE_MAX_DEBUG_LINES)
+	if (_num >= CROWN_MAX_DEBUG_LINES)
 		 return;
 
 	_lines[_num].p0[0] = start.x;
@@ -208,8 +208,11 @@ void DebugLine::commit()
 	if (!_num)
 		return;
 
+	if (!checkAvailTransientVertexBuffer(_num * 2, debug_line::s_decl))
+		return;
+
 	bgfx::TransientVertexBuffer tvb;
-	bgfx::allocTransientVertexBuffer(&tvb, CE_MAX_DEBUG_LINES * 2, debug_line::s_decl);
+	bgfx::allocTransientVertexBuffer(&tvb, _num * 2, debug_line::s_decl);
 
 	memcpy(tvb.data, _lines, sizeof(Line) * _num);
 

+ 1 - 1
engine/renderers/debug_line.h

@@ -53,7 +53,7 @@ private:
 
 	bool _depth_test;
 	uint32_t _num;
-	Line _lines[CE_MAX_DEBUG_LINES];
+	Line _lines[CROWN_MAX_DEBUG_LINES];
 };
 
 } // namespace crown