mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-04 21:10:32 +00:00
afxforceset membervar cleanups
This commit is contained in:
parent
b6076c55dd
commit
17b627e05f
2 changed files with 32 additions and 32 deletions
|
|
@ -32,21 +32,21 @@
|
|||
|
||||
afxForceSet::afxForceSet(const char* name)
|
||||
{
|
||||
this->name = (name) ? StringTable->insert(name) : ST_NULLSTRING;
|
||||
update_dt = 10.0f; // seems like an ok maximum, force-xmods will probably lower it.
|
||||
elapsed_dt = 0.0f;
|
||||
elapsed_ms = 0;
|
||||
num_updates = 0;
|
||||
last_num_updates = 0;
|
||||
mName = (name) ? StringTable->insert(name) : ST_NULLSTRING;
|
||||
mUpdate_dt = 10.0f; // seems like an ok maximum, force-xmods will probably lower it.
|
||||
mElapsed_dt = 0.0f;
|
||||
mElapsed_ms = 0;
|
||||
mNum_updates = 0;
|
||||
mLast_num_updates = 0;
|
||||
}
|
||||
|
||||
void afxForceSet::remove(afxForce* force)
|
||||
{
|
||||
for (S32 i = 0; i < force_v.size(); i++)
|
||||
for (S32 i = 0; i < mForce_v.size(); i++)
|
||||
{
|
||||
if (force_v[i] == force)
|
||||
if (mForce_v[i] == force)
|
||||
{
|
||||
force_v.erase(i);
|
||||
mForce_v.erase(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -56,23 +56,23 @@ S32 afxForceSet::updateDT(F32 dt)
|
|||
{
|
||||
U32 now = Platform::getVirtualMilliseconds();
|
||||
|
||||
if (elapsed_ms == now)
|
||||
return last_num_updates;
|
||||
if (mElapsed_ms == now)
|
||||
return mLast_num_updates;
|
||||
|
||||
elapsed_ms = now;
|
||||
elapsed_dt += dt;
|
||||
mElapsed_ms = now;
|
||||
mElapsed_dt += dt;
|
||||
|
||||
if (elapsed_dt < update_dt)
|
||||
if (mElapsed_dt < mUpdate_dt)
|
||||
{
|
||||
last_num_updates = 0;
|
||||
mLast_num_updates = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
num_updates = mFloor(elapsed_dt/update_dt);
|
||||
elapsed_dt -= update_dt*num_updates;
|
||||
last_num_updates = num_updates;
|
||||
mNum_updates = mFloor(mElapsed_dt/mUpdate_dt);
|
||||
mElapsed_dt -= mUpdate_dt*mNum_updates;
|
||||
mLast_num_updates = mNum_updates;
|
||||
|
||||
return num_updates;
|
||||
return mNum_updates;
|
||||
}
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
|
||||
|
|
|
|||
|
|
@ -32,28 +32,28 @@ class afxForce;
|
|||
|
||||
class afxForceSet
|
||||
{
|
||||
Vector<afxForce*> force_v;
|
||||
StringTableEntry name;
|
||||
Vector<afxForce*> mForce_v;
|
||||
StringTableEntry mName;
|
||||
|
||||
// tick-based updating
|
||||
F32 update_dt; // constant update interval, in seconds
|
||||
F32 elapsed_dt; // runtime elapsed delta, in seconds
|
||||
U32 elapsed_ms;
|
||||
S32 num_updates;
|
||||
S32 last_num_updates;
|
||||
F32 mUpdate_dt; // constant update interval, in seconds
|
||||
F32 mElapsed_dt; // runtime elapsed delta, in seconds
|
||||
U32 mElapsed_ms;
|
||||
S32 mNum_updates;
|
||||
S32 mLast_num_updates;
|
||||
|
||||
public:
|
||||
/*C*/ afxForceSet(const char* name=0);
|
||||
|
||||
void add(afxForce* force) { force_v.push_back(force); }
|
||||
void add(afxForce* force) { mForce_v.push_back(force); }
|
||||
void remove(afxForce* force);
|
||||
|
||||
S32 count() { return force_v.size(); }
|
||||
afxForce* getForce(S32 idx) { return force_v[idx]; }
|
||||
const char* getName() const { return name; }
|
||||
S32 count() { return mForce_v.size(); }
|
||||
afxForce* getForce(S32 idx) { return mForce_v[idx]; }
|
||||
const char* getName() const { return mName; }
|
||||
|
||||
void setUpdateDT(F32 update_dt) { this->update_dt = update_dt; }
|
||||
F32 getUpdateDT() { return update_dt; }
|
||||
void setUpdateDT(F32 update_dt) { mUpdate_dt = update_dt; }
|
||||
F32 getUpdateDT() { return mUpdate_dt; }
|
||||
|
||||
S32 updateDT(F32 dt);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue