| 1265 | } |
| 1266 | |
| 1267 | void DebugDraw::DrawBezier(const Vector3& p1, const Vector3& p2, const Vector3& p3, const Vector3& p4, const Color& color, float duration, bool depthTest) |
| 1268 | { |
| 1269 | const Float3 p1F = p1 - Context->Origin, p2F = p2 - Context->Origin, p3F = p3 - Context->Origin, p4F = p4 - Context->Origin; |
| 1270 | |
| 1271 | // Find amount of segments to use |
| 1272 | const Float3 d1 = p2F - p1F; |
| 1273 | const Float3 d2 = p3F - p2F; |
| 1274 | const Float3 d3 = p4F - p3F; |
| 1275 | const float len = d1.Length() + d2.Length() + d3.Length(); |
| 1276 | const int32 segmentCount = Math::Clamp(Math::CeilToInt(len * 0.05f), 1, 100); |
| 1277 | const float segmentCountInv = 1.0f / (float)segmentCount; |
| 1278 | |
| 1279 | // Draw segmented curve from lines |
| 1280 | PROFILE_MEM(EngineDebug); |
| 1281 | auto& debugDrawData = depthTest ? Context->DebugDrawDepthTest : Context->DebugDrawDefault; |
| 1282 | if (duration > 0) |
| 1283 | { |
| 1284 | DebugLine l = { p1F, Float3::Zero, Color32(color), duration }; |
| 1285 | debugDrawData.DefaultLines.EnsureCapacity(debugDrawData.DefaultLines.Count() + segmentCount + 2); |
| 1286 | for (int32 i = 0; i <= segmentCount; i++) |
| 1287 | { |
| 1288 | const float t = (float)i * segmentCountInv; |
| 1289 | Float3 end; |
| 1290 | AnimationUtils::Bezier(p1F, p2F, p3F, p4F, t, end); |
| 1291 | l.End = end; |
| 1292 | debugDrawData.DefaultLines.Add(l); |
| 1293 | l.Start = l.End; |
| 1294 | } |
| 1295 | } |
| 1296 | else |
| 1297 | { |
| 1298 | Vertex l = { p1F, Color32(color) }; |
| 1299 | debugDrawData.OneFrameLines.EnsureCapacity(debugDrawData.OneFrameLines.Count() + segmentCount * 2 + 4); |
| 1300 | for (int32 i = 0; i <= segmentCount; i++) |
| 1301 | { |
| 1302 | const float t = (float)i * segmentCountInv; |
| 1303 | debugDrawData.OneFrameLines.Add(l); |
| 1304 | Float3 position; |
| 1305 | AnimationUtils::Bezier(p1F, p2F, p3F, p4F, t, position); |
| 1306 | l.Position = position; |
| 1307 | debugDrawData.OneFrameLines.Add(l); |
| 1308 | } |
| 1309 | } |
| 1310 | } |
| 1311 | |
| 1312 | void DebugDraw::DrawWireBox(const BoundingBox& box, const Color& color, float duration, bool depthTest) |
| 1313 | { |