mirror of
https://github.com/glest/glest-source.git
synced 2025-08-13 20:03:58 +02:00
- added the ability to synch unit particles with model animation using start-time and end-time attributes
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#ifndef _SHARED_GRAPHICS_MATHUTIL_H_
|
||||
#define _SHARED_GRAPHICS_MATHUTIL_H_
|
||||
|
||||
#include "math_wrapper.h"
|
||||
#include "vec.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
@@ -266,6 +267,21 @@ inline T radToDeg(T rad){
|
||||
return (rad*360)/(2*pi);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline T truncateDecimal(const T &value, int precision=6) {
|
||||
int iSigned = value >= 0 ? 1: -1;
|
||||
|
||||
#ifdef USE_STREFLOP
|
||||
unsigned int uiTemp = (value * streflop::pow((streflop::Simple)10, (streflop::Simple)precision)) * iSigned; //Note I'm using unsigned int so that I can increase the precision of the truncate
|
||||
T result = (((double)uiTemp) / streflop::pow((streflop::Simple)10,(streflop::Simple)precision) * iSigned);
|
||||
#else
|
||||
unsigned int uiTemp = (value * pow(10, precision)) * iSigned; //Note I'm using unsigned int so that I can increase the precision of the truncate
|
||||
T result = (((double)uiTemp) / pow(10,precision) * iSigned);
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}}//end namespace
|
||||
|
||||
#endif
|
||||
|
@@ -277,6 +277,8 @@ private:
|
||||
Vec3f fixedAddition;
|
||||
Vec3f oldPosition;
|
||||
bool energyUp;
|
||||
float startTime;
|
||||
float endTime;
|
||||
|
||||
public:
|
||||
enum Shape{
|
||||
@@ -315,6 +317,11 @@ public:
|
||||
virtual void fade();
|
||||
virtual void render(ParticleRenderer *pr, ModelRenderer *mr);
|
||||
|
||||
virtual void setStartTime(float startTime) { this->startTime = startTime; }
|
||||
virtual float getStartTime() const { return this->startTime; }
|
||||
virtual void setEndTime(float endTime) { this->endTime = endTime; }
|
||||
virtual float getEndTime() const { return this->endTime; }
|
||||
|
||||
//set params
|
||||
void setRadius(float radius) {this->radius= radius;}
|
||||
void setMinRadius(float minRadius) {this->minRadius= minRadius;}
|
||||
|
Reference in New Issue
Block a user