Skip to content

Comments

water splash particles#136

Merged
mgerhardy merged 2 commits intomgerhardy:masterfrom
cryham:water-particles
Mar 9, 2025
Merged

water splash particles#136
mgerhardy merged 2 commits intomgerhardy:masterfrom
cryham:water-particles

Conversation

@cryham
Copy link
Contributor

@cryham cryham commented Mar 9, 2025

Code was mostly there.
Restored water splash particles and tweaked settings to look cool.
Mostly in water and a bit splash above, not sure why darker.
Looks even better when having packages or for diving.
Screens with refraction:

09_02-15-45`s

09_02-12-50`s


namespace caveexpress {

const float min_lastSoundDT = 1.f; // time, sec
Copy link
Owner

Choose a reason for hiding this comment

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

_lastSoundTime exists for this - why do we need a global var here?

Copy link
Contributor Author

@cryham cryham Mar 9, 2025

Choose a reason for hiding this comment

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

This is a const value for comparing later (twice):
if (_lastSoundDT > min_lastSoundDT) {

while _lastSoundTime is variable, added in Water::update by deltaTime.

Copy link
Owner

Choose a reason for hiding this comment

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

i see - but why do we need _lastSoundDT if we have _lastSoundTime (i don't see why it must be float, we should be able to re-use the existing var, no?)

@mgerhardy
Copy link
Owner

ninja: error: unknown target 'Makefile.local'
[12/51] Building CXX object src/caveexpress/server/CMakeFiles/caveexpress-server.dir/entities/WorldParticle.cpp.o
/home/mgerhardy/dev/oss/caveexpress/src/caveexpress/server/entities/WorldParticle.cpp: In member function ‘b2Vec2 caveexpress::WorldParticle::getSpawnPosition(const caveexpress::IEntity*) const’:
/home/mgerhardy/dev/oss/caveexpress/src/caveexpress/server/entities/WorldParticle.cpp:34:21: warning: unused variable ‘vx’ [-Wunused-variable]
   34 |         const float vx = entity->getLinearVelocity().x;
      |                     ^~
[45/51] Building CXX object src/caveexpress/server/CMakeFiles/caveexpress-server.dir/entities/Water.cpp.o
In file included from /home/mgerhardy/dev/oss/caveexpress/src/caveexpress/server/entities/Water.cpp:1:
/home/mgerhardy/dev/oss/caveexpress/src/caveexpress/server/entities/Water.h: In constructor ‘caveexpress::Water::Water(caveexpress::Map&, float, uint32_t, uint32_t)’:
/home/mgerhardy/dev/oss/caveexpress/src/caveexpress/server/entities/Water.h:35:15: warning: ‘caveexpress::Water::_lastSoundDT’ will be initialized after [-Wreorder]
   35 |         float _lastSoundDT;
      |               ^~~~~~~~~~~~
/home/mgerhardy/dev/oss/caveexpress/src/caveexpress/server/entities/Water.cpp:20:115: warning:   base ‘caveexpress::IEntity’ [-Wreorder]
   20 |                 _currentHeightLevel(0.0f), _waterRisingTime(waterRisingDelay), _waterFallingTime(waterFallingDelay)
      |                                                                                                                   ^
/home/mgerhardy/dev/oss/caveexpress/src/caveexpress/server/entities/Water.cpp:16:1: warning:   when initialized here [-Wreorder]
   16 | Water::Water (Map& map, float waterChangeSpeed, uint32_t waterRisingDelay, uint32_t waterFallingDelay) :
      | ^~~~~

@mgerhardy
Copy link
Owner

looks nice. good job

@cryham
Copy link
Contributor Author

cryham commented Mar 9, 2025

Fixed issues from comments.

// play the sound only once per second
if (_lastSoundTime < _time + 1000) {
_lastSoundTime = _time;
if (_lastSoundDT > min_lastSoundDT) {
Copy link
Owner

Choose a reason for hiding this comment

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

sorry, I still don't see why this change is needed - what's wrong with the _lastSoundTime < _time + 1000 check here? why must it be float?

Copy link
Contributor Author

@cryham cryham Mar 9, 2025

Choose a reason for hiding this comment

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

It doesn't work. It triggers many sounds while in water.
I just used float and added dt in update to be sure. I didn't check why _time doesn't work.
Made a const above since it is used twice.

@mgerhardy mgerhardy merged commit e62282b into mgerhardy:master Mar 9, 2025
3 of 4 checks passed
@cryham cryham deleted the water-particles branch March 9, 2025 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants