[Bf-blender-cvs] [3d6e7cd67c2] blender-v2.82-release: Fix Cycles particle hair rendering broken after recent changes

Brecht Van Lommel noreply at git.blender.org
Mon Feb 3 18:36:01 CET 2020


Commit: 3d6e7cd67c2dac8acbce585efed2fa34341f2676
Author: Brecht Van Lommel
Date:   Mon Feb 3 17:40:03 2020 +0100
Branches: blender-v2.82-release
https://developer.blender.org/rB3d6e7cd67c2dac8acbce585efed2fa34341f2676

Fix Cycles particle hair rendering broken after recent changes

This code was already wrong, we were just lucky that the previous coordinate
was repeated due to using the same memory location.

===================================================================

M	intern/cycles/blender/blender_curves.cpp
M	source/blender/makesrna/intern/rna_particle.c

===================================================================

diff --git a/intern/cycles/blender/blender_curves.cpp b/intern/cycles/blender/blender_curves.cpp
index 4dba8ffbe0e..78db1d5c832 100644
--- a/intern/cycles/blender/blender_curves.cpp
+++ b/intern/cycles/blender/blender_curves.cpp
@@ -173,19 +173,20 @@ static bool ObtainCacheParticleData(
           CData->curve_firstkey.push_back_slow(keyno);
 
           float curve_length = 0.0f;
-          float3 pcKey;
+          float3 prev_co_world = make_float3(0.0f, 0.0f, 0.0f);
+          float3 prev_co_object = make_float3(0.0f, 0.0f, 0.0f);
           for (int step_no = 0; step_no < ren_step; step_no++) {
-            float nco[3];
-            b_psys.co_hair(*b_ob, pa_no, step_no, nco);
-            float3 cKey = make_float3(nco[0], nco[1], nco[2]);
-            cKey = transform_point(&itfm, cKey);
+            float3 co_world = prev_co_world;
+            b_psys.co_hair(*b_ob, pa_no, step_no, &co_world.x);
+            float3 co_object = transform_point(&itfm, co_world);
             if (step_no > 0) {
-              const float step_length = len(cKey - pcKey);
+              const float step_length = len(co_object - prev_co_object);
               curve_length += step_length;
             }
-            CData->curvekey_co.push_back_slow(cKey);
+            CData->curvekey_co.push_back_slow(co_object);
             CData->curvekey_time.push_back_slow(curve_length);
-            pcKey = cKey;
+            prev_co_object = co_object;
+            prev_co_world = co_world;
             keynum++;
           }
           keyno += keynum;
diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c
index 36320be9270..a5852a30661 100644
--- a/source/blender/makesrna/intern/rna_particle.c
+++ b/source/blender/makesrna/intern/rna_particle.c
@@ -400,7 +400,6 @@ static void rna_ParticleSystem_co_hair(
     }
   }
   else {
-    zero_v3(n_co);
     return;
   }
 
@@ -410,9 +409,6 @@ static void rna_ParticleSystem_co_hair(
     mul_m4_v3(particlesystem->imat, n_co);
     mul_m4_v3(object->obmat, n_co);
   }
-  else {
-    zero_v3(n_co);
-  }
 }
 
 static const EnumPropertyItem *rna_Particle_Material_itemf(bContext *C,



More information about the Bf-blender-cvs mailing list