NSEntity: Make sure .scale affects SetSize() calls and is updated with

SetModel() calls. Also keep track of original .mins/.maxs in case scale
changes.
This commit is contained in:
Marco Cawthorne 2021-11-10 02:33:31 +01:00
parent b670c994c1
commit a8e4cd5748
Signed by: eukara
GPG Key ID: C196CD8BA993248A
4 changed files with 14 additions and 9 deletions

View File

@ -553,8 +553,6 @@ CSQC_Input_Frame(void)
sendevent("Spraylogo", "");
}
if (pSeat->m_flCameraTime > time) {
/* TODO: Supress the changing of view_angles/input_angles. */
}

View File

@ -22,6 +22,10 @@ class NSEntity:NSTrigger
{
void(void) NSEntity;
/* these are the real bounds, whereas .mins .maxs are affected by .scale */
vector m_vecMins;
vector m_vecMaxs;
#ifdef CLIENT
virtual void(float flChanged) ReceiveEntity;
virtual void(void) postdraw;
@ -73,4 +77,4 @@ class NSEntity:NSTrigger
virtual void(vector) SetOrigin;
virtual void(vector, vector) SetSize;
virtual void(string, string) SpawnKey;
};
};

View File

@ -284,10 +284,9 @@ NSEntity::SetAngles(vector newAngles)
void
NSEntity::SetSize(vector newMins, vector newMaxs)
{
if (newMins == mins && newMaxs == maxs)
return;
setsize(this, newMins, newMaxs);
m_vecMins = newMins;
m_vecMaxs = newMaxs;
setsize(this, m_vecMins * scale, m_vecMaxs * scale);
SetSendFlags(BASEFL_CHANGED_SIZE);
}
void
@ -306,6 +305,7 @@ NSEntity::SetModel(string newModel)
{
model = newModel;
setmodel(this, newModel);
SetSize(mins, maxs);
SetSendFlags(BASEFL_CHANGED_MODELINDEX);
}
void
@ -315,10 +315,10 @@ NSEntity::SetModelindex(float newModelIndex)
return;
modelindex = newModelIndex;
SetSize(mins, maxs);
SetSendFlags(BASEFL_CHANGED_MODELINDEX);
}
#ifdef SERVER
vector
NSEntity::GetSpawnOrigin(void)

View File

@ -346,7 +346,6 @@ NSRenderableEntity::ReceiveEntity(float flChanged)
maxs[0] = readcoord();
maxs[1] = readcoord();
maxs[2] = readcoord();
setsize(this, mins, maxs);
}
if (flChanged & BASEFL_CHANGED_FRAME) {
frame1time = 0.0;
@ -402,6 +401,9 @@ NSRenderableEntity::ReceiveEntity(float flChanged)
if (scale == 0.0)
scale = 1.0f;
if (flChanged & BASEFL_CHANGED_SIZE)
setsize(this, mins * scale, maxs * scale);
setorigin(this, origin);
}
/*
@ -528,6 +530,7 @@ NSRenderableEntity::SetScale(float newScale)
return;
scale = newScale;
setsize(this, m_vecMins * scale, m_vecMaxs * scale);
SetSendFlags(BASEFL_CHANGED_SCALE);
}