Fix falling sand entities

This commit is contained in:
Drew DeVault 2015-04-20 14:26:15 -06:00
parent 1aa81a7d58
commit 52241a5ea3
3 changed files with 10 additions and 9 deletions

View File

@ -146,7 +146,7 @@ namespace TrueCraft.API
public void Intersects(ref BoundingBox box, out bool result)
{
if ((this.Max.X >= box.Min.X) && (this.Min.X <= box.Max.X))
if ((this.Max.X > box.Min.X) && (this.Min.X < box.Max.X))
{
if ((this.Max.Y < box.Min.Y) || (this.Min.Y > box.Max.Y))
{
@ -154,7 +154,7 @@ namespace TrueCraft.API
return;
}
result = (this.Max.Z >= box.Min.Z) && (this.Min.Z <= box.Max.Z);
result = (this.Max.Z > box.Min.Z) && (this.Min.Z < box.Max.Z);
return;
}

View File

@ -51,7 +51,7 @@ namespace TrueCraft.Core.Entities
{
get
{
return new BoundingBox(Vector3.Zero, Vector3.One);
return new BoundingBox(Position, Position + Size);
}
}
@ -71,7 +71,7 @@ namespace TrueCraft.Core.Entities
{
get
{
return 0.4f;
return 0.04f;
}
}
@ -79,7 +79,7 @@ namespace TrueCraft.Core.Entities
{
get
{
return 0.2f;
return 0.02f;
}
}

View File

@ -54,8 +54,9 @@ namespace TrueCraft
if (multipler < 0.1) multipler = 0.1;
lock (EntityLock)
{
foreach (var entity in Entities)
for (int i = 0; i < Entities.Count; i++)
{
var entity = Entities[i];
if (entity.BeginUpdate())
{
entity.Velocity -= new Vector3(0, entity.AccelerationDueToGravity * multipler, 0);
@ -145,7 +146,7 @@ namespace TrueCraft
var boundingBox = BlockPhysicsProvider.GetBoundingBox(world, position);
if (boundingBox == null)
continue;
blockBox = boundingBox.Value.OffsetBy(position);
blockBox = boundingBox.Value.OffsetBy(position + new Vector3(0.5));
if (TempBoundingBox.Intersects(blockBox))
{
if (entity.Velocity.X < 0)
@ -253,7 +254,7 @@ namespace TrueCraft
var boundingBox = BlockPhysicsProvider.GetBoundingBox(world, position);
if (boundingBox == null)
continue;
blockBox = boundingBox.Value.OffsetBy(position);
blockBox = boundingBox.Value.OffsetBy(position + new Vector3(0.5));
if (TempBoundingBox.Intersects(blockBox))
{
if (entity.Velocity.Y < 0)
@ -351,7 +352,7 @@ namespace TrueCraft
var boundingBox = BlockPhysicsProvider.GetBoundingBox(world, position);
if (boundingBox == null)
continue;
blockBox = boundingBox.Value.OffsetBy(position);
blockBox = boundingBox.Value.OffsetBy(position + new Vector3(0.5));
if (TempBoundingBox.Intersects(blockBox))
{
if (entity.Velocity.Z < 0)