Regression: Hair Particle Edit on model with Mirror Modifier not working properly #107677

Closed
opened 2023-05-06 06:53:05 +02:00 by Mohamad Faisal Amir · 10 comments

System Information
Operating system: Windows 10 Home. 100.19044 Build 19044
Processor: Intel Core i7-8750H
RAM: 16 GB
Graphics card: GTX 1060 6GB

Blender Version
Broken: version: 3.1.0, branch: master, commit date: 2022-03-08 18:16, hash: rBc77597cd0e15
Worked: version: 3.1.0 Beta, branch: master, commit date: 2022-02-20 22:00, hash: rB1a0a22f95a22

Caused by 2fb31f34af

Short description of error
Add hair Particle on Particle Edit mode not working properly on model with Mirror Modifier. The mirrored particle root appear offset too much from expected.
Please check the attached Video and Blend File.

Exact steps for others to reproduce the error

  1. Add any object cube or sphere.
  2. Slice in half.
  3. Add Modifier: Mirror.
  4. Add Particle. type: hair.
    a. Set Emission > Number = 0 to add manually later.
    b. Set Emission > Source > Check USE MODIFIER STACK.
  5. In 3D Viewport change into Particle Edit mode.
  6. Use Add tool.
    a. On the option panel, check Mirror X.
  7. Start add hair particle.

The mirrored particle will appear on the wrong place.
I've tested this on Blender 3.4, 3.2, 3.1 and this behavior also appear.
But it just work fine on Blender 3.0.1 just like on the video

**System Information** Operating system: Windows 10 Home. 100.19044 Build 19044 Processor: Intel Core i7-8750H RAM: 16 GB Graphics card: GTX 1060 6GB **Blender Version** Broken: version: 3.1.0, branch: master, commit date: 2022-03-08 18:16, hash: `rBc77597cd0e15` Worked: version: 3.1.0 Beta, branch: master, commit date: 2022-02-20 22:00, hash: `rB1a0a22f95a22` Caused by 2fb31f34af84c39116742e20a12222099cd0ff9a **Short description of error** Add hair Particle on Particle Edit mode not working properly on model with Mirror Modifier. The mirrored particle root appear offset too much from expected. Please check the attached Video and Blend File. **Exact steps for others to reproduce the error** 1. Add any object cube or sphere. 2. Slice in half. 3. Add Modifier: Mirror. 4. Add Particle. type: hair. a. Set Emission > Number = 0 to add manually later. b. Set Emission > Source > Check USE MODIFIER STACK. 5. In 3D Viewport change into Particle Edit mode. 6. Use Add tool. a. On the option panel, check Mirror X. 7. Start add hair particle. The mirrored particle will appear on the wrong place. I've tested this on Blender 3.4, 3.2, 3.1 and this behavior also appear. But it just work fine on Blender 3.0.1 just like on the video
Mohamad Faisal Amir added the
Priority
Normal
Status
Needs Triage
Type
Report
labels 2023-05-06 06:53:06 +02:00
Iliya Katushenock changed title from Hair Particle Edit on model with Mirror Modifier not working properly to Regression: Hair Particle Edit on model with Mirror Modifier not working properly 2023-05-06 12:57:06 +02:00
Iliya Katushenock added
Priority
High
and removed
Priority
Normal
labels 2023-05-06 16:34:17 +02:00

Most likely this will not be fixed, since soon the old particles will be replaced with curves.

Most likely this will not be fixed, since soon the old particles will be replaced with curves.
Member

Will still check on this

Will still check on this
Member

Caused by 2fb31f34af

We are now calling BKE_mesh_orco_verts_transform not only from psys_face_mat and psys_mat_hair_to_orco, but now also from psys_particle_on_dm > psys_interpolate_face, so we get double transforms with mirror.

But havent thought about this long enough to decide where to call this conditionally (or remove).

Proof of concept though: removing from psys_mat_hair_to_orco seems to work in simple tests:

diff --git a/source/blender/blenkernel/intern/particle.cc b/source/blender/blenkernel/intern/particle.cc
index 0320f98e349..bc5c58f51fe 100644
--- a/source/blender/blenkernel/intern/particle.cc
+++ b/source/blender/blenkernel/intern/particle.cc
@@ -3957,10 +3957,6 @@ void psys_mat_hair_to_orco(
   psys_particle_on_dm(
       mesh, from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, vec, 0, 0, 0, orco);
 
-  /* see psys_face_mat for why this function is called */
-  if (CustomData_get_layer(&mesh->vdata, CD_ORIGINDEX)) {
-    BKE_mesh_orco_verts_transform(static_cast<Mesh *>(ob->data), &orco, 1, 1);
-  }
   copy_v3_v3(hairmat[3], orco);
 }

