Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/bvh/bvh_build.cpp
| Show First 20 Lines • Show All 151 Lines • ▼ Show 20 Lines | for (uint j = 0; j < num_triangles; j++) { | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| void BVHBuild::add_reference_curves(BoundBox &root, BoundBox ¢er, Hair *hair, int i) | void BVHBuild::add_reference_curves(BoundBox &root, BoundBox ¢er, Hair *hair, int i) | ||||
| { | { | ||||
| const Attribute *curve_attr_mP = NULL; | const Attribute *curve_attr_mP = NULL; | ||||
| if (hair->has_motion_blur()) { | if (hair->has_motion_blur()) { | ||||
| curve_attr_mP = hair->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION); | curve_attr_mP = hair->get_attributes().find(ATTR_STD_MOTION_VERTEX_POSITION); | ||||
| } | } | ||||
| const PrimitiveType primitive_type = | const PrimitiveType primitive_type = (curve_attr_mP != NULL) ? | ||||
| (curve_attr_mP != NULL) ? | ((hair->get_curve_shape() == CURVE_RIBBON) ? | ||||
| ((hair->curve_shape == CURVE_RIBBON) ? PRIMITIVE_MOTION_CURVE_RIBBON : | PRIMITIVE_MOTION_CURVE_RIBBON : | ||||
| PRIMITIVE_MOTION_CURVE_THICK) : | PRIMITIVE_MOTION_CURVE_THICK) : | ||||
| ((hair->curve_shape == CURVE_RIBBON) ? PRIMITIVE_CURVE_RIBBON : PRIMITIVE_CURVE_THICK); | ((hair->get_curve_shape() == CURVE_RIBBON) ? | ||||
| PRIMITIVE_CURVE_RIBBON : | |||||
| PRIMITIVE_CURVE_THICK); | |||||
| const size_t num_curves = hair->num_curves(); | const size_t num_curves = hair->num_curves(); | ||||
| for (uint j = 0; j < num_curves; j++) { | for (uint j = 0; j < num_curves; j++) { | ||||
| const Hair::Curve curve = hair->get_curve(j); | const Hair::Curve curve = hair->get_curve(j); | ||||
| const float *curve_radius = &hair->get_curve_radius()[0]; | const float *curve_radius = &hair->get_curve_radius()[0]; | ||||
| for (int k = 0; k < curve.num_keys - 1; k++) { | for (int k = 0; k < curve.get_num_keys() - 1; k++) { | ||||
| if (curve_attr_mP == NULL) { | if (curve_attr_mP == NULL) { | ||||
| /* Really simple logic for static hair. */ | /* Really simple logic for static hair. */ | ||||
| BoundBox bounds = BoundBox::empty; | BoundBox bounds = BoundBox::empty; | ||||
| curve.bounds_grow(k, &hair->get_curve_keys()[0], curve_radius, bounds); | curve.bounds_grow(k, &hair->get_curve_keys()[0], curve_radius, bounds); | ||||
| if (bounds.valid()) { | if (bounds.valid()) { | ||||
| int packed_type = PRIMITIVE_PACK_SEGMENT(primitive_type, k); | int packed_type = PRIMITIVE_PACK_SEGMENT(primitive_type, k); | ||||
| references.push_back(BVHReference(bounds, j, i, packed_type)); | references.push_back(BVHReference(bounds, j, i, packed_type)); | ||||
| root.grow(bounds); | root.grow(bounds); | ||||
| ▲ Show 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | for (int k = 0; k < curve.get_num_keys() - 1; k++) { | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| void BVHBuild::add_reference_geometry(BoundBox &root, BoundBox ¢er, Geometry *geom, int i) | void BVHBuild::add_reference_geometry(BoundBox &root, BoundBox ¢er, Geometry *geom, int i) | ||||
| { | { | ||||
| if (geom->geometry_type == Geometry::MESH || geom->geometry_type == Geometry::VOLUME) { | if (geom->is_mesh() || geom->is_volume()) { | ||||
| Mesh *mesh = static_cast<Mesh *>(geom); | Mesh *mesh = static_cast<Mesh *>(geom); | ||||
| add_reference_triangles(root, center, mesh, i); | add_reference_triangles(root, center, mesh, i); | ||||
| } | } | ||||
| else if (geom->geometry_type == Geometry::HAIR) { | else if (geom->is_hair()) { | ||||
| Hair *hair = static_cast<Hair *>(geom); | Hair *hair = static_cast<Hair *>(geom); | ||||
| add_reference_curves(root, center, hair, i); | add_reference_curves(root, center, hair, i); | ||||
| } | } | ||||
| } | } | ||||
| void BVHBuild::add_reference_object(BoundBox &root, BoundBox ¢er, Object *ob, int i) | void BVHBuild::add_reference_object(BoundBox &root, BoundBox ¢er, Object *ob, int i) | ||||
| { | { | ||||
| references.push_back(BVHReference(ob->bounds, -1, i, 0)); | const BoundBox &bounds = ob->get_bounds(); | ||||
| root.grow(ob->bounds); | references.push_back(BVHReference(bounds, -1, i, 0)); | ||||
| center.grow(ob->bounds.center2()); | root.grow(bounds); | ||||
| center.grow(bounds.center2()); | |||||
| } | } | ||||
| static size_t count_curve_segments(Hair *hair) | static size_t count_curve_segments(Hair *hair) | ||||
| { | { | ||||
| size_t num = 0, num_curves = hair->num_curves(); | size_t num = 0, num_curves = hair->num_curves(); | ||||
| for (size_t i = 0; i < num_curves; i++) | for (size_t i = 0; i < num_curves; i++) | ||||
| num += hair->get_curve(i).num_keys - 1; | num += hair->get_curve(i).get_num_keys() - 1; | ||||
| return num; | return num; | ||||
| } | } | ||||
| static size_t count_primitives(Geometry *geom) | static size_t count_primitives(Geometry *geom) | ||||
| { | { | ||||
| if (geom->geometry_type == Geometry::MESH || geom->geometry_type == Geometry::VOLUME) { | if (geom->is_mesh() || geom->is_volume()) { | ||||
| Mesh *mesh = static_cast<Mesh *>(geom); | Mesh *mesh = static_cast<Mesh *>(geom); | ||||
| return mesh->num_triangles(); | return mesh->num_triangles(); | ||||
| } | } | ||||
| else if (geom->geometry_type == Geometry::HAIR) { | else if (geom->is_hair()) { | ||||
| Hair *hair = static_cast<Hair *>(geom); | Hair *hair = static_cast<Hair *>(geom); | ||||
| return count_curve_segments(hair); | return count_curve_segments(hair); | ||||
| } | } | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| void BVHBuild::add_references(BVHRange &root) | void BVHBuild::add_references(BVHRange &root) | ||||
| ▲ Show 20 Lines • Show All 826 Lines • Show Last 20 Lines | |||||