Scale before rotation for models

This commit is contained in:
UnknownShadow200 2017-11-12 22:59:08 +11:00
parent 8c7e047268
commit 4d23053559
2 changed files with 7 additions and 5 deletions

View File

@ -91,14 +91,14 @@ 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. </summary>
public bool TouchesAnyWater() {
AABB bounds = Bounds.Offset(liqExpand);
bounds.Min.Y += 5f/16f;
bounds.Max.Y -= 5f/16f;
return TouchesAny(bounds, touchesAnyWater);
}
static Predicate<BlockID> touchesAnyWater = IsWater;

View File

@ -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; */