From 4d2305355903e51a1714b8c8973ffd5800203935 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sun, 12 Nov 2017 22:59:08 +1100 Subject: [PATCH] Scale before rotation for models --- ClassicalSharp/Entities/Entity.cs | 8 +++++--- src/Client/Entity.c | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/ClassicalSharp/Entities/Entity.cs b/ClassicalSharp/Entities/Entity.cs index be1096125..34738c610 100644 --- a/ClassicalSharp/Entities/Entity.cs +++ b/ClassicalSharp/Entities/Entity.cs @@ -90,15 +90,15 @@ namespace ClassicalSharp.Entities { public Matrix4 TransformMatrix(Vector3 scale, Vector3 pos) { Matrix4 m = Matrix4.Identity, tmp; - + + Matrix4.Scale(out tmp, scale.X, scale.Y, scale.Z); + Matrix4.Mult(out m, ref m, ref tmp); Matrix4.RotateZ(out tmp, -RotZ * Utils.Deg2Rad); Matrix4.Mult(out m, ref m, ref tmp); Matrix4.RotateX(out tmp, -RotX * Utils.Deg2Rad); Matrix4.Mult(out m, ref m, ref tmp); Matrix4.RotateY(out tmp, -RotY * Utils.Deg2Rad); Matrix4.Mult(out m, ref m, ref tmp); - Matrix4.Scale(out tmp, scale.X, scale.Y, scale.Z); - Matrix4.Mult(out m, ref m, ref tmp); Matrix4.Translate(out tmp, pos.X, pos.Y, pos.Z); Matrix4.Mult(out m, ref m, ref tmp); @@ -226,6 +226,8 @@ namespace ClassicalSharp.Entities { /// bounding box of this entity are water or still water. public bool TouchesAnyWater() { AABB bounds = Bounds.Offset(liqExpand); + bounds.Min.Y += 5f/16f; + bounds.Max.Y -= 5f/16f; return TouchesAny(bounds, touchesAnyWater); } static Predicate touchesAnyWater = IsWater; diff --git a/src/Client/Entity.c b/src/Client/Entity.c index 2f3b6b2f4..7a7dc7b15 100644 --- a/src/Client/Entity.c +++ b/src/Client/Entity.c @@ -64,14 +64,14 @@ void Entity_GetTransform(Entity* entity, Vector3 pos, Vector3 scale) { *m = Matrix_Identity; Matrix tmp; + Matrix_Scale(&tmp, scale.X, scale.Y, scale.Z); + Matrix_MulBy(m, &tmp); Matrix_RotateZ(&tmp, -entity->RotZ * MATH_DEG2RAD); Matrix_MulBy(m, &tmp); Matrix_RotateX(&tmp, -entity->RotX * MATH_DEG2RAD); Matrix_MulBy(m, &tmp); Matrix_RotateY(&tmp, -entity->RotY * MATH_DEG2RAD); Matrix_MulBy(m, &tmp); - Matrix_Scale(&tmp, scale.X, scale.Y, scale.Z); - Matrix_MulBy(m, &tmp); Matrix_Translate(&tmp, pos.X, pos.Y, pos.Z); Matrix_MulBy(m, &tmp); /* return rotZ * rotX * rotY * scale * translate; */