allow models for other entities to be any scale

your own scale is still restricted to 2-3, because collisions are extremely costly at large model scales
This commit is contained in:
UnknownShadow200 2019-02-18 21:45:03 +11:00
parent 0c5674637a
commit 015af253ab
2 changed files with 6 additions and 2 deletions

View File

@ -110,8 +110,10 @@ static void Entity_ParseScale(struct Entity* e, const String* scale) {
float value, maxScale; float value, maxScale;
if (!Convert_ParseFloat(scale, &value)) return; if (!Convert_ParseFloat(scale, &value)) return;
maxScale = e->Model->MaxScale; value = max(value, 0.001f);
Math_Clamp(value, 0.01f, maxScale); /* local player doesn't allow giant model scales */
/* (can't climb stairs, extremely CPU intensive collisions) */
if (e->ModelRestrictedScale) { value = min(value, e->Model->MaxScale); }
e->ModelScale = Vector3_Create1(value); e->ModelScale = Vector3_Create1(value);
} }
@ -904,6 +906,7 @@ static void LocalPlayer_Init(void) {
PhysicsComp_Init(&p->Physics, &p->Base); PhysicsComp_Init(&p->Physics, &p->Base);
TiltComp_Init(&p->Tilt); TiltComp_Init(&p->Tilt);
p->Base.ModelRestrictedScale = true;
p->ReachDistance = 5.0f; p->ReachDistance = 5.0f;
p->Physics.Hacks = &p->Hacks; p->Physics.Hacks = &p->Hacks;
p->Physics.Collisions = &p->Collisions; p->Physics.Collisions = &p->Collisions;

View File

@ -74,6 +74,7 @@ struct Entity {
struct Model* Model; struct Model* Model;
BlockID ModelBlock; /* BlockID, if model name was originally a valid block. */ BlockID ModelBlock; /* BlockID, if model name was originally a valid block. */
bool ModelRestrictedScale; /* true to restrict model scale (needed for local player, otherwise collisions are too costly) */
struct AABB ModelAABB; struct AABB ModelAABB;
Vector3 ModelScale, Size; Vector3 ModelScale, Size;
float StepSize; float StepSize;