RigsOfRods / rigs-of-rods

Main development repository for Rigs of Rods soft-body physics simulator
https://www.rigsofrods.org
GNU General Public License v3.0
1.03k stars 178 forks source link

Custom groundmodel particles don't work #1413

Open ghost opened 6 years ago

ghost commented 6 years ago

I've known about this issue for a while now but I never was able to find the reason for it until recently. Groundmodels that use the fx_type "PARTICLE" don't seem to work on any version past 0.36.3. In that version, you could have set up a custom particle for a ground type, which resulted in nice looking particles if set up correctly: screenshot_76

fx_type = PARTICLE
fx_particle_name = mud_tractiontest
fx_colour = 1, 1, 1

However, this feature seems to have been broken since 0.36.3, as it doesn't seem to do anything now. There are 5 types of fx_type's that groundmodels can use: https://github.com/RigsOfRods/rigs-of-rods/blob/568cffcbba65a7e2b5eff73dce4a91db0bda01d2/source/main/physics/collision/Collisions.h#L57 which all but FX_PARTICLE uses a predefined particle file that you can only change the color of by changing the fx_colour value. I tested this by modifying the mud2 and mud3 sections of the Traction Test terrain, mud2 has the custom particle and mud3 uses the CLUMPY value: screenshot_2017-11-25_14-02-00_1

[mud2]
adhesion velocity = 3.0
static friction coefficient = 0.4
sliding friction coefficient = 0.25
hydrodynamic friction = 0.0001
stribeck velocity = 9
fx_type = PARTICLE
fx_particle_name = mud_tractiontest
fx_colour = 1, 1, 1
solid ground level = 5

fluid density = 1000
flow consistency index = 1000
flow behavior index = .5
drag anisotropy = .5

[mud3]
adhesion velocity = 3.0
static friction coefficient = 0.4
sliding friction coefficient = 0.25
hydrodynamic friction = 0.0001
stribeck velocity = 9
fx_type = CLUMPY
fx_particle_name = mud_tractiontest
fx_colour = 0.93, 0.81, 0.64
solid ground level = 5

fluid density = 500
flow consistency index = 1000
flow behavior index = 1
drag anisotropy = .5

As expected, mud2 doesn't give off any particles and mud3 works. image Links to both 0.36 and 0.4 versions of the map used: 0.36: TractionTestMuddy.zip 0.4: TractionTestMuddy.zip

ohlidalp commented 6 years ago

Thanks for the wonderfully elaborate bug report :heart:

I took a quick look and there's an apparent problem right here: https://github.com/only-a-ptr/ror-legacy-svn-trunk/blob/71d1ea1f31ad3eba3cdd68f454b7b2a41ec36b6a/source/main/physics/BeamForcesEuler.cpp#L753-L782 - there's no code to handle FX_PARTICLE. Unfortunately, this link references the oldest sources we have (circa 2011 ~ v0.38.x), which clearly indicates the FX_PARTICLE code got lost in the sands of time.

We're going to have to re-implement it from scratch because a ground definition without custom particles simply isn't complete. This is also a chance to drop the hardcoded FX 'dusty, clumpy, hard' effects and introduce an unified mechanism for defining particle look and feel.

Suggestions? 😄

ghost commented 6 years ago

Actually, we do have the source for 0.36.3: https://github.com/only-a-ptr/ror-legacy-svn-trunk/tree/dcb83de66935cb6b82d153fea2838e166419a7ac https://sourceforge.net/projects/rigsofrods/files/rigsofrods/0.36/0.36.3/ I don't know how helpful it will be though as the code will have to be rewritten anyway. It would be nice to see the hardcoded effects replaced by custom particles - this will give us the chance to create much better looking particles.

ohlidalp commented 6 months ago

This issue came up on Discord recently https://discord.com/channels/136544456244461568/189904947649708032/1235165850517114941 and as @ghost wrote, we actually do have old source code which still supports custom particles - DustPool.h/cpp and DustManager.h/cpp. https://github.com/ohlidalp/ror-legacy-svn-trunk/tree/dcb83de66935cb6b82d153fea2838e166419a7ac/build/main/source It appears to be portable to current version.