Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simpler particle birth-offset, and again plus a "_tics_since_birth" getter #769

Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions direct/src/particles/ParticleEffect.py
Expand Up @@ -220,10 +220,13 @@ def softStop(self):
for particles in self.getParticlesList():
particles.softStop()

def softStart(self):
def softStart(self, firstBirthOffset = None):
if self.__isValid():
for particles in self.getParticlesList():
particles.softStart()
if firstBirthOffset is not None:
particles.softStartOffset(boff = firstBirthOffset)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: there should not be spaces around a = in keyword argument lists according to PEP8 even though there should be spaces around it almost anywhere else.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, fair enough. My own style includes spaces, but I'll change this to reflect the preferred style for the engine, I intend.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't worry too much about this particular issue; we're wildly inconsistent on this particular rule in the Panda codebase. I wouldn't block the PR from merging on this matter. We just try to default to PEP8 since it's the most popular style that is likely to be the most familiar to other developers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fair! But I have other changes to make anyway, as per your other comment, so I might as well include this one, too. ^_^

else:
particles.softStart()
else:
# Not asserting here since we want to crash live clients for more expedient bugfix
# (Sorry, live clients)
Expand Down
17 changes: 17 additions & 0 deletions panda/src/particlesystem/particleSystem.I
Expand Up @@ -58,6 +58,15 @@ soft_start(PN_stdfloat br) {
_tics_since_birth = 0.0f;
}

/**
* Causes system to use birth rate set by set_birth_rate()
*/
INLINE void ParticleSystem::
soft_start_offset(PN_stdfloat br, PN_stdfloat boff) {
soft_start(br);
_tics_since_birth = boff;
}

/**
* Causes system to use birth rate set by set_soft_birth_rate()
*/
Expand Down Expand Up @@ -342,6 +351,14 @@ get_floor_z() const {
return _floor_z;
}

/**

*/
INLINE PN_stdfloat ParticleSystem::
get_tics_since_birth() const {
return _tics_since_birth;
}

/**

*/
Expand Down
2 changes: 2 additions & 0 deletions panda/src/particlesystem/particleSystem.h
Expand Up @@ -83,6 +83,7 @@ class EXPCL_PANDA_PARTICLESYSTEM ParticleSystem : public Physical {
INLINE BaseParticleEmitter *get_emitter() const;
INLINE BaseParticleFactory *get_factory() const;
INLINE PN_stdfloat get_floor_z() const;
INLINE PN_stdfloat get_tics_since_birth() const;

// particle template vector

Expand All @@ -96,6 +97,7 @@ class EXPCL_PANDA_PARTICLESYSTEM ParticleSystem : public Physical {
INLINE void clear_to_initial();
INLINE void soft_stop(PN_stdfloat br = 0.0);
INLINE void soft_start(PN_stdfloat br = 0.0);
INLINE void soft_start_offset(PN_stdfloat br = 0.0, PN_stdfloat boff = 0.0);
void update(PN_stdfloat dt);

virtual void output(std::ostream &out) const;
Expand Down