mirror of
https://github.com/glest/glest-source.git
synced 2025-08-18 22:21:18 +02:00
- bugfix animated particle model logic
This commit is contained in:
@@ -400,7 +400,8 @@ void ParticleSystemTypeProjectile::load(const XmlNode* particleFileNode, const s
|
|||||||
|
|
||||||
//trajectory speed
|
//trajectory speed
|
||||||
const XmlNode *tajectorySpeedNode= tajectoryNode->getChild("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"){
|
if(trajectory=="parabolic" || trajectory=="spiral"){
|
||||||
//trajectory scale
|
//trajectory scale
|
||||||
@@ -432,6 +433,8 @@ ProjectileParticleSystem *ParticleSystemTypeProjectile::create() {
|
|||||||
ParticleSystemType::setValues(ps);
|
ParticleSystemType::setValues(ps);
|
||||||
|
|
||||||
ps->setTrajectory(ProjectileParticleSystem::strToTrajectory(trajectory));
|
ps->setTrajectory(ProjectileParticleSystem::strToTrajectory(trajectory));
|
||||||
|
|
||||||
|
//printf("Setting trajectorySpeed = %f\n",trajectorySpeed);
|
||||||
ps->setTrajectorySpeed(trajectorySpeed);
|
ps->setTrajectorySpeed(trajectorySpeed);
|
||||||
ps->setTrajectoryScale(trajectoryScale);
|
ps->setTrajectoryScale(trajectoryScale);
|
||||||
ps->setTrajectoryFrequency(trajectoryFrequency);
|
ps->setTrajectoryFrequency(trajectoryFrequency);
|
||||||
|
@@ -776,8 +776,9 @@ void GameParticleSystem::render(ParticleRenderer *pr, ModelRenderer *mr){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GameParticleSystem::setTween(float relative,float absolute) {
|
void GameParticleSystem::setTween(float relative,float absolute) {
|
||||||
if(model){
|
if(model) {
|
||||||
// animation?
|
// animation?
|
||||||
|
//printf("#1 Particle model meshcount [%d] modelCycle = %f, relative = %f, absolute = %f\n",model->getMeshCount(),modelCycle,relative,absolute);
|
||||||
if(modelCycle == 0.0f) {
|
if(modelCycle == 0.0f) {
|
||||||
tween= relative;
|
tween= relative;
|
||||||
}
|
}
|
||||||
@@ -785,7 +786,7 @@ void GameParticleSystem::setTween(float relative,float absolute) {
|
|||||||
#ifdef USE_STREFLOP
|
#ifdef USE_STREFLOP
|
||||||
if(streflop::fabs(static_cast<streflop::Simple>(absolute)) <= 0.00001f){
|
if(streflop::fabs(static_cast<streflop::Simple>(absolute)) <= 0.00001f){
|
||||||
#else
|
#else
|
||||||
if(fabs(absolute) <= 0.00001f){
|
if(fabs(absolute) <= 0.00001f) {
|
||||||
#endif
|
#endif
|
||||||
tween = 0.0f;
|
tween = 0.0f;
|
||||||
}
|
}
|
||||||
@@ -806,9 +807,12 @@ void GameParticleSystem::setTween(float relative,float absolute) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tween= clamp(tween, 0.0f, 1.0f);
|
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);
|
(*it)->setTween(relative,absolute);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string GameParticleSystem::getModelFileLoadDeferred() {
|
string GameParticleSystem::getModelFileLoadDeferred() {
|
||||||
@@ -1431,12 +1435,15 @@ ProjectileParticleSystem::ProjectileParticleSystem(int particleCount) :
|
|||||||
setSpeed(0.14f);
|
setSpeed(0.14f);
|
||||||
|
|
||||||
trajectory= tLinear;
|
trajectory= tLinear;
|
||||||
|
|
||||||
trajectorySpeed= 1.0f;
|
trajectorySpeed= 1.0f;
|
||||||
trajectoryScale= 1.0f;
|
trajectoryScale= 1.0f;
|
||||||
trajectoryFrequency= 1.0f;
|
trajectoryFrequency= 1.0f;
|
||||||
modelCycle=0.0f;
|
modelCycle=0.0f;
|
||||||
|
|
||||||
nextParticleSystem= NULL;
|
nextParticleSystem= NULL;
|
||||||
|
|
||||||
|
//printf("#aXX trajectorySpeed = %f\n",trajectorySpeed);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectileParticleSystem::~ProjectileParticleSystem(){
|
ProjectileParticleSystem::~ProjectileParticleSystem(){
|
||||||
@@ -1462,11 +1469,18 @@ void ProjectileParticleSystem::update(){
|
|||||||
|
|
||||||
// ratio
|
// ratio
|
||||||
float relative= clamp(currentVector.length() / targetVector.length(), 0.0f, 1.0f);
|
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
|
#ifdef USE_STREFLOP
|
||||||
float absolute= clamp(streflop::fabs(static_cast<streflop::Simple>(currentVector.length())), 0.0f, 1.0f);
|
float absolute= clamp(streflop::fabs(static_cast<streflop::Simple>(currentVector.length())), 0.0f, 1.0f);
|
||||||
#else
|
#else
|
||||||
float absolute= clamp(fabs(currentVector.length()), 0.0f, 1.0f);
|
float absolute= clamp(fabs(currentVector.length()), 0.0f, 1.0f);
|
||||||
#endif
|
#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);
|
setTween(relative,absolute);
|
||||||
|
|
||||||
// trajectory
|
// trajectory
|
||||||
|
Reference in New Issue
Block a user