Skip to content

Commit

Permalink
Fix 3d object thumbnails
Browse files Browse the repository at this point in the history
- Fixes a game crash after a desync
- Fixes it so you can actually see the object
  • Loading branch information
riperiperi committed Dec 3, 2024
1 parent 31bea08 commit f2bc125
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions TSOClient/tso.world/Platform/WorldPlatform3D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public void Dispose()
{
LotThumbTarget?.Dispose();
ObjThumbTarget?.Dispose();

LotThumbTarget = null;
ObjThumbTarget = null;
}

public void SwapBlueprint(Blueprint bp)
Expand Down Expand Up @@ -241,8 +244,8 @@ public Texture2D GetObjectThumb(ObjectComponent[] objects, Vector3[] positions,

gd.SetRenderTarget(ObjThumbTarget);
var cpoints = new List<Vector3>();
var view = state.View;
var vp = view * state.Projection;
var view = cam.View;
var vp = view * cam.Projection;
gd.BlendState = BlendState.NonPremultiplied;
gd.RasterizerState = RasterizerState.CullNone;
gd.DepthStencilState = DepthStencilState.Default;
Expand All @@ -265,11 +268,13 @@ public Texture2D GetObjectThumb(ObjectComponent[] objects, Vector3[] positions,
var oldObjRot = obj.Direction;
var oldObjPos = obj.UnmoddedPosition;
var oldRoom = obj.Room;
var oldContainer = obj.Container;

obj.Direction = Direction.NORTH;
obj.Room = 65535;
obj.OnRotationChanged(state);
obj.OnZoomChanged(state);
obj.Container = null;
obj.Position = tilePosition;
obj.Draw(gd, state);

Expand All @@ -289,6 +294,7 @@ public Texture2D GetObjectThumb(ObjectComponent[] objects, Vector3[] positions,
//return everything to normal
obj.Direction = oldObjRot;
obj.Room = oldRoom;
obj.Container = oldContainer;
obj.UnmoddedPosition = oldObjPos;
obj.OnRotationChanged(state);
obj.OnZoomChanged(state);
Expand Down

0 comments on commit f2bc125

Please sign in to comment.