GearBlocks
Steam News 10 August 20241y ago

GearBlocks 0.7.8987

Hello everyone, it's been a long time coming, but it's finally time for another update! There's too much to cover in technical detail here really, so I'll just give a brief summary... Combustion Engines As I mentioned i…

Update log

Full GearBlocks update

The complete published notes, normalized for clean reading and source attribution.

Repeated intro

Hello everyone, it's been a long time coming, but it's finally time for another update!

Extracted changes

1 fix1 addition6 changes0 removals
  • Performance
  • Gameplay
  • UI and audio
changedCombustion EnginesAs I mentioned in my last post, I tried using physics forces applied to physical piston and con-rod parts to drive the engine. After prototyping this, I found it not be a viable solution, due to phantom forces (from rapidly moving piston and con-rod parts), performance cost, and other issues.
changedCombustion EnginesSome possibilities included (in order of complexity): lookup tables, mean value modelling (MVM), 1D or multi-D fluid dynamic modelling. After investigation, I chose a basic MVM approach for relative simplicity (for performance and implementation), while still providing more flexibility and realism than a simple lookup table based solution.
fixedCombustion EnginesA "sim updater" to update the simulation multiple times per fixed update (giving a smaller time step per update). I found this was necessary to improve simulation stability of the throttle air flow and intake manifold pressure.
addedCombustion EnginesI've made a selection of new parts (cranks, cylinders, heads, throttle, etc.) that you can use to build combustion engines.
changedCombustion EnginesSound
changedCombustion EnginesI wanted the engine sound to be derived from and recognisable to any given engine configuration. For simplicity, the approach I went with is to play a looped "single cylinder" sound for each of an engine's cylinders, with pitch and volume varied based on RPM and engine load. The audio playback is then synchronised across all the cylinders, with a precise timing offset for each cylinder.

There's too much to cover in technical detail here really, so I'll just give a brief summary...

Combustion Engines

As I mentioned in my last post, I tried using physics forces applied to physical piston and con-rod parts to drive the engine. After prototyping this, I found it not be a viable solution, due to phantom forces (from rapidly moving piston and con-rod parts), performance cost, and other issues.

Mean Value Modelling

I looked into other possible methods for simulating internal combustion engine. The basic requirements being: a model that takes current engine RPM and throttle amount as inputs, and calculates output torque. Ideally it should be parameterised to allow for tweakable engine characteristics (giving different torque curves etc.)

Some possibilities included (in order of complexity): lookup tables, mean value modelling (MVM), 1D or multi-D fluid dynamic modelling. After investigation, I chose a basic MVM approach for relative simplicity (for performance and implementation), while still providing more flexibility and realism than a simple lookup table based solution.

This required implementing code for:-

  • CosmeticGas (air) physicsflow rate calculation (choked flow), pressure state equation, etc.
  • CosmeticEngine physicscalculations for: throttle air flow rate, fuel flow rate, volumetric efficiency, thermal efficiency, indicated torque, friction loss torque, and pumping loss torque.
  • A "sim updater" to update the simulation multiple times per fixed update (giving a smaller time step per update). I found this was necessary to improve simulation stability of the throttle air flow and intake manifold pressure.

  • Part behaviours for the engine crank, head, throttle, etc. to calculate their various parts of the simulation.

Parts

I've made a selection of new parts (cranks, cylinders, heads, throttle, etc.) that you can use to build combustion engines.

There are three crank parts (rear, middle, front) that can be assembled together to make a crankshaft. An engine must at least have a rear crank part, as it is the "driven crank" - i.e. it has the part behaviour that actually calculates and applies torque to the crankshaft.

The piston and con-rod are not separate parts in of themselves, but are shown automatically when a cylinder and crank are linked together. They have no associated physics rigidbodies, they're just animated based on the crank angle relative to the cylinder.

You can make pretty much any engine configuration you like!

Sound

I wanted the engine sound to be derived from and recognisable to any given engine configuration. For simplicity, the approach I went with is to play a looped "single cylinder" sound for each of an engine's cylinders, with pitch and volume varied based on RPM and engine load. The audio playback is then synchronised across all the cylinders, with a precise timing offset for each cylinder.

I developed a method for determining timing angle from firing order and crank angle, and then used this to calculate the offset for audio synchronisation. I found the ear is very sensitive to small changes in audio timing, but when the playback is synchronised with the correct offsets, out pops the characteristic sound of a V6, V8, V10, and so on!

The resulting sounds aren't perfect by any means. For example, the sound sample I used could be better, and there are phasing issues with certain engine configurations which can cause the overall sound to be a bit "weak" in lower frequencies. However, I'm generally quite happy with the results, given the low implementation and performance costs.

Source

Steam News / 10 August 2024

Open original