Refactor: Remove pre-2.8 function to reevaluate a single object #106186

Merged
Hans Goudey merged 6 commits from HooglyBoogly/blender:fix-remove-broken-reevaluate-mesh into main 2023-05-30 22:25:12 +02:00
Member

This function replaced the evaluated mesh with a new one with the given
custom data type mask. That doesn't work in general anymore for a few
reasons: the increased dependence on named attributes (a opposed to
custom data types), and the "all or nothing" approach to reevaluating
the depsgraph. Other objects might depend on the object's evaluated
geometry, so it shouldn't just be replaced. Pushed a bit further, this could
give nice simplifications to mesh modifier evaluation.

There are two breaking changes, bmesh_from_object and BVH tree
FromObject require the source object to have a proper evaluated
mesh now.

If this causes a regression, it's likely that the object is missing
an update tag when a mode is entered that requires extra evaluated data.

This function replaced the evaluated mesh with a new one with the given custom data type mask. That doesn't work in general anymore for a few reasons: the increased dependence on named attributes (a opposed to custom data types), and the "all or nothing" approach to reevaluating the depsgraph. Other objects might depend on the object's evaluated geometry, so it shouldn't just be replaced. Pushed a bit further, this could give nice simplifications to mesh modifier evaluation. There are two breaking changes, `bmesh_from_object` and BVH tree `FromObject` require the source object to have a proper evaluated mesh now. If this causes a regression, it's likely that the object is missing an update tag when a mode is entered that requires extra evaluated data.
Hans Goudey added 1 commit 2023-03-27 18:32:36 +02:00
5d51e5f0ca Fix: Remove pre-2.8 function to reevaluate a single object
This function replaced the evaluated mesh with a new one with the given
custom data type mask. That doesn't work in general anymore for a few
reasons: the increased dependence on named attributes (a opposed to
custom data types), and the "all or nothing" approach to reevaluating
the depsgraph. Other objects might depend on the object's evaluated
geometry, so it shouldn't just be replaced.

If this causes a regression, it's likely that the object is missing
an update tag when a mode is entered that requires extra evaluated data.

Fixes #105912
Hans Goudey requested review from Brecht Van Lommel 2023-03-27 18:33:16 +02:00
Hans Goudey added this to the Core project 2023-03-27 18:33:23 +02:00
Brecht Van Lommel requested changes 2023-03-27 19:14:56 +02:00
@ -1354,2 +1353,2 @@
Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
Object *ob_src_eval = DEG_get_evaluated_object(depsgraph, ob_src);
const Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob_src);
const Mesh *me_eval = BKE_object_get_evaluated_mesh(ob_eval);

Here I don't think we can assume the existence of depsgraph, ob_eval or me_eval. I think they could be NULL for objects that are hidden or part of another scene, and crash.

Using context and the depsgraph here at all is dodgy, but that's not something to solve as part of this.

There's probably more cases like this where the object may not have been evaluated, but I didn't have time today to check them all. Probably best to be extra careful and add null pointer checks in various places.

Here I don't think we can assume the existence of `depsgraph`, `ob_eval` or `me_eval`. I think they could be NULL for objects that are hidden or part of another scene, and crash. Using context and the depsgraph here at all is dodgy, but that's not something to solve as part of this. There's probably more cases like this where the object may not have been evaluated, but I didn't have time today to check them all. Probably best to be extra careful and add null pointer checks in various places.
HooglyBoogly marked this conversation as resolved
@ -1133,3 +1134,3 @@
}
else {
me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_eval, &data_masks);
me_eval = BKE_object_get_evaluated_mesh(ob_eval);

This could be a breaking change, it's conceivable a script calls this for a hidden object.

Maybe best to postpone changing this one.

This could be a breaking change, it's conceivable a script calls this for a hidden object. Maybe best to postpone changing this one.
@ -1048,3 +1049,3 @@
}
return mesh_get_eval_final(depsgraph, scene, ob_eval, &data_masks);
return BKE_object_get_evaluated_mesh(ob_eval);

Same here, could be a breaking change.

Same here, could be a breaking change.
Author
Member

Thanks for looking at this. I think I'll postpone the change until 4.0 so that we can be more liberal about requiring an evaluated depsgraph for certain Python functions. It would also allow going a bit further too, I think there are other similar functions that could be removed as well.

Thanks for looking at this. I think I'll postpone the change until 4.0 so that we can be more liberal about requiring an evaluated depsgraph for certain Python functions. It would also allow going a bit further too, I think there are other similar functions that could be removed as well.
Hans Goudey changed title from Fix: Remove pre-2.8 function to reevaluate a single object to WIP: Fix: Remove pre-2.8 function to reevaluate a single object 2023-03-31 14:14:16 +02:00
Hans Goudey changed title from WIP: Fix: Remove pre-2.8 function to reevaluate a single object to WIP: Refactor: Remove pre-2.8 function to reevaluate a single object 2023-03-31 14:14:25 +02:00
Hans Goudey added 4 commits 2023-05-26 22:45:37 +02:00
Hans Goudey changed title from WIP: Refactor: Remove pre-2.8 function to reevaluate a single object to Refactor: Remove pre-2.8 function to reevaluate a single object 2023-05-26 22:46:33 +02:00
Hans Goudey requested review from Brecht Van Lommel 2023-05-26 22:48:59 +02:00
Author
Member

@blender-bot build

@blender-bot build
Author
Member

It looks to me like more functions have the same problem:

  • mesh_get_eval_deform
  • mesh_create_eval_final
  • mesh_create_eval_no_deform
  • mesh_create_eval_no_deform_render
  • editbmesh_get_eval_cage
  • editbmesh_get_eval_cage_from_orig

I guess they can be removed in separate steps.

It looks to me like more functions have the same problem: - `mesh_get_eval_deform` - `mesh_create_eval_final` - `mesh_create_eval_no_deform` - `mesh_create_eval_no_deform_render` - `editbmesh_get_eval_cage` - `editbmesh_get_eval_cage_from_orig` I guess they can be removed in separate steps.
Brecht Van Lommel approved these changes 2023-05-30 14:29:39 +02:00
Hans Goudey added 1 commit 2023-05-30 21:27:38 +02:00
Author
Member

@blender-bot build windows

@blender-bot build windows
Hans Goudey merged commit e64b3c8212 into main 2023-05-30 22:25:12 +02:00
Hans Goudey deleted branch fix-remove-broken-reevaluate-mesh 2023-05-30 22:25:13 +02:00
Bastien Montagne removed this from the Core project 2023-07-03 12:47:12 +02: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 project
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#106186
No description provided.