Merge pull request #94 from emcifuntik/master

Changed entity hash generation method to real one used in RAGE
This commit is contained in:
dexyfex 2021-04-14 15:26:46 +10:00 committed by GitHub
commit b20af501e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 20 deletions

View File

@ -1385,6 +1385,7 @@ namespace CodeWalker.GameFiles
UpdateWidgetPosition();
UpdateWidgetOrientation();
UpdateEntityHash();
}
@ -1515,26 +1516,10 @@ namespace CodeWalker.GameFiles
public void UpdateEntityHash()
{
unchecked
{
var ints = new int[4];
var pv = Position;
ints[0] = (int)pv.X;
ints[1] = (int)pv.Y;
ints[2] = (int)pv.Z;
ints[3] = (int)_CEntityDef.archetypeName.Hash;
var bytes = new byte[16];
for (int i = 0; i < 4; i++)
{
var ib = i * 4;
var b = BitConverter.GetBytes(ints[i]);
bytes[ib + 0] = b[0];
bytes[ib + 1] = b[1];
bytes[ib + 2] = b[2];
bytes[ib + 3] = b[3];
}
EntityHash = JenkHash.GenHash(bytes);
}
uint xhash = (uint)(Position.X * 100);
uint yhash = (uint)(Position.Y * 100);
uint zhash = (uint)(Position.Z * 100);
EntityHash = _CEntityDef.archetypeName.Hash ^ xhash ^ yhash ^ zhash & 0xffffffff;
}
public void SetOrientation(Quaternion ori, bool inverse = false)

View File

@ -864,6 +864,7 @@ namespace CodeWalker.GameFiles
e.Orientation = Quaternion.Multiply(Owner.Orientation, e.MloRefOrientation);
e.UpdateWidgetPosition();
e.UpdateWidgetOrientation();
e.UpdateEntityHash();
}
public void AddEntity(YmapEntityDef e)