Cleanup: Sculpt, use C++ vector types in internal types #114636

Merged
Sergey Sharybin merged 2 commits from Sergey/blender:sculpt_cpp_vector_types into main 2023-11-09 10:05:32 +01:00

Only converted value types in the structures.

The pointer values are left unchanged as it requires more careful look
to avoid possible alignment mismatch.

Function arguments are left unchanged as well.

Only float[3] is converted as the float[4] will likely need to be
converted to some C++ rotation class. And float[4][4] often did not
compile when change is only done in the header.

Only converted value types in the structures. The pointer values are left unchanged as it requires more careful look to avoid possible alignment mismatch. Function arguments are left unchanged as well. Only float[3] is converted as the float[4] will likely need to be converted to some C++ rotation class. And float[4][4] often did not compile when change is only done in the header.
Sergey Sharybin added 1 commit 2023-11-08 17:03:50 +01:00
95c2b28157 Cleanup: Sculpt, use C++ vector types in internal types
Only converted value types in the structures.

The pointer values are left unchanged as it requires more careful look
to avoid possible alignment mismatch.

Function arguments are left unchanged as well.

Only float[3] is converted as the float[4] will likely need to be
converted to some C++ rotation class. And float[4][4] often did not
compile when change is only done in the header.
Sergey Sharybin requested review from Hans Goudey 2023-11-08 17:03:55 +01:00
Author
Owner

Unfortunately, there seems to be some artifacts caused by this change. It is a bit hard to reproduce. But is just some quick strokes with a Draw brush.
Investigating it, but if someone sees an obvious issue please let me know :)

P.S. And this time I am more sure it is the source of the artifacts.

Unfortunately, there seems to be some artifacts caused by this change. It is a bit hard to reproduce. But is just some quick strokes with a Draw brush. Investigating it, but if someone sees an obvious issue please let me know :) P.S. And this time I am more sure it is the source of the artifacts.
Sergey Sharybin added 1 commit 2023-11-08 18:07:14 +01:00
buildbot/vexp-code-patch-coordinator Build done. Details
c80db67bf3
Fix incorrect behavior and bad memory access introduced with the refactor
At least one of the issues was the following code in SCULPT_search_sphere():
  center = data->ss->cache ? data->ss->cache->location : data->ss->cursor_location;

The `location` and `cursor_location` had different type, which is not how the ternary operator could work in this case, so the cursor_location got implicitly converted from float[3] to float3, and then to a pointer.
This lead to center being assigned to a pointer of a temporary object.

Not sure how to fully guard about such error automatically. Solution is to convert even more float[3] to float3.

@Sergey : MSVC (for 95c2b28157)

F:\Blender_build\first\blender\source\blender\editors\sculpt_paint\sculpt.cc(2181): error C2445: result type of conditional expression is ambiguous: types 'blender::float3' and 'float [3]' can be converted to multiple common types
F:\Blender_build\first\blender\source\blender\editors\sculpt_paint\sculpt.cc(2181): note: could be 'blender::float3'
F:\Blender_build\first\blender\source\blender\editors\sculpt_paint\sculpt.cc(2181): note: or       'float *'
F:\Blender_build\first\blender\source\blender\editors\sculpt_paint\sculpt.cc(2721): error C2445: result type of conditional expression is ambiguous: types 'blender::float3' and 'float [3]' can be converted to multiple common types
F:\Blender_build\first\blender\source\blender\editors\sculpt_paint\sculpt.cc(2721): note: could be 'blender::float3'
F:\Blender_build\first\blender\source\blender\editors\sculpt_paint\sculpt.cc(2721): note: or       'float *'
[25/33] Building CXX object source\blender\editors\sculpt_paint\CMakeFiles\bf_editor_sculpt_paint.dir\sculpt_ops.cc.obj
@Sergey : MSVC (for 95c2b28157) ``` F:\Blender_build\first\blender\source\blender\editors\sculpt_paint\sculpt.cc(2181): error C2445: result type of conditional expression is ambiguous: types 'blender::float3' and 'float [3]' can be converted to multiple common types F:\Blender_build\first\blender\source\blender\editors\sculpt_paint\sculpt.cc(2181): note: could be 'blender::float3' F:\Blender_build\first\blender\source\blender\editors\sculpt_paint\sculpt.cc(2181): note: or 'float *' F:\Blender_build\first\blender\source\blender\editors\sculpt_paint\sculpt.cc(2721): error C2445: result type of conditional expression is ambiguous: types 'blender::float3' and 'float [3]' can be converted to multiple common types F:\Blender_build\first\blender\source\blender\editors\sculpt_paint\sculpt.cc(2721): note: could be 'blender::float3' F:\Blender_build\first\blender\source\blender\editors\sculpt_paint\sculpt.cc(2721): note: or 'float *' [25/33] Building CXX object source\blender\editors\sculpt_paint\CMakeFiles\bf_editor_sculpt_paint.dir\sculpt_ops.cc.obj ```
Hans Goudey approved these changes 2023-11-08 22:30:20 +01:00
Hans Goudey left a comment
Member

Looking through the code, definitely much nicer this way!

Looking through the code, definitely much nicer this way!
Author
Owner

@blender-bot build

@blender-bot build
Author
Owner

@mod_moder That was fixed with later update.
The build is completed, and no new warnings added. I think it is safe to land.

@mod_moder That was fixed with later update. The build is completed, and no new warnings added. I think it is safe to land.
Sergey Sharybin merged commit c3609ec435 into main 2023-11-09 10:05:32 +01:00
Sergey Sharybin deleted branch sculpt_cpp_vector_types 2023-11-09 10:05:34 +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 project
No Assignees
3 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#114636
No description provided.