- bugfix animated particle model logic

This commit is contained in:
Mark Vejvoda
2012-04-04 23:43:31 +00:00
parent 4aae520da6
commit 83d2474ded
2 changed files with 21 additions and 4 deletions

View File

@@ -400,7 +400,8 @@ void ParticleSystemTypeProjectile::load(const XmlNode* particleFileNode, const s
//trajectory speed
const XmlNode *tajectorySpeedNode= tajectoryNode->getChild("speed");
trajectorySpeed= tajectorySpeedNode->getAttribute("value")->getFloatValue()/GameConstants::updateFps;
trajectorySpeed= tajectorySpeedNode->getAttribute("value")->getFloatValue() / (float)GameConstants::updateFps;
//printf("[%s] trajectorySpeed = %f\n",path.c_str(),trajectorySpeed);
if(trajectory=="parabolic" || trajectory=="spiral"){
//trajectory scale
@@ -432,6 +433,8 @@ ProjectileParticleSystem *ParticleSystemTypeProjectile::create() {
ParticleSystemType::setValues(ps);
ps->setTrajectory(ProjectileParticleSystem::strToTrajectory(trajectory));
//printf("Setting trajectorySpeed = %f\n",trajectorySpeed);
ps->setTrajectorySpeed(trajectorySpeed);
ps->setTrajectoryScale(trajectoryScale);
ps->setTrajectoryFrequency(trajectoryFrequency);

View File

@@ -776,8 +776,9 @@ void GameParticleSystem::render(ParticleRenderer *pr, ModelRenderer *mr){
}
void GameParticleSystem::setTween(float relative,float absolute) {
if(model){
if(model) {
// animation?
//printf("#1 Particle model meshcount [%d] modelCycle = %f, relative = %f, absolute = %f\n",model->getMeshCount(),modelCycle,relative,absolute);
if(modelCycle == 0.0f) {
tween= relative;
}
@@ -785,7 +786,7 @@ void GameParticleSystem::setTween(float relative,float absolute) {
#ifdef USE_STREFLOP
if(streflop::fabs(static_cast<streflop::Simple>(absolute)) <= 0.00001f){
#else
if(fabs(absolute) <= 0.00001f){
if(fabs(absolute) <= 0.00001f) {
#endif
tween = 0.0f;
}
@@ -806,9 +807,12 @@ void GameParticleSystem::setTween(float relative,float absolute) {
}
tween= clamp(tween, 0.0f, 1.0f);
//printf("#2 Particle model meshcount [%d] modelCycle = %f, relative = %f, absolute = %f\n",model->getMeshCount(),modelCycle,relative,absolute);
}
for(Children::iterator it= children.begin(); it != children.end(); ++it)
for(Children::iterator it= children.begin(); it != children.end(); ++it) {
(*it)->setTween(relative,absolute);
}
}
string GameParticleSystem::getModelFileLoadDeferred() {
@@ -1431,12 +1435,15 @@ ProjectileParticleSystem::ProjectileParticleSystem(int particleCount) :
setSpeed(0.14f);
trajectory= tLinear;
trajectorySpeed= 1.0f;
trajectoryScale= 1.0f;
trajectoryFrequency= 1.0f;
modelCycle=0.0f;
nextParticleSystem= NULL;
//printf("#aXX trajectorySpeed = %f\n",trajectorySpeed);
}
ProjectileParticleSystem::~ProjectileParticleSystem(){
@@ -1462,11 +1469,18 @@ void ProjectileParticleSystem::update(){
// ratio
float relative= clamp(currentVector.length() / targetVector.length(), 0.0f, 1.0f);
//printf("Update particle targetVector [%s][%f] currentVector [%s][%f] relative = %f\n",targetVector.getString().c_str(),targetVector.length(),currentVector.getString().c_str(),currentVector.length(),relative);
#ifdef USE_STREFLOP
float absolute= clamp(streflop::fabs(static_cast<streflop::Simple>(currentVector.length())), 0.0f, 1.0f);
#else
float absolute= clamp(fabs(currentVector.length()), 0.0f, 1.0f);
#endif
//printf("#a currentVector.length() = %f, targetVector.length() = %f, relative = %f, absolute = %f, trajectorySpeed = %f\n",currentVector.length(),targetVector.length(),relative,absolute,trajectorySpeed);
absolute = relative;
setTween(relative,absolute);
// trajectory