MCPcopy Create free account
hub / github.com/TombEngine/TombEngine / CollectStatics

Method CollectStatics

TombEngine/Renderer/RendererFrame.cpp:545–619  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

543 }
544
545 void Renderer::CollectStatics(short roomNumber, RenderView& renderView)
546 {
547 if (_rooms.size() <= roomNumber)
548 return;
549
550 auto& rendererRoom = _rooms[roomNumber];
551 auto& nativeRoom = g_Level.Rooms[rendererRoom.RoomNumber];
552
553 if (nativeRoom.mesh.empty())
554 return;
555
556 bool isRoomReflected = IsRoomReflected(renderView, roomNumber);
557
558 for (int i = 0; i < rendererRoom.Statics.size(); i++)
559 {
560 auto& rendererStatic = rendererRoom.Statics[i];
561 auto& nativeStatic = nativeRoom.mesh[i];
562
563 if (nativeStatic.Dirty || _invalidateCache)
564 {
565 rendererStatic.ObjectNumber = nativeStatic.Slot;
566 rendererStatic.Color = nativeStatic.Color;
567 rendererStatic.OriginalSphere = Statics[rendererStatic.ObjectNumber].visibilityBox.ToLocalBoundingSphere();
568 rendererStatic.Pose = nativeStatic.Pose;
569 rendererStatic.Update(GetInterpolationFactor());
570
571 nativeStatic.Dirty = (rendererStatic.PrevPose != rendererStatic.Pose);
572 }
573
574 if (!(nativeStatic.Flags & StaticMeshFlags::SM_VISIBLE))
575 continue;
576
577 if (nativeStatic.Color.w < EPSILON)
578 continue;
579
580 if (!_staticObjects[Statics.GetIndex(rendererStatic.ObjectNumber)].has_value())
581 continue;
582
583 const auto& rendererObj = GetStaticRendererObject(rendererStatic.ObjectNumber);
584 if (rendererObj.ObjectMeshes.empty())
585 continue;
586
587 if (!isRoomReflected && !renderView.Camera.Frustum.SphereInFrustum(rendererStatic.Sphere.Center, rendererStatic.Sphere.Radius))
588 continue;
589
590 // Collect lights.
591 auto lights = std::vector<RendererLight*>{};
592 auto cachedRoomLights = std::vector<RendererLightNode>{};
593 if (rendererObj.ObjectMeshes.front()->LightMode != LightMode::Static)
594 {
595 if (rendererStatic.CacheLights || _invalidateCache)
596 {
597 // Collect all lights and return cached light for next frames.
598 CollectLights(rendererStatic.Pose.Position.ToVector3(), ITEM_LIGHT_COLLECTION_RADIUS, rendererRoom.RoomNumber, NO_VALUE, false, false, &cachedRoomLights, &lights);
599 rendererStatic.CacheLights = false;
600 rendererStatic.CachedRoomLights = cachedRoomLights;
601 }
602 else

Callers

nothing calls this directly

Calls 12

ToLocalBoundingSphereMethod · 0.80
SphereInFrustumMethod · 0.80
sizeMethod · 0.45
emptyMethod · 0.45
UpdateMethod · 0.45
has_valueMethod · 0.45
GetIndexMethod · 0.45
ToVector3Method · 0.45
push_backMethod · 0.45
findMethod · 0.45
endMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected