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