mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 03:25:14 -04:00
Fix collisions when using 0 sized blocks as model
This commit is contained in:
parent
51417b950d
commit
65ab6a011d
@ -34,10 +34,18 @@ namespace ClassicalSharp.Model {
|
|||||||
float maxY = BlockInfo.MaxBB[block].Y;
|
float maxY = BlockInfo.MaxBB[block].Y;
|
||||||
return block == Block.Air ? 1 : (minY + maxY) / 2;
|
return block == Block.Air ? 1 : (minY + maxY) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Vector3 colShrink = new Vector3(0.75f/16, 0.75f/16, 0.75f/16);
|
static Vector3 colShrink = new Vector3(0.75f/16, 0.75f/16, 0.75f/16);
|
||||||
public override Vector3 CollisionSize {
|
public override Vector3 CollisionSize {
|
||||||
get { return (maxBB - minBB) - colShrink; } // to fit slightly inside
|
get {
|
||||||
|
// to fit slightly inside
|
||||||
|
Vector3 size = (maxBB - minBB) - colShrink;
|
||||||
|
// fix for 0 size blocks
|
||||||
|
size.X = Math.Max(size.X, 0.125f/16);
|
||||||
|
size.Y = Math.Max(size.Y, 0.125f/16);
|
||||||
|
size.Z = Math.Max(size.Z, 0.125f/16);
|
||||||
|
return size;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Vector3 offset = new Vector3(-0.5f, 0.0f, -0.5f);
|
static Vector3 offset = new Vector3(-0.5f, 0.0f, -0.5f);
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include "Stream.h"
|
#include "Stream.h"
|
||||||
#include "ErrorHandler.h"
|
#include "ErrorHandler.h"
|
||||||
#include "Entity.h"
|
#include "Entity.h"
|
||||||
|
#include "Funcs.h"
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
@ -1113,6 +1114,10 @@ static void BlockModel_GetCollisionSize(Vector3* size) {
|
|||||||
/* to fit slightly inside */
|
/* to fit slightly inside */
|
||||||
static Vector3 shrink = { 0.75f/16.0f, 0.75f/16.0f, 0.75f/16.0f };
|
static Vector3 shrink = { 0.75f/16.0f, 0.75f/16.0f, 0.75f/16.0f };
|
||||||
Vector3_SubBy(size, &shrink);
|
Vector3_SubBy(size, &shrink);
|
||||||
|
/* fix for 0 size blocks */
|
||||||
|
size->X = max(size->X, 0.125f/16.0f);
|
||||||
|
size->Y = max(size->Y, 0.125f/16.0f);
|
||||||
|
size->Z = max(size->Z, 0.125f/16.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void BlockModel_GetPickingBounds(struct AABB* bb) {
|
static void BlockModel_GetPickingBounds(struct AABB* bb) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user