Commit: 7500737fbece242067c71a1ec7b4e8fe01303e0c
Author: Lukas Toenne
Date:   Fri Oct 26 07:56:16 2018 +0100
Branches: hair_object
https://developer.blender.org/rB7500737fbece242067c71a1ec7b4e8fe01303e0c

Merge branch 'blender2.8' into hair_object

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



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

diff --cc build_files/cmake/macros.cmake
index d825e522409,9d679dc9b8f..00ad032a157
--- a/build_files/cmake/macros.cmake
+++ b/build_files/cmake/macros.cmake
@@@ -616,7 -615,7 +615,8 @@@ function(SETUP_BLENDER_SORTED_LIBS
                bf_editor_datafiles
                bf_editor_mask
                bf_editor_io
+               bf_editor_util
 +              bf_editor_hair
  
                bf_render
                bf_python
diff --cc intern/cycles/blender/blender_curves.cpp
index b6ea9ee0a2c,5e4522af6e1..0baf2a2f425
--- a/intern/cycles/blender/blender_curves.cpp
+++ b/intern/cycles/blender/blender_curves.cpp
@@@ -124,326 -125,139 +124,326 @@@ static void ObtainCacheDataFromParticle
        Transform tfm = get_transform(b_ob->matrix_world());
        Transform itfm = transform_quick_inverse(tfm);
  
 -      BL::Object::modifiers_iterator b_mod;
 -      for(b_ob->modifiers.begin(b_mod); b_mod != b_ob->modifiers.end(); 
++b_mod) {
 -              if((b_mod->type() == b_mod->type_PARTICLE_SYSTEM) && 
(background ? b_mod->show_render() : b_mod->show_viewport())) {
 -                      BL::ParticleSystemModifier psmd((const 
PointerRNA)b_mod->ptr);
 -                      BL::ParticleSystem b_psys((const 
PointerRNA)psmd.particle_system().ptr);
 -                      BL::ParticleSettings b_part((const 
PointerRNA)b_psys.settings().ptr);
 -
 -                      if((b_part.render_type() == 
BL::ParticleSettings::render_type_PATH) && (b_part.type() == 
BL::ParticleSettings::type_HAIR)) {
 -                              int shader = clamp(b_part.material()-1, 0, 
mesh->used_shaders.size()-1);
 -                              int display_step = background ? 
b_part.render_step() : b_part.display_step();
 -                              int totparts = b_psys.particles.length();
 -                              int totchild = background ? 
b_psys.child_particles.length() : (int)((float)b_psys.child_particles.length() 
* (float)b_part.display_percentage() / 100.0f);
 -                              int totcurves = totchild;
 -
 -                              if(b_part.child_type() == 0 || totchild == 0)
 -                                      totcurves += totparts;
 -
 -                              if(totcurves == 0)
 +      if((b_part.type() != BL::ParticleSettings::type_HAIR) ||
 +         (b_part.render_type() != BL::ParticleSettings::render_type_PATH))
 +      {
 +              return;
 +      }
 +      
 +      int shader = clamp(b_part.material()-1, 0, mesh->used_shaders.size()-1);
-       int draw_step = background ? b_part.render_step() : b_part.draw_step();
++      int display_step = background ? b_part.render_step() : 
b_part.display_step();
 +      int totparts = b_psys.particles.length();
-       int totchild = background ? b_psys.child_particles.length() : 
(int)((float)b_psys.child_particles.length() * (float)b_part.draw_percentage() 
/ 100.0f);
++      int totchild = background ? b_psys.child_particles.length() : 
(int)((float)b_psys.child_particles.length() * 
(float)b_part.display_percentage() / 100.0f);
 +      int totcurves = totchild;
 +      
 +      if(b_part.child_type() == 0 || totchild == 0)
 +              totcurves += totparts;
 +      
 +      if(totcurves == 0)
 +              return;
 +      
-       int ren_step = (1 << draw_step) + 1;
++      int ren_step = (1 << display_step) + 1;
 +      if(b_part.kink() == BL::ParticleSettings::kink_SPIRAL)
 +              ren_step += b_part.kink_extra_steps();
 +      
 +      CData->psys_firstcurve.push_back_slow(*curvenum);
 +      CData->psys_curvenum.push_back_slow(totcurves);
 +      CData->psys_shader.push_back_slow(shader);
 +      
 +      float radius = b_part.radius_scale() * 0.5f;
 +      
 +      CData->psys_rootradius.push_back_slow(radius * b_part.root_radius());
 +      CData->psys_tipradius.push_back_slow(radius * b_part.tip_radius());
 +      CData->psys_shape.push_back_slow(b_part.shape());
 +      CData->psys_closetip.push_back_slow(b_part.use_close_tip());
 +      
 +      int pa_no = 0;
 +      if(!(b_part.child_type() == 0) && totchild != 0)
 +              pa_no = totparts;
 +      
 +      int num_add = (totparts+totchild - pa_no);
 +      CData->curve_firstkey.reserve(CData->curve_firstkey.size() + num_add);
 +      CData->curve_keynum.reserve(CData->curve_keynum.size() + num_add);
 +      CData->curve_length.reserve(CData->curve_length.size() + num_add);
 +      CData->curvekey_co.reserve(CData->curvekey_co.size() + 
num_add*ren_step);
 +      CData->curvekey_time.reserve(CData->curvekey_time.size() + 
num_add*ren_step);
 +      
 +      for(; pa_no < totparts+totchild; pa_no++) {
 +              int keynum = 0;
 +              CData->curve_firstkey.push_back_slow(*keyno);
 +              
 +              float curve_length = 0.0f;
 +              float3 pcKey;
 +              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);
 +                      if(step_no > 0) {
 +                              float step_length = len(cKey - pcKey);
 +                              if(step_length == 0.0f)
                                        continue;
 -
 -                              int ren_step = (1 << display_step) + 1;
 -                              if(b_part.kink() == 
BL::ParticleSettings::kink_SPIRAL)
 -                                      ren_step += b_part.kink_extra_steps();
 -
 -                              CData->psys_firstcurve.push_back_slow(curvenum);
 -                              CData->psys_curvenum.push_back_slow(totcurves);
 -                              CData->psys_shader.push_back_slow(shader);
 -
 -                              float radius = b_part.radius_scale() * 0.5f;
 -
 -                              CData->psys_rootradius.push_back_slow(radius * 
b_part.root_radius());
 -                              CData->psys_tipradius.push_back_slow(radius * 
b_part.tip_radius());
 -                              
CData->psys_shape.push_back_slow(b_part.shape());
 -                              
CData->psys_closetip.push_back_slow(b_part.use_close_tip());
 -
 -                              int pa_no = 0;
 -                              if(!(b_part.child_type() == 0) && totchild != 0)
 -                                      pa_no = totparts;
 -
 -                              int num_add = (totparts+totchild - pa_no);
 -                              
CData->curve_firstkey.reserve(CData->curve_firstkey.size() + num_add);
 -                              
CData->curve_keynum.reserve(CData->curve_keynum.size() + num_add);
 -                              
CData->curve_length.reserve(CData->curve_length.size() + num_add);
 -                              
CData->curvekey_co.reserve(CData->curvekey_co.size() + num_add*ren_step);
 -                              
CData->curvekey_time.reserve(CData->curvekey_time.size() + num_add*ren_step);
 -
 -                              for(; pa_no < totparts+totchild; pa_no++) {
 -                                      int keynum = 0;
 -                                      
CData->curve_firstkey.push_back_slow(keyno);
 -
 -                                      float curve_length = 0.0f;
 -                                      float3 pcKey;
 -                                      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);
 -                                              if(step_no > 0) {
 -                                                      float step_length = 
len(cKey - pcKey);
 -                                                      if(step_length == 0.0f)
 -                                                              continue;
 -                                                      curve_length += 
step_length;
 -                                              }
 -                                              
CData->curvekey_co.push_back_slow(cKey);
 -                                              
CData->curvekey_time.push_back_slow(curve_length);
 -                                              pcKey = cKey;
 -                                              keynum++;
 -                                      }
 -                                      keyno += keynum;
 -
 -                                      
CData->curve_keynum.push_back_slow(keynum);
 -                                      
CData->curve_length.push_back_slow(curve_length);
 -                                      curvenum++;
 -                              }
 +                              curve_length += step_length;
                        }
 +                      CData->curvekey_co.push_back_slow(cKey);
 +                      CData->curvekey_time.push_back_slow(curve_length);
 +                      pcKey = cKey;
 +                      keynum++;
                }
 +              *keyno += keynum;
 +              
 +              CData->curve_keynum.push_back_slow(keynum);
 +              CData->curve_length.push_back_slow(curve_length);
 +              (*curvenum)++;
        }
 -
 -      return true;
  }
  
 -static bool ObtainCacheParticleUV(Mesh *mesh,
 -                                  BL::Mesh *b_mesh,
 -                                  BL::Object *b_ob,
 -                                  ParticleCurveData *CData,
 -                                  bool background,
 -                                  int uv_num)
 +static void ObtainCacheUVFromParticleSystem(BL::Mesh *b_mesh,
 +                                            BL::ParticleSystemModifier 
*b_psmd,
 +                                            ParticleCurveData *CData,
 +                                            bool background,
 +                                            int uv_num)
  {
 -      if(!(mesh && b_mesh && b_ob && CData))
 -              return false;
 +      BL::ParticleSystem b_psys((const 
PointerRNA)b_psmd->particle_system().ptr);
 +      BL::ParticleSettings b_part((const PointerRNA)b_psys.settings().ptr);
  
 -      CData->curve_uv.clear();
 +      if((b_part.type() != BL::ParticleSettings::type_HAIR) ||
 +         (b_part.render_type() != BL::ParticleSettings::render_type_PATH))
 +      {
 +              return;
 +      }
  
 -      BL::Object::modifiers_iterator b_mod;
 -      for(b_ob->modifiers.begin(b_mod); b_mod != b_ob->modifiers.end(); 
++b_mod) {
 -              if((b_mod->type() == b_mod->type_PARTICLE_SYSTEM) && 
(background ? b_mod->show_render() : b_mod->show_viewport())) {
 -                      BL::ParticleSystemModifier psmd((const 
PointerRNA)b_mod->ptr);
 -                      BL::ParticleSystem b_psys((const 
PointerRNA)psmd.particle_system().ptr);
 -                      BL::ParticleSettings b_part((const 
PointerRNA)b_psys.settings().ptr);
 +      int totparts = b_psys.particles.length();
-       int totchild = background ? b_psys.child_particles.length() : 
(int)((float)b_psys.child_particles.length() * (float)b_part.draw_percentage() 
/ 100.0f);
++      int totchild = background ? b_psys.child_particles.length() : 
(int)((float)b_psys.child_particles.length() * 
(float)b_part.display_percentage() / 100.0f);
 +      int totcurves = totchild;
 +      
 +      if(b_part.child_type() == 0 || totchild == 0)
 +              totcurves += totparts;
 +      
 +      if(totcurves == 0)
 +              return;
 +      
 +      int pa_no = 0;
 +      if(!(b_part.child_type() == 0) && totchild != 0)
 +              pa_no = totparts;
 +      
 +      int num_add = (totparts+totchild - pa_no);
 +      CData->curve_uv.reserve(CData->curve_uv.size() + num_add);
 +      
 +      BL::ParticleSystem::particles_iterator b_pa;
 +      b_psys.particles.begin(b_pa);
 +      for(; pa_no < totparts+totchild; pa_no++) {
 +              /* Add UVs */
-               BL::Mesh::tessface_uv_textures_iterator l;
-               b_mesh->tessface_uv_textures.begin(l);
++              BL::Mesh::uv_layers_iterator l;
++              b_mesh->uv_layers.begin(l);
 +              
 +              float3 uv = make_float3(0.0f, 0.0f, 0.0f);
-               if(b_mesh->tessface_uv_textures.length())
++              if(b_mesh->uv_layers.length())
 +                      b_psys.uv_on_emitter(*b_psmd, *b_pa, pa_no, uv_num, 
&uv.x);
 +              CData->curve_uv.push_back_slow(uv);
 +              
 +              if(pa_no < totparts && b_pa != b_psys.particles.end())
 +                      ++b_pa;
 +      }
 +}
  
 -                      if((b_part.render_type() == 
BL::ParticleSettings::render_type_PATH) && (b_part.type() == 
BL::ParticleSettings::type_HAIR)) {
 -                              int totparts = b_psys.particles.length();
 -                              int totchild = background ? 
b_psys.child_particles.length() : (int)((float)b_psys.child_particles.length() 
* (float)b_part.display_percentage() / 100.0f);
 -                              int totcurves = totchild;
 +static void ObtainCacheVColFromParticleSystem(BL::Mesh *b_mesh,
 +                                  

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to