Skip to content

Commit ca2fecc

Browse files
committed
particles fixup
1 parent 43be870 commit ca2fecc

6 files changed

Lines changed: 24 additions & 11 deletions

File tree

game/graphics/effect.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ Effect::Effect(const VisualFx& vfx, World& owner, const Npc& src, SpellFxKey key
2020
}
2121

2222
Effect::Effect(const VisualFx& v, World& owner, const Vec3& inPos, SpellFxKey k) {
23-
root = &v;
24-
nodeSlot = root->emTrjOriginNode;
23+
root = &v;
24+
nodeSlot = root->emTrjOriginNode;
2525
pos.identity();
2626
pos.translate(inPos);
2727
setKey(owner,k);
@@ -97,12 +97,19 @@ bool Effect::is(const VisualFx& vfx) const {
9797
}
9898

9999
void Effect::tick(uint64_t dt) {
100+
if(next!=nullptr)
101+
next->tick(dt);
102+
100103
if(root==nullptr)
101104
return;
105+
102106
Vec3 vel = root->emSelfRotVel;
103107
if(key!=nullptr)
104108
vel = key->emSelfRotVel.value_or(vel);
105109

110+
selfRotation += (vel*float(dt)/1000.f);
111+
if(vel!=Vec3())
112+
syncAttachesSingle(pos);
106113
}
107114

108115
void Effect::setActive(bool e) {
@@ -175,9 +182,12 @@ void Effect::syncAttachesSingle(const Matrix4x4& inPos) {
175182
p.mul(pose->bone(boneId));
176183
}
177184

178-
if(emSelfRotVel!=Vec3()) {
179-
//Matrix4x4 m;
180-
//m.rotateOX(emSelfRotVel.x*);
185+
if(selfRotation!=Vec3()) {
186+
Matrix4x4 m;
187+
m.rotateOX(selfRotation.x);
188+
m.rotateOY(selfRotation.y);
189+
m.rotateOZ(selfRotation.z);
190+
p.mul(m);
181191
}
182192

183193
p.set(3,1, p.at(3,1)+emTrjEaseVel);

game/graphics/effect.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ class Effect final {
8080
const MeshObjects::Mesh* meshEmitter = nullptr;
8181

8282
Tempest::Matrix4x4 pos;
83+
Tempest::Vec3 selfRotation;
8384

84-
uint64_t timeStart = 0;
8585
bool active = false;
8686
bool looped = false;
8787

game/graphics/pfx/particlefx.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ ParticleFx::ParticleFx(const Daedalus::GEngineClasses::C_ParticleFX &src, std::s
3939
ppsScaleKeys = loadArr(src.ppsScaleKeys_S);
4040
ppsIsLooping = src.ppsIsLooping!=0;
4141
ppsIsSmooth = src.ppsIsSmooth!=0;
42-
ppsFPS = src.ppsFPS;
42+
ppsFPS = src.ppsFPS>0 ? src.ppsFPS : 1.f;
4343
ppsCreateEm = Gothic::inst().loadParticleFx(src.ppsCreateEm_S.c_str());
4444
ppsCreateEmDelay = uint64_t(src.ppsCreateEmDelay);
4545

game/graphics/pfx/pfxbucket.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ void PfxBucket::init(PfxBucket::Block& block, ImplEmitter& emitter, size_t parti
316316
break;
317317
}
318318
case ParticleFx::Dir::Target:
319-
Vec3 targetPos = p.pos;
319+
Vec3 targetPos = emitter.pos;
320320
switch(decl.dirModeTargetFOR) {
321321
case ParticleFx::Frame::World:
322322
targetPos = decl.dirModeTargetPos;
@@ -327,6 +327,9 @@ void PfxBucket::init(PfxBucket::Block& block, ImplEmitter& emitter, size_t parti
327327
// MFX_WINDFIST_CAST
328328
auto mt = emitter.targetNpc->transform();
329329
mt.project(targetPos);
330+
} else {
331+
// IRRLICHT_DIE
332+
targetPos = emitter.pos;
330333
}
331334
break;
332335
}

game/world/triggers/pfxcontroller.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
PfxController::PfxController(Vob* parent, World& world, ZenLoad::zCVobData&& d, bool startup)
99
:AbstractTrigger(parent,world,std::move(d),startup) {
1010
auto& name = data.zCPFXControler.pfxName;
11-
const ParticleFx* view = Gothic::inst().loadParticleFx(name.c_str());
11+
const ParticleFx* view = Gothic::inst().loadParticleFx(name);
1212
if(view==nullptr)
13-
view = Gothic::inst().loadParticleFx(data.visual.c_str());
13+
view = Gothic::inst().loadParticleFx(data.visual);
1414
if(view==nullptr)
1515
return;
1616
lifeTime = view->maxLifetime();

0 commit comments

Comments
 (0)