minor formatting and code standard enforcement to Particle.*

This commit is contained in:
Andrew Meadows 2014-01-02 09:30:14 -08:00
parent 7c108ab489
commit 5843c745cb
2 changed files with 6 additions and 9 deletions

View file

@ -459,15 +459,14 @@ void Particle::adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, ssiz
void Particle::update() {
uint64_t now = usecTimestampNow();
int elapsed = now - _lastUpdated; // making this signed slightly improves clock skew behavior
float timeElapsed = (float)((float)elapsed/(float)USECS_PER_SECOND);
float elapsed = static_cast<float>(now - _lastUpdated);
_lastUpdated = now;
float timeElapsed = elapsed / static_cast<float>(USECS_PER_SECOND);
// calculate our default shouldDie state... then allow script to change it if it wants...
float velocityScalar = glm::length(getVelocity());
const float STILL_MOVING = 0.05 / TREE_SCALE;
const float STILL_MOVING = 0.05f / static_cast<float>(TREE_SCALE);
bool isStillMoving = (velocityScalar > STILL_MOVING);
const float REALLY_OLD = 30.0f; // 30 seconds
bool isReallyOld = (getLifetime() > REALLY_OLD);
@ -503,8 +502,6 @@ void Particle::update() {
_velocity -= dampingResistance * timeElapsed;
//printf("applying damping to Particle timeElapsed=%f\n",timeElapsed);
}
_lastUpdated = now;
}
void Particle::runScript() {

View file

@ -75,8 +75,8 @@ public:
uint64_t getLastEdited() const { return _lastEdited; }
/// lifetime of the particle in seconds
float getLifetime() const { return (float)(usecTimestampNow() - _created) / (float)USECS_PER_SECOND; }
float getEditedAgo() const { return (float)(usecTimestampNow() - _lastEdited) / (float)USECS_PER_SECOND; }
float getLifetime() const { return static_cast<float>(usecTimestampNow() - _created) / static_cast<float>(USECS_PER_SECOND); }
float getEditedAgo() const { return static_cast<float>(usecTimestampNow() - _lastEdited) / static_cast<float>(USECS_PER_SECOND); }
uint32_t getID() const { return _id; }
bool getShouldDie() const { return _shouldDie; }
QString getUpdateScript() const { return _updateScript; }