mirror of
https://github.com/glest/glest-source.git
synced 2025-08-21 23:45:14 +02:00
- improved performance and bug fixes.
This commit is contained in:
@@ -180,8 +180,10 @@ void ParticleSystem::setVisible(bool visible){
|
||||
}
|
||||
|
||||
// =============== MISC =========================
|
||||
void ParticleSystem::fade(){
|
||||
assert(state==sPlay);
|
||||
void ParticleSystem::fade() {
|
||||
if(particleObserver != NULL) {
|
||||
assert(state == sPlay);
|
||||
}
|
||||
state= sFade;
|
||||
if(particleObserver!=NULL){
|
||||
particleObserver->update(this);
|
||||
|
@@ -781,50 +781,58 @@ Vec3f Pixmap2D::getPixel3f(int x, int y) const {
|
||||
}
|
||||
|
||||
float Pixmap2D::getPixelf(int x, int y) const {
|
||||
return pixels[(w*y+x)*components]/255.f;
|
||||
int index = (w*y+x)*components;
|
||||
return pixels[index]/255.f;
|
||||
}
|
||||
|
||||
float Pixmap2D::getComponentf(int x, int y, int component) const {
|
||||
float c;
|
||||
float c=0;
|
||||
getComponent(x, y, component, c);
|
||||
return c;
|
||||
}
|
||||
|
||||
void Pixmap2D::setPixel(int x, int y, const uint8 *value) {
|
||||
for(int i=0; i<components; ++i) {
|
||||
pixels[(w*y+x)*components+i]= value[i];
|
||||
int index = (w*y+x)*components+i;
|
||||
pixels[index]= value[i];
|
||||
}
|
||||
}
|
||||
|
||||
void Pixmap2D::setPixel(int x, int y, const float32 *value) {
|
||||
for(int i=0; i<components; ++i) {
|
||||
pixels[(w*y+x)*components+i]= static_cast<uint8>(value[i]*255.f);
|
||||
int index = (w*y+x)*components+i;
|
||||
pixels[index]= static_cast<uint8>(value[i]*255.f);
|
||||
}
|
||||
}
|
||||
|
||||
void Pixmap2D::setComponent(int x, int y, int component, uint8 value) {
|
||||
pixels[(w*y+x)*components+component]= value;
|
||||
int index = (w*y+x)*components+component;
|
||||
pixels[index] = value;
|
||||
}
|
||||
|
||||
void Pixmap2D::setComponent(int x, int y, int component, float32 value){
|
||||
pixels[(w*y+x)*components+component]= static_cast<uint8>(value*255.f);
|
||||
void Pixmap2D::setComponent(int x, int y, int component, float32 value) {
|
||||
int index = (w*y+x)*components+component;
|
||||
pixels[index]= static_cast<uint8>(value*255.f);
|
||||
}
|
||||
|
||||
//vector set
|
||||
void Pixmap2D::setPixel(int x, int y, const Vec3f &p){
|
||||
for(int i=0; i<components && i<3; ++i){
|
||||
pixels[(w*y+x)*components+i]= static_cast<uint8>(p.ptr()[i]*255.f);
|
||||
void Pixmap2D::setPixel(int x, int y, const Vec3f &p) {
|
||||
for(int i = 0; i < components && i < 3; ++i) {
|
||||
int index = (w*y+x)*components+i;
|
||||
pixels[index]= static_cast<uint8>(p.ptr()[i]*255.f);
|
||||
}
|
||||
}
|
||||
|
||||
void Pixmap2D::setPixel(int x, int y, const Vec4f &p){
|
||||
for(int i=0; i<components && i<4; ++i){
|
||||
pixels[(w*y+x)*components+i]= static_cast<uint8>(p.ptr()[i]*255.f);
|
||||
void Pixmap2D::setPixel(int x, int y, const Vec4f &p) {
|
||||
for(int i = 0; i < components && i < 4; ++i) {
|
||||
int index = (w*y+x)*components+i;
|
||||
pixels[index]= static_cast<uint8>(p.ptr()[i]*255.f);
|
||||
}
|
||||
}
|
||||
|
||||
void Pixmap2D::setPixel(int x, int y, float p){
|
||||
pixels[(w*y+x)*components]= static_cast<uint8>(p*255.f);
|
||||
void Pixmap2D::setPixel(int x, int y, float p) {
|
||||
int index = (w*y+x)*components;
|
||||
pixels[index]= static_cast<uint8>(p*255.f);
|
||||
}
|
||||
|
||||
void Pixmap2D::setPixels(const uint8 *value){
|
||||
|
@@ -108,6 +108,12 @@ Chrono::Chrono() {
|
||||
freq = 1000;
|
||||
stopped= true;
|
||||
accumCount= 0;
|
||||
|
||||
lastStartCount = 0;
|
||||
lastTickCount = 0;
|
||||
lastResult = 0;
|
||||
lastMultiplier = 0;
|
||||
lastStopped = false;
|
||||
}
|
||||
|
||||
void Chrono::start() {
|
||||
@@ -122,26 +128,51 @@ void Chrono::stop() {
|
||||
stopped= true;
|
||||
}
|
||||
|
||||
int64 Chrono::getMicros() const {
|
||||
int64 Chrono::getMicros() {
|
||||
return queryCounter(1000000);
|
||||
}
|
||||
|
||||
int64 Chrono::getMillis() const {
|
||||
int64 Chrono::getMillis() {
|
||||
return queryCounter(1000);
|
||||
}
|
||||
|
||||
int64 Chrono::getSeconds() const {
|
||||
int64 Chrono::getSeconds() {
|
||||
return queryCounter(1);
|
||||
}
|
||||
|
||||
int64 Chrono::queryCounter(int multiplier) const {
|
||||
if(stopped) {
|
||||
return multiplier*accumCount/freq;
|
||||
} else {
|
||||
Uint32 endCount;
|
||||
endCount = SDL_GetTicks();
|
||||
return multiplier*(accumCount+endCount-startCount)/freq;
|
||||
int64 Chrono::queryCounter(int multiplier) {
|
||||
|
||||
if( multiplier == lastMultiplier &&
|
||||
stopped == lastStopped &&
|
||||
lastStartCount == startCount) {
|
||||
|
||||
if(stopped) {
|
||||
return lastResult;
|
||||
}
|
||||
else {
|
||||
Uint32 endCount = SDL_GetTicks();
|
||||
if(lastTickCount == endCount) {
|
||||
return lastResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int64 result = 0;
|
||||
if(stopped) {
|
||||
result = multiplier*accumCount/freq;
|
||||
}
|
||||
else {
|
||||
Uint32 endCount = SDL_GetTicks();
|
||||
result = multiplier*(accumCount+endCount-startCount)/freq;
|
||||
lastTickCount = endCount;
|
||||
}
|
||||
|
||||
lastStartCount = startCount;
|
||||
lastResult = result;
|
||||
lastMultiplier = multiplier;
|
||||
lastStopped = stopped;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int64 Chrono::getCurMillis() {
|
||||
|
Reference in New Issue
Block a user