Objective
Improve the quality of dynamics driven by velocity input.
Design Revisions
Velocity Mapping
Current State: Velocity is clamped to a limit.
Issue: The users input motion velocity is clipped at an arbitrary value. Strokes lack a realistic sense of motion.
Solution: Add a compress_velocity function for logarithmic velocity normalization. Lower speeds are more sensitive, faster motions are compressed rather than clamped, this gives a more natural feel. Also removes a subtle filtering artifact.
Technical Details: Uses a log function, no discernible slowdown on a fast pc.
Visual Comparison:
Without Feature: Left side is a slow to fast stroke, right side has inverted velocity mapping
With Feature: Left side is a slow to fast stroke, right side has inverted velocity mapping
Implementation Details:
Logarithmic Velocity Compression: Introduces a new compression function that maps raw velocities to a compressed range using a logarithmic scale. Enhances sensitivity for low velocities, allowing for finer control during slow movements. Prevents compressed velocities from saturating too quickly at high raw velocities, ensuring a smooth transition across the velocity spectrum.
Improved Smoothing Mechanism: Utilizes a consistent exponential smoothing factor in the velocity calculations. Provides stable and smooth transitions by reducing abrupt changes in velocity. Ensures the smoothed velocity is correctly maintained for accurate computations in subsequent events.
Optimizations and Refactoring: Adds precomputed constants for logarithmic calculations to optimize performance. Refactors code to correctly update
buffer->last_coords.velocity
after assignments to prevent unintended overwrites. Includes detailed comments explaining the purpose of constants likeV_MAX
,k
, andV_THRESHOLD
, aiding future maintenance and readability.
Benefits: These enhancements result in more responsive and natural tool dynamics within GIMP’s drawing tools, offering users improved control and a better overall experience when interacting with dynamic brushes and other velocity-dependent features.