mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 16:44:36 +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)
|
afxForceSet::afxForceSet(const char* name)
|
||||||
{
|
{
|
||||||
this->name = (name) ? StringTable->insert(name) : ST_NULLSTRING;
|
mName = (name) ? StringTable->insert(name) : ST_NULLSTRING;
|
||||||
update_dt = 10.0f; // seems like an ok maximum, force-xmods will probably lower it.
|
mUpdate_dt = 10.0f; // seems like an ok maximum, force-xmods will probably lower it.
|
||||||
elapsed_dt = 0.0f;
|
mElapsed_dt = 0.0f;
|
||||||
elapsed_ms = 0;
|
mElapsed_ms = 0;
|
||||||
num_updates = 0;
|
mNum_updates = 0;
|
||||||
last_num_updates = 0;
|
mLast_num_updates = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void afxForceSet::remove(afxForce* force)
|
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;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -56,23 +56,23 @@ S32 afxForceSet::updateDT(F32 dt)
|
||||||
{
|
{
|
||||||
U32 now = Platform::getVirtualMilliseconds();
|
U32 now = Platform::getVirtualMilliseconds();
|
||||||
|
|
||||||
if (elapsed_ms == now)
|
if (mElapsed_ms == now)
|
||||||
return last_num_updates;
|
return mLast_num_updates;
|
||||||
|
|
||||||
elapsed_ms = now;
|
mElapsed_ms = now;
|
||||||
elapsed_dt += dt;
|
mElapsed_dt += dt;
|
||||||
|
|
||||||
if (elapsed_dt < update_dt)
|
if (mElapsed_dt < mUpdate_dt)
|
||||||
{
|
{
|
||||||
last_num_updates = 0;
|
mLast_num_updates = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
num_updates = mFloor(elapsed_dt/update_dt);
|
mNum_updates = mFloor(mElapsed_dt/mUpdate_dt);
|
||||||
elapsed_dt -= update_dt*num_updates;
|
mElapsed_dt -= mUpdate_dt*mNum_updates;
|
||||||
last_num_updates = num_updates;
|
mLast_num_updates = mNum_updates;
|
||||||
|
|
||||||
return num_updates;
|
return mNum_updates;
|
||||||
}
|
}
|
||||||
|
|
||||||
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
|
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
|
||||||
|
|
|
||||||
|
|
@ -32,28 +32,28 @@ class afxForce;
|
||||||
|
|
||||||
class afxForceSet
|
class afxForceSet
|
||||||
{
|
{
|
||||||
Vector<afxForce*> force_v;
|
Vector<afxForce*> mForce_v;
|
||||||
StringTableEntry name;
|
StringTableEntry mName;
|
||||||
|
|
||||||
// tick-based updating
|
// tick-based updating
|
||||||
F32 update_dt; // constant update interval, in seconds
|
F32 mUpdate_dt; // constant update interval, in seconds
|
||||||
F32 elapsed_dt; // runtime elapsed delta, in seconds
|
F32 mElapsed_dt; // runtime elapsed delta, in seconds
|
||||||
U32 elapsed_ms;
|
U32 mElapsed_ms;
|
||||||
S32 num_updates;
|
S32 mNum_updates;
|
||||||
S32 last_num_updates;
|
S32 mLast_num_updates;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/*C*/ afxForceSet(const char* name=0);
|
/*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);
|
void remove(afxForce* force);
|
||||||
|
|
||||||
S32 count() { return force_v.size(); }
|
S32 count() { return mForce_v.size(); }
|
||||||
afxForce* getForce(S32 idx) { return force_v[idx]; }
|
afxForce* getForce(S32 idx) { return mForce_v[idx]; }
|
||||||
const char* getName() const { return name; }
|
const char* getName() const { return mName; }
|
||||||
|
|
||||||
void setUpdateDT(F32 update_dt) { this->update_dt = update_dt; }
|
void setUpdateDT(F32 update_dt) { mUpdate_dt = update_dt; }
|
||||||
F32 getUpdateDT() { return update_dt; }
|
F32 getUpdateDT() { return mUpdate_dt; }
|
||||||
|
|
||||||
S32 updateDT(F32 dt);
|
S32 updateDT(F32 dt);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue