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

Method Init

Source/Engine/Debug/DebugDraw.cpp:542–650  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

540DebugDrawService DebugDrawServiceInstance;
541
542bool DebugDrawService::Init()
543{
544 PROFILE_MEM(EngineDebug);
545 Context = &GlobalContext;
546
547 // Init wireframe sphere cache
548 SphereCache[0].Init(DEBUG_DRAW_SPHERE_LOD0_RESOLUTION);
549 SphereCache[1].Init(DEBUG_DRAW_SPHERE_LOD1_RESOLUTION);
550 SphereCache[2].Init(DEBUG_DRAW_SPHERE_LOD2_RESOLUTION);
551
552 // Init wireframe circle cache
553 int32 index = 0;
554 float step = TWO_PI / (float)DEBUG_DRAW_CIRCLE_RESOLUTION;
555 for (float a = 0.0f; a < TWO_PI; a += step)
556 {
557 // Calculate sines and cosines
558 float sinA = Math::Sin(a);
559 float cosA = Math::Cos(a);
560 float sinB = Math::Sin(a + step);
561 float cosB = Math::Cos(a + step);
562
563 CircleCache[index++] = Float3(cosA, sinA, 0.0f);
564 CircleCache[index++] = Float3(cosB, sinB, 0.0f);
565 }
566
567 // Init triangle sphere cache
568 {
569 const int32 verticalSegments = DEBUG_DRAW_TRIANGLE_SPHERE_RESOLUTION;
570 const int32 horizontalSegments = DEBUG_DRAW_TRIANGLE_SPHERE_RESOLUTION * 2;
571
572 Array<Float3> vertices;
573 vertices.Resize((verticalSegments + 1) * (horizontalSegments + 1));
574 Array<int> indices;
575 indices.Resize((verticalSegments) * (horizontalSegments + 1) * 6);
576
577 int vertexCount = 0;
578
579 // Generate the first extremity points
580 for (int j = 0; j <= horizontalSegments; j++)
581 {
582 vertices[vertexCount++] = Float3(0, -1, 0);
583 }
584
585 // Create rings of vertices at progressively higher latitudes
586 for (int i = 1; i < verticalSegments; i++)
587 {
588 const float latitude = ((i * PI / verticalSegments) - PI / 2.0f);
589 const float dy = Math::Sin(latitude);
590 const float dxz = Math::Cos(latitude);
591
592 // The first point
593 auto& firstHorizontalVertex = vertices[vertexCount++];
594 firstHorizontalVertex = Float3(0, dy, dxz);
595
596 // Create a single ring of vertices at this latitude
597 for (int j = 1; j < horizontalSegments; j++)
598 {
599 const float longitude = (j * 2.0f * PI / horizontalSegments);

Callers 1

CreateMethod · 0.45

Calls 5

Float3Class · 0.85
SinFunction · 0.50
CosFunction · 0.50
ResizeMethod · 0.45
CountMethod · 0.45

Tested by

no test coverage detected