Submarine rendering to correct position almost ready, fixed camera position "twitching"
This commit is contained in:
@@ -536,17 +536,28 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public void FindHull()
|
||||
public void FindHull(bool setSubmarine = true)
|
||||
{
|
||||
Hull newHull = Hull.FindHull(
|
||||
ConvertUnits.ToDisplayUnits(refLimb.SimPosition),
|
||||
currentHull);
|
||||
|
||||
|
||||
if (newHull == currentHull) return;
|
||||
|
||||
CurrentHull = newHull;
|
||||
|
||||
if (setSubmarine)
|
||||
{
|
||||
if (newHull == null && currentHull.Submarine != null)
|
||||
{
|
||||
SetPosition(refLimb.SimPosition + ConvertUnits.ToSimUnits(currentHull.Submarine.Position));
|
||||
}
|
||||
else if (currentHull == null && newHull != null && newHull.Submarine != null)
|
||||
{
|
||||
SetPosition(refLimb.SimPosition - ConvertUnits.ToSimUnits(newHull.Submarine.Position));
|
||||
}
|
||||
}
|
||||
|
||||
CurrentHull = newHull;
|
||||
|
||||
UpdateCollisionCategories();
|
||||
}
|
||||
|
||||
|
||||
@@ -443,7 +443,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
AnimController.FindHull();
|
||||
AnimController.FindHull(false);
|
||||
|
||||
CharacterList.Add(this);
|
||||
|
||||
@@ -755,7 +755,6 @@ namespace Barotrauma
|
||||
|
||||
if (moveCam)
|
||||
{
|
||||
cam.TargetPos = WorldPosition;
|
||||
cam.OffsetAmount = MathHelper.Lerp(cam.OffsetAmount, 250.0f, 0.05f);
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace Barotrauma
|
||||
else if (character.SelectedCharacter == null && character.ClosestItem != null && character.SelectedConstruction == null)
|
||||
{
|
||||
|
||||
Vector2 startPos = character.Position + (character.ClosestItem.Position - character.Position) * 0.7f;
|
||||
Vector2 startPos = character.WorldPosition + (character.ClosestItem.WorldPosition - character.WorldPosition) * 0.7f;
|
||||
startPos = cam.WorldToScreen(startPos);
|
||||
|
||||
Vector2 textPos = startPos;
|
||||
|
||||
@@ -163,6 +163,7 @@ namespace Barotrauma.Items.Components
|
||||
if (item.body == null)
|
||||
{
|
||||
transformedItemPos = new Vector2(item.Rect.X, item.Rect.Y);
|
||||
if (item.Submarine != null) transformedItemPos += item.Submarine.Position;
|
||||
transformedItemPos = transformedItemPos + itemPos;
|
||||
}
|
||||
else
|
||||
@@ -179,7 +180,7 @@ namespace Barotrauma.Items.Components
|
||||
transformedItemPos = Vector2.Transform(transformedItemPos, transform);
|
||||
transformedItemInterval = Vector2.Transform(transformedItemInterval, transform);
|
||||
|
||||
transformedItemPos += ConvertUnits.ToDisplayUnits(item.body.SimPosition);
|
||||
transformedItemPos += item.DrawPosition;
|
||||
|
||||
currentRotation += item.body.Rotation;
|
||||
}
|
||||
|
||||
@@ -1257,6 +1257,16 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override void OnMapLoaded()
|
||||
{
|
||||
FindHull();
|
||||
|
||||
foreach (ItemComponent ic in components)
|
||||
{
|
||||
ic.OnMapLoaded();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void NewComponentEvent(ItemComponent ic, bool isClient, bool isImportant)
|
||||
|
||||
@@ -384,9 +384,8 @@ namespace Barotrauma
|
||||
if (subBody != null) subBody.ApplyForce(force);
|
||||
}
|
||||
|
||||
public void SetPrevTransform(Vector2 position, Camera cam = null)
|
||||
public void SetPrevTransform(Vector2 position)
|
||||
{
|
||||
if (cam != null) cam.Position += prevPosition - position;
|
||||
prevPosition = position;
|
||||
}
|
||||
|
||||
@@ -646,23 +645,16 @@ namespace Barotrauma
|
||||
|
||||
subBody = new SubmarineBody(this);
|
||||
|
||||
MapEntity.MapLoaded();
|
||||
|
||||
foreach (Item item in Item.ItemList)
|
||||
{
|
||||
foreach (ItemComponent ic in item.components)
|
||||
{
|
||||
ic.OnMapLoaded();
|
||||
}
|
||||
}
|
||||
loaded = this;
|
||||
|
||||
MapEntity.MapLoaded();
|
||||
|
||||
WayPoint.GenerateSubWaypoints();
|
||||
|
||||
GameMain.LightManager.OnMapLoaded();
|
||||
|
||||
ID = ushort.MaxValue-10;
|
||||
|
||||
loaded = this;
|
||||
}
|
||||
|
||||
public static Submarine Load(string fileName)
|
||||
|
||||
@@ -101,14 +101,15 @@ namespace Barotrauma
|
||||
while (Physics.accumulator >= Physics.step)
|
||||
{
|
||||
cam.MoveCamera((float)Physics.step);
|
||||
if (Character.Controlled != null) cam.TargetPos = Character.Controlled.WorldPosition;
|
||||
|
||||
if (Submarine.Loaded != null) Submarine.Loaded.SetPrevTransform(Submarine.Loaded.Position, cam);
|
||||
if (Submarine.Loaded != null) Submarine.Loaded.SetPrevTransform(Submarine.Loaded.Position);
|
||||
|
||||
foreach (PhysicsBody pb in PhysicsBody.list)
|
||||
{
|
||||
pb.SetPrevTransform(pb.SimPosition, pb.Rotation);
|
||||
}
|
||||
|
||||
|
||||
MapEntity.UpdateAll(cam, (float)Physics.step);
|
||||
|
||||
Character.UpdateAnimAll((float)Physics.step);
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user