attempt to fix the model render not properly timed
This commit is contained in:
parent
a0506e3486
commit
6cc8f6ac75
|
@ -5141,7 +5141,7 @@ void Renderer::renderUnits(const int renderFps) {
|
||||||
//dead alpha
|
//dead alpha
|
||||||
const SkillType *st= unit->getCurrSkill();
|
const SkillType *st= unit->getCurrSkill();
|
||||||
if(st->getClass() == scDie && static_cast<const DieSkillType*>(st)->getFade()) {
|
if(st->getClass() == scDie && static_cast<const DieSkillType*>(st)->getFade()) {
|
||||||
float alpha= 1.0f-unit->getAnimProgress();
|
float alpha= 1.0f - unit->getAnimProgressAsFloat();
|
||||||
glDisable(GL_COLOR_MATERIAL);
|
glDisable(GL_COLOR_MATERIAL);
|
||||||
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, Vec4f(1.0f, 1.0f, 1.0f, alpha).ptr());
|
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, Vec4f(1.0f, 1.0f, 1.0f, alpha).ptr());
|
||||||
}
|
}
|
||||||
|
@ -5155,7 +5155,7 @@ void Renderer::renderUnits(const int renderFps) {
|
||||||
//printf("Rendering model [%d - %s]\n[%s]\nCamera [%s]\nDistance: %f\n",unit->getId(),unit->getType()->getName().c_str(),unit->getCurrVector().getString().c_str(),this->gameCamera->getPos().getString().c_str(),this->gameCamera->getPos().dist(unit->getCurrVector()));
|
//printf("Rendering model [%d - %s]\n[%s]\nCamera [%s]\nDistance: %f\n",unit->getId(),unit->getType()->getName().c_str(),unit->getCurrVector().getString().c_str(),this->gameCamera->getPos().getString().c_str(),this->gameCamera->getPos().dist(unit->getCurrVector()));
|
||||||
|
|
||||||
//if(this->gameCamera->getPos().dist(unit->getCurrVector()) <= SKIP_INTERPOLATION_DISTANCE) {
|
//if(this->gameCamera->getPos().dist(unit->getCurrVector()) <= SKIP_INTERPOLATION_DISTANCE) {
|
||||||
model->updateInterpolationData(unit->getAnimProgress(), unit->isAlive() && !unit->isAnimProgressBound());
|
model->updateInterpolationData(unit->getAnimProgressAsFloat(), unit->isAlive() && !unit->isAnimProgressBound());
|
||||||
//}
|
//}
|
||||||
|
|
||||||
modelRenderer->render(model);
|
modelRenderer->render(model);
|
||||||
|
|
|
@ -471,8 +471,8 @@ Unit::Unit(int id, UnitPathInterface *unitpath, const Vec2i &pos,
|
||||||
|
|
||||||
lastPos= pos;
|
lastPos= pos;
|
||||||
progress= 0;
|
progress= 0;
|
||||||
lastAnimProgress= 0;
|
this->lastAnimProgress= 0;
|
||||||
animProgress= 0;
|
this->animProgress= 0;
|
||||||
progress2= 0;
|
progress2= 0;
|
||||||
kills= 0;
|
kills= 0;
|
||||||
enemyKills = 0;
|
enemyKills = 0;
|
||||||
|
@ -1041,8 +1041,8 @@ void Unit::setCurrSkill(const SkillType *currSkill) {
|
||||||
changedActiveCommand = false;
|
changedActiveCommand = false;
|
||||||
if( currSkill->getClass() != this->currSkill->getClass() ||
|
if( currSkill->getClass() != this->currSkill->getClass() ||
|
||||||
currSkill->getName() != this->currSkill->getName()) {
|
currSkill->getName() != this->currSkill->getName()) {
|
||||||
animProgress= 0;
|
this->animProgress= 0;
|
||||||
lastAnimProgress= 0;
|
this->lastAnimProgress= 0;
|
||||||
|
|
||||||
queuedUnitParticleSystemTypes.clear();
|
queuedUnitParticleSystemTypes.clear();
|
||||||
while(unitParticleSystems.empty() == false) {
|
while(unitParticleSystems.empty() == false) {
|
||||||
|
@ -1301,7 +1301,7 @@ Model *Unit::getCurrentModelPtr() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int currentModelIndexForCurrSkillType = lastModelIndexForCurrSkillType;
|
int currentModelIndexForCurrSkillType = lastModelIndexForCurrSkillType;
|
||||||
Model *result = currSkill->getAnimation(animProgress,this,&lastModelIndexForCurrSkillType, &animationRandomCycleCount);
|
Model *result = currSkill->getAnimation(getAnimProgressAsFloat(),this,&lastModelIndexForCurrSkillType, &animationRandomCycleCount);
|
||||||
if(currentModelIndexForCurrSkillType != lastModelIndexForCurrSkillType) {
|
if(currentModelIndexForCurrSkillType != lastModelIndexForCurrSkillType) {
|
||||||
animationRandomCycleCount++;
|
animationRandomCycleCount++;
|
||||||
if(currSkill != NULL && animationRandomCycleCount >= currSkill->getAnimationCount()) {
|
if(currSkill != NULL && animationRandomCycleCount >= currSkill->getAnimationCount()) {
|
||||||
|
@ -1319,7 +1319,7 @@ const Model *Unit::getCurrentModel() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int currentModelIndexForCurrSkillType = lastModelIndexForCurrSkillType;
|
int currentModelIndexForCurrSkillType = lastModelIndexForCurrSkillType;
|
||||||
const Model *result = currSkill->getAnimation(animProgress,this,&lastModelIndexForCurrSkillType, &animationRandomCycleCount);
|
const Model *result = currSkill->getAnimation(getAnimProgressAsFloat(),this,&lastModelIndexForCurrSkillType, &animationRandomCycleCount);
|
||||||
if(currentModelIndexForCurrSkillType != lastModelIndexForCurrSkillType) {
|
if(currentModelIndexForCurrSkillType != lastModelIndexForCurrSkillType) {
|
||||||
animationRandomCycleCount++;
|
animationRandomCycleCount++;
|
||||||
if(currSkill != NULL && animationRandomCycleCount >= currSkill->getAnimationCount()) {
|
if(currSkill != NULL && animationRandomCycleCount >= currSkill->getAnimationCount()) {
|
||||||
|
@ -2018,7 +2018,7 @@ bool Unit::update() {
|
||||||
int heightFactor = getHeightFactor();
|
int heightFactor = getHeightFactor();
|
||||||
|
|
||||||
//update progresses
|
//update progresses
|
||||||
lastAnimProgress= animProgress;
|
this->lastAnimProgress= this->animProgress;
|
||||||
const Game *game = Renderer::getInstance().getGame();
|
const Game *game = Renderer::getInstance().getGame();
|
||||||
|
|
||||||
progress = getUpdatedProgress(progress,
|
progress = getUpdatedProgress(progress,
|
||||||
|
@ -2041,17 +2041,15 @@ bool Unit::update() {
|
||||||
if(currSkill->getClass() == scMorph) {
|
if(currSkill->getClass() == scMorph) {
|
||||||
targetProgress = this->getProgressRatio();
|
targetProgress = this->getProgressRatio();
|
||||||
}
|
}
|
||||||
if(animProgress < targetProgress) {
|
if(getAnimProgressAsFloat() < targetProgress) {
|
||||||
float diff = targetProgress - animProgress;
|
float diff = targetProgress - getAnimProgressAsFloat();
|
||||||
animProgress = animProgress + diff / (GameConstants::updateFps);
|
this->animProgress = this->animProgress + static_cast<int>(diff * 100.f) / (GameConstants::updateFps);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
float speedDenominator = static_cast<float>(speedDivider) *
|
int speedDenominator = speedDivider *
|
||||||
game->getWorld()->getUpdateFps(this->getFactionIndex());
|
game->getWorld()->getUpdateFps(this->getFactionIndex());
|
||||||
animProgress += (currSkill->getAnimSpeed() *
|
this->animProgress += (currSkill->getAnimSpeed() * heightFactor) / speedDenominator;
|
||||||
(truncateDecimal<float>(static_cast<float>(heightFactor) / 100.f))) /
|
|
||||||
(truncateDecimal<float>(speedDenominator));
|
|
||||||
}
|
}
|
||||||
//update target
|
//update target
|
||||||
updateTarget();
|
updateTarget();
|
||||||
|
@ -2129,9 +2127,9 @@ bool Unit::update() {
|
||||||
}
|
}
|
||||||
|
|
||||||
//checks
|
//checks
|
||||||
if(animProgress > 1.f) {
|
if(this->animProgress > 100) {
|
||||||
bool canCycle = currSkill->CanCycleNextRandomAnimation(&animationRandomCycleCount);
|
bool canCycle = currSkill->CanCycleNextRandomAnimation(&animationRandomCycleCount);
|
||||||
animProgress = currSkill->getClass() == scDie? 1.f: 0.f;
|
this->animProgress = currSkill->getClass() == scDie ? 100 : 0;
|
||||||
if(canCycle == true) {
|
if(canCycle == true) {
|
||||||
this->lastModelIndexForCurrSkillType = -1;
|
this->lastModelIndexForCurrSkillType = -1;
|
||||||
}
|
}
|
||||||
|
@ -2299,7 +2297,7 @@ void Unit::updateTimedParticles() {
|
||||||
for(int i = queuedUnitParticleSystemTypes.size() - 1; i >= 0; i--) {
|
for(int i = queuedUnitParticleSystemTypes.size() - 1; i >= 0; i--) {
|
||||||
UnitParticleSystemType *pst = queuedUnitParticleSystemTypes[i];
|
UnitParticleSystemType *pst = queuedUnitParticleSystemTypes[i];
|
||||||
if(pst != NULL) {
|
if(pst != NULL) {
|
||||||
if(truncateDecimal<float>(pst->getStartTime()) <= truncateDecimal<float>(animProgress)) {
|
if(truncateDecimal<float>(pst->getStartTime()) <= truncateDecimal<float>(getAnimProgressAsFloat())) {
|
||||||
//printf("STARTING queued particle system type [%s] [%f] [%f] [%f] [%f]\n",pst->getType().c_str(),truncateDecimal<float>(pst->getStartTime()),truncateDecimal<float>(pst->getEndTime()),truncateDecimal<float>(animProgress),truncateDecimal<float>(lastAnimProgress));
|
//printf("STARTING queued particle system type [%s] [%f] [%f] [%f] [%f]\n",pst->getType().c_str(),truncateDecimal<float>(pst->getStartTime()),truncateDecimal<float>(pst->getEndTime()),truncateDecimal<float>(animProgress),truncateDecimal<float>(lastAnimProgress));
|
||||||
|
|
||||||
UnitParticleSystem *ups = new UnitParticleSystem(200);
|
UnitParticleSystem *ups = new UnitParticleSystem(200);
|
||||||
|
@ -2329,8 +2327,8 @@ void Unit::updateTimedParticles() {
|
||||||
if(truncateDecimal<float>(ps->getStartTime()) != 0.0 || truncateDecimal<float>(ps->getEndTime()) != 1.0) {
|
if(truncateDecimal<float>(ps->getStartTime()) != 0.0 || truncateDecimal<float>(ps->getEndTime()) != 1.0) {
|
||||||
//printf("Checking for end particle system #%d [%d] [%f] [%f] [%f] [%f]\n",i,ps->shape,truncateDecimal<float>(ps->getStartTime()),truncateDecimal<float>(ps->getEndTime()),truncateDecimal<float>(animProgress),truncateDecimal<float>(lastAnimProgress));
|
//printf("Checking for end particle system #%d [%d] [%f] [%f] [%f] [%f]\n",i,ps->shape,truncateDecimal<float>(ps->getStartTime()),truncateDecimal<float>(ps->getEndTime()),truncateDecimal<float>(animProgress),truncateDecimal<float>(lastAnimProgress));
|
||||||
|
|
||||||
if(truncateDecimal<float>(animProgress) >= 0.99 ||
|
if(truncateDecimal<float>(getAnimProgressAsFloat()) >= 0.99 ||
|
||||||
truncateDecimal<float>(animProgress) >= truncateDecimal<float>(ps->getEndTime())) {
|
truncateDecimal<float>(getAnimProgressAsFloat()) >= truncateDecimal<float>(ps->getEndTime())) {
|
||||||
//printf("ENDING particle system [%d]\n",ps->shape);
|
//printf("ENDING particle system [%d]\n",ps->shape);
|
||||||
|
|
||||||
ps->fade();
|
ps->fade();
|
||||||
|
|
|
@ -348,8 +348,8 @@ private:
|
||||||
int deadCount;
|
int deadCount;
|
||||||
//float progress; //between 0 and 1
|
//float progress; //between 0 and 1
|
||||||
int progress; //between 0 and 1
|
int progress; //between 0 and 1
|
||||||
float lastAnimProgress; //between 0 and 1
|
int lastAnimProgress; //between 0 and 1
|
||||||
float animProgress; //between 0 and 1
|
int animProgress; //between 0 and 1
|
||||||
float highlight;
|
float highlight;
|
||||||
int progress2;
|
int progress2;
|
||||||
int kills;
|
int kills;
|
||||||
|
@ -503,9 +503,12 @@ public:
|
||||||
inline int getId() const {return id;}
|
inline int getId() const {return id;}
|
||||||
inline Field getCurrField() const {return currField;}
|
inline Field getCurrField() const {return currField;}
|
||||||
inline int getLoadCount() const {return loadCount;}
|
inline int getLoadCount() const {return loadCount;}
|
||||||
inline float getLastAnimProgress() const {return lastAnimProgress;}
|
|
||||||
//float getProgress() const {return progress;}
|
//inline int getLastAnimProgress() const {return lastAnimProgress;}
|
||||||
inline float getAnimProgress() const {return animProgress;}
|
//inline int getAnimProgress() const {return animProgress;}
|
||||||
|
inline float getLastAnimProgressAsFloat() const {return static_cast<float>(lastAnimProgress) / 100.f;}
|
||||||
|
inline float getAnimProgressAsFloat() const {return static_cast<float>(animProgress) / 100.f;}
|
||||||
|
|
||||||
inline float getHightlight() const {return highlight;}
|
inline float getHightlight() const {return highlight;}
|
||||||
inline int getProgress2() const {return progress2;}
|
inline int getProgress2() const {return progress2;}
|
||||||
inline int getFactionIndex() const {
|
inline int getFactionIndex() const {
|
||||||
|
|
|
@ -120,7 +120,7 @@ bool UnitUpdater::updateUnit(Unit *unit) {
|
||||||
const SkillType *currSkill= unit->getCurrSkill();
|
const SkillType *currSkill= unit->getCurrSkill();
|
||||||
if(currSkill->getSound() != NULL) {
|
if(currSkill->getSound() != NULL) {
|
||||||
float soundStartTime= currSkill->getSoundStartTime();
|
float soundStartTime= currSkill->getSoundStartTime();
|
||||||
if(soundStartTime >= unit->getLastAnimProgress() && soundStartTime < unit->getAnimProgress()) {
|
if(soundStartTime >= unit->getLastAnimProgressAsFloat() && soundStartTime < unit->getAnimProgressAsFloat()) {
|
||||||
if(map->getSurfaceCell(Map::toSurfCoords(unit->getPos()))->isVisible(world->getThisTeamIndex()) ||
|
if(map->getSurfaceCell(Map::toSurfCoords(unit->getPos()))->isVisible(world->getThisTeamIndex()) ||
|
||||||
(game->getWorld()->showWorldForPlayer(game->getWorld()->getThisTeamIndex()) == true)) {
|
(game->getWorld()->showWorldForPlayer(game->getWorld()->getThisTeamIndex()) == true)) {
|
||||||
soundRenderer.playFx(currSkill->getSound(), unit->getCurrVector(), gameCamera->getPos());
|
soundRenderer.playFx(currSkill->getSound(), unit->getCurrVector(), gameCamera->getPos());
|
||||||
|
@ -138,7 +138,7 @@ bool UnitUpdater::updateUnit(Unit *unit) {
|
||||||
if(unit->getCurrSkill()->getClass() == scAttack) {
|
if(unit->getCurrSkill()->getClass() == scAttack) {
|
||||||
const AttackSkillType *ast= static_cast<const AttackSkillType*>(unit->getCurrSkill());
|
const AttackSkillType *ast= static_cast<const AttackSkillType*>(unit->getCurrSkill());
|
||||||
float attackStartTime= ast->getAttackStartTime();
|
float attackStartTime= ast->getAttackStartTime();
|
||||||
if(attackStartTime>=unit->getLastAnimProgress() && attackStartTime<unit->getAnimProgress()){
|
if(attackStartTime>=unit->getLastAnimProgressAsFloat() && attackStartTime<unit->getAnimProgressAsFloat()){
|
||||||
startAttackParticleSystem(unit);
|
startAttackParticleSystem(unit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue