Fix for NaN values resulting from curve editing with collision #105499

Merged
Lukas Tönne merged 2 commits from LukasTonne/blender:fix_curve_collision_nans into main 2023-03-07 11:05:17 +01:00
Member

This was caused by an incorrect assumption in the solver:
It tries to solve both collision and length constraints simultaneously,
using the projected movement of a point as a slide direction along the surface.
This only works if the distance of the previous curve point to the surface
is less than the allowed segment length. Otherwise the segment will
exceed the allowed length even with zero slide and NaN values are computed.

The case of larger surface distance can occur if the previous segment
solve was already stretching the current segment and then the point
moves further away. In this case we can simply clamp the segment length
without violating the contact constraint.

Fixes #105467

This was caused by an incorrect assumption in the solver: It tries to solve both collision and length constraints simultaneously, using the projected movement of a point as a slide direction along the surface. This only works if the distance of the previous curve point to the surface is less than the allowed segment length. Otherwise the segment will exceed the allowed length even with zero slide and NaN values are computed. The case of larger surface distance can occur if the previous segment solve was already stretching the current segment and then the point moves further away. In this case we can simply clamp the segment length without violating the contact constraint. Fixes #105467
Lukas Tönne added 1 commit 2023-03-06 17:36:59 +01:00
f70123e81e Fix for NaN values resulting from curve editing with collision
This was caused by an incorrect assumption in the solver:
It tries to solve both collision and length constraints simultaneously,
using the projected movement of a point as a slide direction along the surface.
This only works if the distance of the previous curve point to the surface
is less than the allowed segment length. Otherwise the segment will
exceed the allowed length even with zero slide and NaN values are computed.

The case of larger surface distance can occur if the previous segment
solve was already stretching the current segment and then the point
moves further away. In this case we can simply clamp the segment length
without violating the contact constraint.
Lukas Tönne requested review from Jacques Lucke 2023-03-06 17:37:34 +01:00
Lukas Tönne requested review from Hans Goudey 2023-03-06 17:37:34 +01:00
Lukas Tönne added this to the Nodes & Physics project 2023-03-06 17:37:46 +01:00
Jacques Lucke approved these changes 2023-03-07 10:30:21 +01:00
Jacques Lucke left a comment
Member

Thanks for catching that!

Thanks for catching that!
@ -152,3 +149,1 @@
math::length_squared(slide_normal_cu)) -
slide_direction_length_cu;
positions_cu[point_i] = plane_pos_cu + normalized_slide_direction_cu * slide_distance_cu;
const float slide_normal_length_cu = math::length_squared(slide_normal_cu);
Member

The name here should contain sq for squared.

The name here should contain `sq` for `squared`.
LukasTonne marked this conversation as resolved
Lukas Tönne added 1 commit 2023-03-07 11:03:37 +01:00
Lukas Tönne merged commit 98b56aadec into main 2023-03-07 11:05:17 +01:00
Lukas Tönne deleted branch fix_curve_collision_nans 2023-03-07 11:05:18 +01:00
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#105499
No description provided.