MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / DrawBezier

Method DrawBezier

Source/Engine/Debug/DebugDraw.cpp:1267–1310  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1265}
1266
1267void 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
1312void DebugDraw::DrawWireBox(const BoundingBox& box, const Color& color, float duration, bool depthTest)
1313{

Callers 3

DrawInputBracketsMethod · 0.45
DrawConnectionMethod · 0.45
UpdateMethod · 0.45

Calls 8

ClampFunction · 0.85
BezierFunction · 0.85
CeilToIntFunction · 0.50
Color32Class · 0.50
LengthMethod · 0.45
EnsureCapacityMethod · 0.45
CountMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected