Game Development 5 min read

Resolving Mass‑Volume Discrepancy in 2D Physics Engines

This article analyzes the inconsistency between 2D physics engine mass calculations (mass = density × area) and real‑world physics (mass = density × volume), proposes measurement methods for volume, density, and mass, and presents three implementation strategies for correcting the discrepancy in nape and box2d engines.

New Oriental Technology
New Oriental Technology
New Oriental Technology
Resolving Mass‑Volume Discrepancy in 2D Physics Engines

In 2D physics simulations the engine computes mass as density multiplied by area, whereas in the real world mass equals density multiplied by volume, leading to a mismatch that can affect educational experiments.

The article outlines how users can experimentally determine volume (by dividing mass by density, measuring diameter, or using water displacement), density (by reference tables, mass/volume, or water displacement), and mass (via density × volume, Hooke's law devices, balances, or collision tests).

Three solution methods are proposed:

Method 1: Keep user‑defined mass enabled, ensure density is correct, and adjust the measured volume by adding a volumeScale factor in nape’s FluidProperties and the pre‑step calculation; box2d can be modified similarly.

Method 2: Disable user‑defined mass, keep density correct, and modify the mass calculation; this is impractical for nape but feasible for box2d by overriding the ComputeMass method of shape subclasses.

Method 3: Disable user‑defined mass and do not enforce correct density, instead ensure the relation ρ = m / S holds; this requires adjusting both the intersected area for buoyancy and setting two densities for the fluid (one for mass, one for buoyancy). nape supports this via separate density settings, while box2d would need an additional parameter.

The conclusion notes that although the problem seemed unsolvable without a 3D model, practical fixes are relatively simple, though edge cases such as partial immersion and fluid‑fluid buoyancy still need verification.

2D simulationbox2dmass densitynapephysics enginevolume correction
New Oriental Technology
Written by

New Oriental Technology

Practical internet development experience, tech sharing, knowledge consolidation, and forward-thinking insights.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.