Skip to content

Commit

Permalink
Adjust visualization to new CGE with optimize-shapes-collection
Browse files Browse the repository at this point in the history
  • Loading branch information
michaliskambi committed Aug 30, 2024
1 parent a98ec4a commit b2d37a5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 20 deletions.
23 changes: 6 additions & 17 deletions castle_model_viewer.dpr
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ type
TV3DViewport = class(TV3DShadowsViewport)
protected
procedure RenderFromView3D(const Params: TRenderParams); override;
procedure RenderOnePass(const Params: TRenderParams); override;
public
constructor Create(AOwner: TComponent); override;
procedure BeforeRender; override;
Expand Down Expand Up @@ -687,33 +686,23 @@ begin
SelectedItem^.World.Triangle,
SelectedPointWorld
);
end else
begin
SceneBoundingBox.Exists := false;
end;
end;

procedure TV3DViewport.RenderOnePass(const Params: TRenderParams);
procedure TV3DViewport.RenderFromView3D(const Params: TRenderParams);
begin
SceneBoundingBoxUpdate(Params.RenderingCamera);
inherited;
{ RenderVisualizations are opaque, so they should be rendered here
to correctly mix with partially transparent 3D scenes.
Render as ShadowVolumesReceivers=true to make selected triangle
drawn last (on top), to be clearly and always visible. }
if (not Params.Transparent) and
(true in Params.ShadowVolumesReceivers) then
RenderVisualizations(Params.RenderingCamera);
end;

procedure TV3DViewport.RenderFromView3D(const Params: TRenderParams);
begin
Scene.Visible := FillMode <> fmSilhouetteBorderEdges;
SceneDebugEdges.Exists := FillMode = fmSilhouetteBorderEdges;
if SceneDebugEdges.Exists then
SceneDebugEdges.UpdateEdges(Scene);
inherited;
{ inherited will call RenderOnePass that will call RenderVisualizations }

{ Draw visualizations after viewport contents, this is important for
"selected" visualization that doesn't use depth test and assumes it is
just drawn on top of everything. }
RenderVisualizations(Params.RenderingCamera);
end;

procedure TV3DViewport.BeforeRender;
Expand Down
10 changes: 7 additions & 3 deletions code/v3dsceneshadows.pas
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
interface

uses CastleWindow, CastleScene, CastleTransform, CastleVectors, CastleViewport,
CastleRenderOptions,
CastleRenderOptions, CastleUtils,
V3DSceneViewports;

type
Expand All @@ -37,7 +37,9 @@ interface
configurations (bump mapping, fill modes etc.) }
TV3DShadowsViewport = class(TMyViewport)
protected
procedure RenderOnePass(const Params: TRenderParams); override;
procedure RenderOnePass(const Params: TRenderParams;
const UsingBlending: Boolean;
const FilterShadowVolumesReceivers: TBooleanSet); override;
end;

var
Expand All @@ -56,7 +58,9 @@ procedure ViewportShadowsProperties(Viewport: TCastleViewport);
Viewport.ShadowVolumesRender := ShadowVolumesRender;
end;

procedure TV3DShadowsViewport.RenderOnePass(const Params: TRenderParams);
procedure TV3DShadowsViewport.RenderOnePass(const Params: TRenderParams;
const UsingBlending: Boolean;
const FilterShadowVolumesReceivers: TBooleanSet);

procedure RenderOnePassShadowsBegin(Scene: TCastleScene);
begin
Expand Down

0 comments on commit b2d37a5

Please sign in to comment.