Commit: 386c77817321f48fb661f617a0b38e9753e9d156
Author: Sergey Sharybin
Date:   Thu Jun 9 12:50:55 2016 +0200
Branches: cycles_hair_bvh
https://developer.blender.org/rB386c77817321f48fb661f617a0b38e9753e9d156

Merge branch 'master' into cycles_hair_bvh

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



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

diff --cc intern/cycles/bvh/bvh_build.cpp
index 1c6a778,3f68722..d774096
--- a/intern/cycles/bvh/bvh_build.cpp
+++ b/intern/cycles/bvh/bvh_build.cpp
@@@ -114,72 -112,70 +114,74 @@@ BVHBuild::~BVHBuild(
  
  void BVHBuild::add_reference_mesh(BoundBox& root, BoundBox& center, Mesh 
*mesh, int i)
  {
 -      Attribute *attr_mP = NULL;
 -      
 -      if(mesh->has_motion_blur())
 -              attr_mP = 
mesh->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
 +      if(params.primitive_mask & PRIMITIVE_ALL_TRIANGLE) {
 +              Attribute *attr_mP = NULL;
  
 -      size_t num_triangles = mesh->num_triangles();
 -      for(uint j = 0; j < num_triangles; j++) {
 -              Mesh::Triangle t = mesh->get_triangle(j);
 -              BoundBox bounds = BoundBox::empty;
 -              PrimitiveType type = PRIMITIVE_TRIANGLE;
 +              if(mesh->has_motion_blur())
 +                      attr_mP = 
mesh->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
  
-               for(uint j = 0; j < mesh->triangles.size(); j++) {
-                       Mesh::Triangle t = mesh->triangles[j];
 -              t.bounds_grow(&mesh->verts[0], bounds);
++              size_t num_triangles = mesh->num_triangles();
++              for(uint j = 0; j < num_triangles; j++) {
++                      Mesh::Triangle t = mesh->get_triangle(j);
 +                      BoundBox bounds = BoundBox::empty;
 +                      PrimitiveType type = PRIMITIVE_TRIANGLE;
  
 -              /* motion triangles */
 -              if(attr_mP) {
 -                      size_t mesh_size = mesh->verts.size();
 -                      size_t steps = mesh->motion_steps - 1;
 -                      float3 *vert_steps = attr_mP->data_float3();
 +                      t.bounds_grow(&mesh->verts[0], bounds);
  
 -                      for(size_t i = 0; i < steps; i++)
 -                              t.bounds_grow(vert_steps + i*mesh_size, bounds);
 +                      /* motion triangles */
 +                      if(attr_mP) {
 +                              size_t mesh_size = mesh->verts.size();
 +                              size_t steps = mesh->motion_steps - 1;
 +                              float3 *vert_steps = attr_mP->data_float3();
  
 -                      type = PRIMITIVE_MOTION_TRIANGLE;
 -              }
 +                              for(size_t i = 0; i < steps; i++)
 +                                      t.bounds_grow(vert_steps + i*mesh_size, 
bounds);
 +
 +                              type = PRIMITIVE_MOTION_TRIANGLE;
 +                      }
  
 -              if(bounds.valid()) {
 -                      references.push_back(BVHReference(bounds, j, i, type));
 -                      root.grow(bounds);
 -                      center.grow(bounds.center2());
 +                      if(bounds.valid()) {
 +                              references.push_back(BVHReference(bounds, j, i, 
type));
 +                              root.grow(bounds);
 +                              center.grow(bounds.center2());
 +                      }
                }
        }
  
 -      Attribute *curve_attr_mP = NULL;
 +      if(params.primitive_mask & PRIMITIVE_ALL_CURVE) {
 +              Attribute *curve_attr_mP = NULL;
  
 -      if(mesh->has_motion_blur())
 -              curve_attr_mP = 
mesh->curve_attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
 +              if(mesh->has_motion_blur())
 +                      curve_attr_mP = 
mesh->curve_attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
  
-               for(uint j = 0; j < mesh->curves.size(); j++) {
-                       Mesh::Curve curve = mesh->curves[j];
 -      size_t num_curves = mesh->num_curves();
 -      for(uint j = 0; j < num_curves; j++) {
 -              Mesh::Curve curve = mesh->get_curve(j);
 -              PrimitiveType type = PRIMITIVE_CURVE;
++              size_t num_curves = mesh->num_curves();
++              for(uint j = 0; j < num_curves; j++) {
++                      Mesh::Curve curve = mesh->get_curve(j);
 +                      PrimitiveType type = PRIMITIVE_CURVE;
  
 -              for(int k = 0; k < curve.num_keys - 1; k++) {
 -                      BoundBox bounds = BoundBox::empty;
 -                      curve.bounds_grow(k, &mesh->curve_keys[0], 
&mesh->curve_radius[0], bounds);
 +                      for(int k = 0; k < curve.num_keys - 1; k++) {
 +                              BoundBox bounds = BoundBox::empty;
-                               curve.bounds_grow(k, &mesh->curve_keys[0], 
bounds);
++                              curve.bounds_grow(k, &mesh->curve_keys[0], 
&mesh->curve_radius[0], bounds);
  
 -                      /* motion curve */
 -                      if(curve_attr_mP) {
 -                              size_t mesh_size = mesh->curve_keys.size();
 -                              size_t steps = mesh->motion_steps - 1;
 -                              float3 *key_steps = 
curve_attr_mP->data_float3();
 +                              /* motion curve */
 +                              if(curve_attr_mP) {
 +                                      size_t mesh_size = 
mesh->curve_keys.size();
 +                                      size_t steps = mesh->motion_steps - 1;
-                                       float4 *key_steps = 
curve_attr_mP->data_float4();
++                                      float3 *key_steps = 
curve_attr_mP->data_float3();
  
 -                              for(size_t i = 0; i < steps; i++)
 -                                      curve.bounds_grow(k, key_steps + 
i*mesh_size, &mesh->curve_radius[0], bounds);
 +                                      for(size_t i = 0; i < steps; i++)
-                                               curve.bounds_grow(k, key_steps 
+ i*mesh_size, bounds);
++                                              curve.bounds_grow(k, key_steps 
+ i*mesh_size, &mesh->curve_radius[0], bounds);
  
 -                              type = PRIMITIVE_MOTION_CURVE;
 -                      }
 +                                      type = PRIMITIVE_MOTION_CURVE;
 +                              }
  
 -                      if(bounds.valid()) {
 -                              int packed_type = PRIMITIVE_PACK_SEGMENT(type, 
k);
 -                              
 -                              references.push_back(BVHReference(bounds, j, i, 
packed_type));
 -                              root.grow(bounds);
 -                              center.grow(bounds.center2());
 +                              if(bounds.valid()) {
 +                                      int packed_type = 
PRIMITIVE_PACK_SEGMENT(type, k);
 +
 +                                      
references.push_back(BVHReference(bounds, j, i, packed_type));
 +                                      root.grow(bounds);
 +                                      center.grow(bounds.center2());
 +                              }
                        }
                }
        }
@@@ -209,24 -205,19 +211,27 @@@ void BVHBuild::add_references(BVHRange
  
        foreach(Object *ob, objects) {
                if(params.top_level) {
+                       if(!ob->is_traceable()) {
+                               continue;
+                       }
                        if(!ob->mesh->is_instanced()) {
 -                              num_alloc_references += 
ob->mesh->num_triangles();
 -                              num_alloc_references += 
count_curve_segments(ob->mesh);
 +                              if(params.primitive_mask & 
PRIMITIVE_ALL_TRIANGLE) {
-                                       num_alloc_references += 
ob->mesh->triangles.size();
++                                      num_alloc_references += 
ob->mesh->num_triangles();
 +                              }
 +                              if(params.primitive_mask & PRIMITIVE_ALL_CURVE) 
{
 +                                      num_alloc_references += 
count_curve_segments(ob->mesh);
 +                              }
                        }
                        else
                                num_alloc_references++;
                }
                else {
 -                      num_alloc_references += ob->mesh->num_triangles();
 -                      num_alloc_references += count_curve_segments(ob->mesh);
 +                      if(params.primitive_mask & PRIMITIVE_ALL_TRIANGLE) {
-                               num_alloc_references += 
ob->mesh->triangles.size();
++                              num_alloc_references += 
ob->mesh->num_triangles();
 +                      }
 +                      if(params.primitive_mask & PRIMITIVE_ALL_CURVE) {
 +                              num_alloc_references += 
count_curve_segments(ob->mesh);
 +                      }
                }
        }
  
@@@ -340,13 -335,11 +349,13 @@@ BVHNode* BVHBuild::run(
                        VLOG(1) << "BVH build statistics:\n"
                                << "  Build time: " << time_dt() - 
build_start_time << "\n"
                                << "  Total number of nodes: "
-                               << 
rootnode->getSubtreeSize(BVH_STAT_NODE_COUNT) << "\n"
+                               << 
string_human_readable_number(rootnode->getSubtreeSize(BVH_STAT_NODE_COUNT)) << 
"\n"
                                << "  Number of inner nodes: "
-                               << 
rootnode->getSubtreeSize(BVH_STAT_INNER_COUNT)  << "\n"
+                               << 
string_human_readable_number(rootnode->getSubtreeSize(BVH_STAT_INNER_COUNT)) << 
"\n"
                                << "  Number of leaf nodes: "
-                               << 
rootnode->getSubtreeSize(BVH_STAT_LEAF_COUNT)  << "\n"
+                               << 
string_human_readable_number(rootnode->getSubtreeSize(BVH_STAT_LEAF_COUNT)) << 
"\n"
 +                              << "  Number of unaligned nodes: "
-                               << 
rootnode->getSubtreeSize(BVH_STAT_UNALIGNED_COUNT)  << "\n"
++                              << 
string_human_readable_number(rootnode->getSubtreeSize(BVH_STAT_UNALIGNED_COUNT))
  << "\n"
                                << "  Allocation slop factor: "
                                       << ((prim_type.capacity() != 0)
                                               ? (float)prim_type.size() / 
prim_type.capacity()
diff --cc intern/cycles/bvh/bvh_split.cpp
index 70b03a0,bf68b41..3965586
--- a/intern/cycles/bvh/bvh_split.cpp
+++ b/intern/cycles/bvh/bvh_split.cpp
@@@ -356,16 -292,14 +356,16 @@@ void BVHSpatialSplit::split_triangle_pr
                                                 BoundBox& left_bounds,
                                                 BoundBox& right_bounds)
  {
-       const int *inds = mesh->triangles[prim_index].v;
+       Mesh::Triangle t = mesh->get_triangle(prim_index);
        const float3 *verts = &mesh->verts[0];
-       float3 v1 = tfm ? transform_point(tfm, verts[inds[2]]) : verts[inds[2]];
+       float3 v1 = tfm ? transform_point(tfm, verts[t.v[2]]) : verts[t.v[2]];
 +      v1 = get_unaligned_point(v1);
  
        for(int i = 0; i < 3; i++) {
                float3 v0 = v1;
-               int vindex = inds[i];
+               int vindex = t.v[i];
                v1 = tfm ? transform_point(tfm, verts[vindex]) : verts[vindex];
 +              v1 = get_unaligned_point(v1);
                float v0p = v0[dim];
                float v1p = v1[dim];
  
diff --cc intern/cycles/bvh/bvh_unaligned.cpp
index 6f49738,0000000..98e7de6
mode 100644,000000..100644
--- a/intern/cycles/bvh/bvh_unaligned.cpp
+++ b/intern/cycles/bvh/bvh_unaligned.cpp
@@@ -1,174 -1,0 +1,178 @@@
 +/*
 + * Copyright 2011-2016 Blender Foundation
 + *
 + * Licensed under the Apache License, Version 2.0 (the "License");
 + * you may not use this file except in compliance with the License.
 + * You may obtain a copy of the License at
 + *
 + * http://www.apache.org/licenses/LICENSE-2.0
 + *
 + * Unless required by applicable law or agreed to in writing, software
 + * distributed under the License is distributed on an "AS IS" BASIS,
 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 + * See the License for the specific language governing permissions and
 + * limitations under the License.
 + */
 +
 +
 +#include "bvh_unaligned.h"
 +
 +#include "mesh.h"
 +#include "object.h"
 +
 +#include "bvh_binning.h"
 +#include "bvh_params.h"
 +
 +#include "util_boundbox.h"
 +#include "util_debug.h"
 +#include "util_transform.h"
 +
 +CCL_NAMESPACE_BEGIN
 +
 +
 +BVHUnaligned::BVHUnaligned(const vector<Object*>& objects)
 +        : objects_(objects)
 +{
 +}
 +
 +Transform BVHUnaligned::compute_aligned_space(
 +        const BVHObjectBinning& range,
 +        const BVHReference *references) const
 +{
 +      for(int i = range.start(); i < range.end(); ++i) {
 +              const BVHReference& ref = references[i];
 +              Transform aligned_space;
 +              /* Use first primitive which defines correct direction to define
 +               * the orientation space.
 +               */
 +              if(compute_aligned_space(ref, &aligned_space)) {
 +                      return aligned_space;
 +              }
 +      }
 +      return make_trasnform_frame(make_float3(0.0f, 0.0f, 1.0f));
 +}
 +
 +Transform BVHUnaligned::compute_aligned_space(
 +        const BVHRange& range,
 +        const BVHReference *references) const
 +{
 +      for(int i = range.start(); i < range.end(); ++i) {
 +              const BVHReference& ref = references[i];
 +              Transform aligned_space;
 +              /* Use first primitive which defines correct direction to define
 +               * the orienta

@@ 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