CC @JacquesLucke
CC @Sergey

Caused by 2fb31f34af84c39116742e20a12222099cd0ff9a We are now calling `BKE_mesh_orco_verts_transform` not only from `psys_face_mat` and `psys_mat_hair_to_orco`, but now also from `psys_particle_on_dm` > `psys_interpolate_face`, so we get double transforms with mirror. But havent thought about this long enough to decide where to call this conditionally (or remove). Proof of concept though: removing from `psys_mat_hair_to_orco` seems to work in simple tests: ```Diff diff --git a/source/blender/blenkernel/intern/particle.cc b/source/blender/blenkernel/intern/particle.cc index 0320f98e349..bc5c58f51fe 100644 --- a/source/blender/blenkernel/intern/particle.cc +++ b/source/blender/blenkernel/intern/particle.cc @@ -3957,10 +3957,6 @@ void psys_mat_hair_to_orco( psys_particle_on_dm( mesh, from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, vec, 0, 0, 0, orco); - /* see psys_face_mat for why this function is called */ - if (CustomData_get_layer(&mesh->vdata, CD_ORIGINDEX)) { - BKE_mesh_orco_verts_transform(static_cast<Mesh *>(ob->data), &orco, 1, 1); - } copy_v3_v3(hairmat[3], orco); } ``` CC @JacquesLucke CC @Sergey
Philipp Oeser removed the
Interest
Sculpt, Paint & Texture
label 2023-05-08 10:48:09 +02:00
Member

The proposed fix of removing these lines sounds reasonable to me. Applying BKE_mesh_orco_verts_transform on the same variable twice does not make sense. I don't see a reason for why this should ever be called conditionally right now.

The proposed fix of removing these lines sounds reasonable to me. Applying `BKE_mesh_orco_verts_transform` on the same variable twice does not make sense. I don't see a reason for why this should ever be called conditionally right now.
Member

The thing I was wondering about is why we even call it multiple times (even with the patch it gets called twice afaict)

The thing I was wondering about is why we even call it multiple times (even with the patch it gets called twice afaict)
Member

Not sure which two calls you mean right now but note that BKE_mesh_orco_verts_transform has an "invert" parameter. So maybe it's called twice to convert the data back and forth?

Not sure which two calls you mean right now but note that `BKE_mesh_orco_verts_transform` has an "invert" parameter. So maybe it's called twice to convert the data back and forth?
Member

Not sure which two calls you mean right now but note that BKE_mesh_orco_verts_transform has an "invert" parameter. So maybe it's called twice to convert the data back and forth?

psys_face_mat and psys_particle_on_dm > psys_interpolate_face both call it inverted, so might be it?

> Not sure which two calls you mean right now but note that `BKE_mesh_orco_verts_transform` has an "invert" parameter. So maybe it's called twice to convert the data back and forth? `psys_face_mat` and `psys_particle_on_dm` > `psys_interpolate_face` both call it inverted, so might be it?
Member

From what I can tell right now, it always gets vectors from orcodata and then calls BKE_mesh_orco_verts_transform (with invert=true). The fact that it is called twice does not matter, because it's not the case that the output of the first call is passed into the second call, I think.

From what I can tell right now, it always gets vectors from `orcodata` and then calls `BKE_mesh_orco_verts_transform` (with `invert=true`). The fact that it is called twice does not matter, because it's not the case that the output of the first call is passed into the second call, I think.
Member

The fact that it is called twice does not matter, because it's not the case that the output of the first call is passed into the second call, I think.

Hm, why does the third call [which the proposed patch removes] cause a double transform then?

> The fact that it is called twice does not matter, because it's not the case that the output of the first call is passed into the second call, I think. Hm, why does the third call [which the proposed patch removes] cause a double transform then?
Member

Hm, why does the third call [which the proposed patch removes] cause a double transform then?

Because both calls to BKE_mesh_orco_verts_transform get the same orco variable passed in afaik.

> Hm, why does the third call [which the proposed patch removes] cause a double transform then? Because both calls to `BKE_mesh_orco_verts_transform` get the same `orco` variable passed in afaik.
Blender Bot added
Status
Resolved
and removed
Status
Confirmed
labels 2023-05-10 15:16:53 +02:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser Project (Legacy)
Interest
Asset System
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
4 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#107677
No description provided.