Cleanup: Cycles: use existing utility functions for geometry types
Pull Request: https://projects.blender.org/blender/blender/pulls/129552
This commit is contained in:
committed by
Weizhen Huang
parent
1dbe94c8ac
commit
34b95fe3f6
@@ -358,15 +358,15 @@ void BVHBuild::add_reference_geometry(BoundBox &root,
|
||||
Geometry *geom,
|
||||
int object_index)
|
||||
{
|
||||
if (geom->geometry_type == Geometry::MESH || geom->geometry_type == Geometry::VOLUME) {
|
||||
if (geom->is_mesh() || geom->is_volume()) {
|
||||
Mesh *mesh = static_cast<Mesh *>(geom);
|
||||
add_reference_triangles(root, center, mesh, object_index);
|
||||
}
|
||||
else if (geom->geometry_type == Geometry::HAIR) {
|
||||
else if (geom->is_hair()) {
|
||||
Hair *hair = static_cast<Hair *>(geom);
|
||||
add_reference_curves(root, center, hair, object_index);
|
||||
}
|
||||
else if (geom->geometry_type == Geometry::POINTCLOUD) {
|
||||
else if (geom->is_pointcloud()) {
|
||||
PointCloud *pointcloud = static_cast<PointCloud *>(geom);
|
||||
add_reference_points(root, center, pointcloud, object_index);
|
||||
}
|
||||
@@ -392,15 +392,15 @@ static size_t count_curve_segments(Hair *hair)
|
||||
|
||||
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);
|
||||
return mesh->num_triangles();
|
||||
}
|
||||
else if (geom->geometry_type == Geometry::HAIR) {
|
||||
else if (geom->is_hair()) {
|
||||
Hair *hair = static_cast<Hair *>(geom);
|
||||
return count_curve_segments(hair);
|
||||
}
|
||||
else if (geom->geometry_type == Geometry::POINTCLOUD) {
|
||||
else if (geom->is_pointcloud()) {
|
||||
PointCloud *pointcloud = static_cast<PointCloud *>(geom);
|
||||
return pointcloud->num_points();
|
||||
}
|
||||
|
||||
@@ -233,19 +233,19 @@ void BVHEmbree::add_object(Object *ob, int i)
|
||||
{
|
||||
Geometry *geom = ob->get_geometry();
|
||||
|
||||
if (geom->geometry_type == Geometry::MESH || geom->geometry_type == Geometry::VOLUME) {
|
||||
if (geom->is_mesh() || geom->is_volume()) {
|
||||
Mesh *mesh = static_cast<Mesh *>(geom);
|
||||
if (mesh->num_triangles() > 0) {
|
||||
add_triangles(ob, mesh, i);
|
||||
}
|
||||
}
|
||||
else if (geom->geometry_type == Geometry::HAIR) {
|
||||
else if (geom->is_hair()) {
|
||||
Hair *hair = static_cast<Hair *>(geom);
|
||||
if (hair->num_curves() > 0) {
|
||||
add_curves(ob, hair, i);
|
||||
}
|
||||
}
|
||||
else if (geom->geometry_type == Geometry::POINTCLOUD) {
|
||||
else if (geom->is_pointcloud()) {
|
||||
PointCloud *pointcloud = static_cast<PointCloud *>(geom);
|
||||
if (pointcloud->num_points() > 0) {
|
||||
add_points(ob, pointcloud, i);
|
||||
@@ -696,7 +696,7 @@ void BVHEmbree::refit(Progress &progress)
|
||||
if (!params.top_level || (ob->is_traceable() && !ob->get_geometry()->is_instanced())) {
|
||||
Geometry *geom = ob->get_geometry();
|
||||
|
||||
if (geom->geometry_type == Geometry::MESH || geom->geometry_type == Geometry::VOLUME) {
|
||||
if (geom->is_mesh() || geom->is_volume()) {
|
||||
Mesh *mesh = static_cast<Mesh *>(geom);
|
||||
if (mesh->num_triangles() > 0) {
|
||||
RTCGeometry geom = rtcGetGeometry(scene, geom_id);
|
||||
@@ -705,7 +705,7 @@ void BVHEmbree::refit(Progress &progress)
|
||||
rtcCommitGeometry(geom);
|
||||
}
|
||||
}
|
||||
else if (geom->geometry_type == Geometry::HAIR) {
|
||||
else if (geom->is_hair()) {
|
||||
Hair *hair = static_cast<Hair *>(geom);
|
||||
if (hair->num_curves() > 0) {
|
||||
RTCGeometry geom = rtcGetGeometry(scene, geom_id + 1);
|
||||
@@ -714,7 +714,7 @@ void BVHEmbree::refit(Progress &progress)
|
||||
rtcCommitGeometry(geom);
|
||||
}
|
||||
}
|
||||
else if (geom->geometry_type == Geometry::POINTCLOUD) {
|
||||
else if (geom->is_pointcloud()) {
|
||||
PointCloud *pointcloud = static_cast<PointCloud *>(geom);
|
||||
if (pointcloud->num_points() > 0) {
|
||||
RTCGeometry geom = rtcGetGeometry(scene, geom_id);
|
||||
|
||||
@@ -492,14 +492,14 @@ void BVHSpatialSplit::split_object_reference(
|
||||
{
|
||||
Geometry *geom = object->get_geometry();
|
||||
|
||||
if (geom->geometry_type == Geometry::MESH || geom->geometry_type == Geometry::VOLUME) {
|
||||
if (geom->is_mesh() || geom->is_volume()) {
|
||||
Mesh *mesh = static_cast<Mesh *>(geom);
|
||||
for (int tri_idx = 0; tri_idx < mesh->num_triangles(); ++tri_idx) {
|
||||
split_triangle_primitive(
|
||||
mesh, &object->get_tfm(), tri_idx, dim, pos, left_bounds, right_bounds);
|
||||
}
|
||||
}
|
||||
else if (geom->geometry_type == Geometry::HAIR) {
|
||||
else if (geom->is_hair()) {
|
||||
Hair *hair = static_cast<Hair *>(geom);
|
||||
for (int curve_idx = 0; curve_idx < hair->num_curves(); ++curve_idx) {
|
||||
Hair::Curve curve = hair->get_curve(curve_idx);
|
||||
@@ -509,7 +509,7 @@ void BVHSpatialSplit::split_object_reference(
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (geom->geometry_type == Geometry::POINTCLOUD) {
|
||||
else if (geom->is_pointcloud()) {
|
||||
PointCloud *pointcloud = static_cast<PointCloud *>(geom);
|
||||
for (int point_idx = 0; point_idx < pointcloud->num_points(); ++point_idx) {
|
||||
split_point_primitive(
|
||||
|
||||
@@ -922,10 +922,10 @@ hiprtScene HIPRTDevice::build_tlas(BVHHIPRT *bvh,
|
||||
custom_prim_info_offset[blender_instance_id].x = offset;
|
||||
custom_prim_info_offset[blender_instance_id].y = custom_prim_offset;
|
||||
|
||||
if (geom->geometry_type == Geometry::HAIR) {
|
||||
if (geom->is_hair()) {
|
||||
custom_prim_offset += ((Hair *)geom)->num_curves();
|
||||
}
|
||||
else if (geom->geometry_type == Geometry::POINTCLOUD) {
|
||||
else if (geom->is_pointcloud()) {
|
||||
custom_prim_offset += ((PointCloud *)geom)->num_points();
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -1139,17 +1139,17 @@ bool BVHMetal::build_TLAS(Progress &progress,
|
||||
uint32_t primitive_offset = 0;
|
||||
int currIndex = instance_index++;
|
||||
|
||||
if (geom->geometry_type == Geometry::HAIR) {
|
||||
if (geom->is_hair()) {
|
||||
/* Build BLAS for curve primitives. */
|
||||
Hair *const hair = static_cast<Hair *const>(const_cast<Geometry *>(geom));
|
||||
primitive_offset = uint32_t(hair->curve_segment_offset);
|
||||
}
|
||||
else if (geom->geometry_type == Geometry::MESH || geom->geometry_type == Geometry::VOLUME) {
|
||||
else if (geom->is_mesh() || geom->is_volume()) {
|
||||
/* Build BLAS for triangle primitives. */
|
||||
Mesh *const mesh = static_cast<Mesh *const>(const_cast<Geometry *>(geom));
|
||||
primitive_offset = uint32_t(mesh->prim_offset);
|
||||
}
|
||||
else if (geom->geometry_type == Geometry::POINTCLOUD) {
|
||||
else if (geom->is_pointcloud()) {
|
||||
/* Build BLAS for points primitives. */
|
||||
PointCloud *const pointcloud = static_cast<PointCloud *const>(
|
||||
const_cast<Geometry *>(geom));
|
||||
|
||||
@@ -1166,7 +1166,7 @@ void OptiXDevice::build_bvh(BVH *bvh, Progress &progress, bool refit)
|
||||
|
||||
/* Build bottom level acceleration structures (BLAS). */
|
||||
Geometry *const geom = bvh->geometry[0];
|
||||
if (geom->geometry_type == Geometry::HAIR) {
|
||||
if (geom->is_hair()) {
|
||||
/* Build BLAS for curve primitives. */
|
||||
Hair *const hair = static_cast<Hair *const>(geom);
|
||||
if (hair->num_segments() == 0) {
|
||||
@@ -1365,7 +1365,7 @@ void OptiXDevice::build_bvh(BVH *bvh, Progress &progress, bool refit)
|
||||
progress.set_error("Failed to build OptiX acceleration structure");
|
||||
}
|
||||
}
|
||||
else if (geom->geometry_type == Geometry::MESH || geom->geometry_type == Geometry::VOLUME) {
|
||||
else if (geom->is_mesh() || geom->is_volume()) {
|
||||
/* Build BLAS for triangle primitives. */
|
||||
Mesh *const mesh = static_cast<Mesh *const>(geom);
|
||||
if (mesh->num_triangles() == 0) {
|
||||
@@ -1433,7 +1433,7 @@ void OptiXDevice::build_bvh(BVH *bvh, Progress &progress, bool refit)
|
||||
progress.set_error("Failed to build OptiX acceleration structure");
|
||||
}
|
||||
}
|
||||
else if (geom->geometry_type == Geometry::POINTCLOUD) {
|
||||
else if (geom->is_pointcloud()) {
|
||||
/* Build BLAS for points primitives. */
|
||||
PointCloud *const pointcloud = static_cast<PointCloud *const>(geom);
|
||||
const size_t num_points = pointcloud->num_points();
|
||||
@@ -1608,7 +1608,7 @@ void OptiXDevice::build_bvh(BVH *bvh, Progress &progress, bool refit)
|
||||
instance.visibilityMask = 0xFF;
|
||||
}
|
||||
|
||||
if (ob->get_geometry()->geometry_type == Geometry::HAIR &&
|
||||
if (ob->get_geometry()->is_hair() &&
|
||||
static_cast<const Hair *>(ob->get_geometry())->curve_shape == CURVE_THICK)
|
||||
{
|
||||
if (pipeline_options.usesMotionBlur && ob->get_geometry()->has_motion_blur()) {
|
||||
@@ -1616,7 +1616,7 @@ void OptiXDevice::build_bvh(BVH *bvh, Progress &progress, bool refit)
|
||||
instance.sbtOffset = PG_HITD_MOTION - PG_HITD;
|
||||
}
|
||||
}
|
||||
else if (ob->get_geometry()->geometry_type == Geometry::POINTCLOUD) {
|
||||
else if (ob->get_geometry()->is_pointcloud()) {
|
||||
/* Use the hit group that has an intersection program for point clouds. */
|
||||
instance.sbtOffset = PG_HITD_POINTCLOUD - PG_HITD;
|
||||
|
||||
|
||||
@@ -206,20 +206,20 @@ size_t Attribute::element_size(Geometry *geom, AttributePrimitive prim) const
|
||||
size = 1;
|
||||
break;
|
||||
case ATTR_ELEMENT_VERTEX:
|
||||
if (geom->geometry_type == Geometry::MESH || geom->geometry_type == Geometry::VOLUME) {
|
||||
if (geom->is_mesh() || geom->is_volume()) {
|
||||
Mesh *mesh = static_cast<Mesh *>(geom);
|
||||
size = mesh->get_verts().size() + mesh->get_num_ngons();
|
||||
if (prim == ATTR_PRIM_SUBD) {
|
||||
size -= mesh->get_num_subd_verts();
|
||||
}
|
||||
}
|
||||
else if (geom->geometry_type == Geometry::POINTCLOUD) {
|
||||
else if (geom->is_pointcloud()) {
|
||||
PointCloud *pointcloud = static_cast<PointCloud *>(geom);
|
||||
size = pointcloud->num_points();
|
||||
}
|
||||
break;
|
||||
case ATTR_ELEMENT_VERTEX_MOTION:
|
||||
if (geom->geometry_type == Geometry::MESH) {
|
||||
if (geom->is_mesh()) {
|
||||
Mesh *mesh = static_cast<Mesh *>(geom);
|
||||
DCHECK_GT(mesh->get_motion_steps(), 0);
|
||||
size = (mesh->get_verts().size() + mesh->get_num_ngons()) * (mesh->get_motion_steps() - 1);
|
||||
@@ -227,13 +227,13 @@ size_t Attribute::element_size(Geometry *geom, AttributePrimitive prim) const
|
||||
size -= mesh->get_num_subd_verts() * (mesh->get_motion_steps() - 1);
|
||||
}
|
||||
}
|
||||
else if (geom->geometry_type == Geometry::POINTCLOUD) {
|
||||
else if (geom->is_pointcloud()) {
|
||||
PointCloud *pointcloud = static_cast<PointCloud *>(geom);
|
||||
size = pointcloud->num_points() * (pointcloud->get_motion_steps() - 1);
|
||||
}
|
||||
break;
|
||||
case ATTR_ELEMENT_FACE:
|
||||
if (geom->geometry_type == Geometry::MESH || geom->geometry_type == Geometry::VOLUME) {
|
||||
if (geom->is_mesh() || geom->is_volume()) {
|
||||
Mesh *mesh = static_cast<Mesh *>(geom);
|
||||
if (prim == ATTR_PRIM_GEOMETRY) {
|
||||
size = mesh->num_triangles();
|
||||
@@ -245,7 +245,7 @@ size_t Attribute::element_size(Geometry *geom, AttributePrimitive prim) const
|
||||
break;
|
||||
case ATTR_ELEMENT_CORNER:
|
||||
case ATTR_ELEMENT_CORNER_BYTE:
|
||||
if (geom->geometry_type == Geometry::MESH) {
|
||||
if (geom->is_mesh()) {
|
||||
Mesh *mesh = static_cast<Mesh *>(geom);
|
||||
if (prim == ATTR_PRIM_GEOMETRY) {
|
||||
size = mesh->num_triangles() * 3;
|
||||
@@ -256,19 +256,19 @@ size_t Attribute::element_size(Geometry *geom, AttributePrimitive prim) const
|
||||
}
|
||||
break;
|
||||
case ATTR_ELEMENT_CURVE:
|
||||
if (geom->geometry_type == Geometry::HAIR) {
|
||||
if (geom->is_hair()) {
|
||||
Hair *hair = static_cast<Hair *>(geom);
|
||||
size = hair->num_curves();
|
||||
}
|
||||
break;
|
||||
case ATTR_ELEMENT_CURVE_KEY:
|
||||
if (geom->geometry_type == Geometry::HAIR) {
|
||||
if (geom->is_hair()) {
|
||||
Hair *hair = static_cast<Hair *>(geom);
|
||||
size = hair->get_curve_keys().size();
|
||||
}
|
||||
break;
|
||||
case ATTR_ELEMENT_CURVE_KEY_MOTION:
|
||||
if (geom->geometry_type == Geometry::HAIR) {
|
||||
if (geom->is_hair()) {
|
||||
Hair *hair = static_cast<Hair *>(geom);
|
||||
DCHECK_GT(hair->get_motion_steps(), 0);
|
||||
size = hair->get_curve_keys().size() * (hair->get_motion_steps() - 1);
|
||||
@@ -529,7 +529,7 @@ Attribute *AttributeSet::add(AttributeStandard std, ustring name)
|
||||
name = Attribute::standard_name(std);
|
||||
}
|
||||
|
||||
if (geometry->geometry_type == Geometry::MESH) {
|
||||
if (geometry->is_mesh()) {
|
||||
switch (std) {
|
||||
case ATTR_STD_VERTEX_NORMAL:
|
||||
attr = add(name, TypeNormal, ATTR_ELEMENT_VERTEX);
|
||||
@@ -580,7 +580,7 @@ Attribute *AttributeSet::add(AttributeStandard std, ustring name)
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (geometry->geometry_type == Geometry::POINTCLOUD) {
|
||||
else if (geometry->is_pointcloud()) {
|
||||
switch (std) {
|
||||
case ATTR_STD_UV:
|
||||
attr = add(name, TypeFloat2, ATTR_ELEMENT_VERTEX);
|
||||
@@ -602,7 +602,7 @@ Attribute *AttributeSet::add(AttributeStandard std, ustring name)
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (geometry->geometry_type == Geometry::VOLUME) {
|
||||
else if (geometry->is_volume()) {
|
||||
switch (std) {
|
||||
case ATTR_STD_VERTEX_NORMAL:
|
||||
attr = add(name, TypeNormal, ATTR_ELEMENT_VERTEX);
|
||||
@@ -630,7 +630,7 @@ Attribute *AttributeSet::add(AttributeStandard std, ustring name)
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (geometry->geometry_type == Geometry::HAIR) {
|
||||
else if (geometry->is_hair()) {
|
||||
switch (std) {
|
||||
case ATTR_STD_VERTEX_NORMAL:
|
||||
attr = add(name, TypeNormal, ATTR_ELEMENT_CURVE_KEY);
|
||||
|
||||
@@ -82,7 +82,7 @@ void BakeManager::device_update(Device * /*device*/,
|
||||
int object_index = 0;
|
||||
foreach (Object *object, scene->objects) {
|
||||
const Geometry *geom = object->get_geometry();
|
||||
if (object->name == object_name && geom->geometry_type == Geometry::MESH) {
|
||||
if (object->name == object_name && geom->is_mesh()) {
|
||||
kbake->object_index = object_index;
|
||||
kbake->tri_offset = geom->prim_offset;
|
||||
break;
|
||||
|
||||
@@ -288,7 +288,7 @@ void GeometryManager::geom_calc_offset(Scene *scene, BVHLayout bvh_layout)
|
||||
foreach (Geometry *geom, scene->geometry) {
|
||||
bool prim_offset_changed = false;
|
||||
|
||||
if (geom->geometry_type == Geometry::MESH || geom->geometry_type == Geometry::VOLUME) {
|
||||
if (geom->is_mesh() || geom->is_volume()) {
|
||||
Mesh *mesh = static_cast<Mesh *>(geom);
|
||||
|
||||
prim_offset_changed = (mesh->prim_offset != tri_size);
|
||||
@@ -436,7 +436,7 @@ void GeometryManager::device_update_preprocess(Device *device, Scene *scene, Pro
|
||||
/* Re-create volume mesh if we will rebuild or refit the BVH. Note we
|
||||
* should only do it in that case, otherwise the BVH and mesh can go
|
||||
* out of sync. */
|
||||
if (geom->is_modified() && geom->geometry_type == Geometry::VOLUME) {
|
||||
if (geom->is_modified() && geom->is_volume()) {
|
||||
/* Create volume meshes if there is voxel data. */
|
||||
if (!volume_images_updated) {
|
||||
progress.set_status("Updating Meshes Volume Bounds");
|
||||
@@ -622,7 +622,7 @@ void GeometryManager::device_update_displacement_images(Device *device,
|
||||
* This matches the logic in the `Hair::update_shadow_transparency()`, avoiding access to
|
||||
* possible non-loaded images. */
|
||||
bool need_shadow_transparency = false;
|
||||
if (geom->geometry_type == Geometry::HAIR) {
|
||||
if (geom->is_hair()) {
|
||||
Hair *hair = static_cast<Hair *>(geom);
|
||||
need_shadow_transparency = hair->need_shadow_transparency();
|
||||
}
|
||||
@@ -731,7 +731,7 @@ void GeometryManager::device_update(Device *device,
|
||||
|
||||
foreach (Geometry *geom, scene->geometry) {
|
||||
if (geom->is_modified()) {
|
||||
if ((geom->geometry_type == Geometry::MESH || geom->geometry_type == Geometry::VOLUME)) {
|
||||
if (geom->is_mesh() || geom->is_volume()) {
|
||||
Mesh *mesh = static_cast<Mesh *>(geom);
|
||||
|
||||
/* Update normals. */
|
||||
@@ -752,7 +752,7 @@ void GeometryManager::device_update(Device *device,
|
||||
true_displacement_used = true;
|
||||
}
|
||||
}
|
||||
else if (geom->geometry_type == Geometry::HAIR) {
|
||||
else if (geom->is_hair()) {
|
||||
Hair *hair = static_cast<Hair *>(geom);
|
||||
if (hair->need_shadow_transparency()) {
|
||||
curve_shadow_transparency_used = true;
|
||||
@@ -886,7 +886,7 @@ void GeometryManager::device_update(Device *device,
|
||||
displacement_done = true;
|
||||
}
|
||||
}
|
||||
else if (geom->geometry_type == Geometry::HAIR) {
|
||||
else if (geom->is_hair()) {
|
||||
Hair *hair = static_cast<Hair *>(geom);
|
||||
if (hair->update_shadow_transparency(device, scene, progress)) {
|
||||
curve_shadow_transparency_done = true;
|
||||
|
||||
@@ -54,7 +54,7 @@ void GeometryManager::device_update_mesh(Device *,
|
||||
size_t patch_size = 0;
|
||||
|
||||
foreach (Geometry *geom, scene->geometry) {
|
||||
if (geom->geometry_type == Geometry::MESH || geom->geometry_type == Geometry::VOLUME) {
|
||||
if (geom->is_mesh() || geom->is_volume()) {
|
||||
Mesh *mesh = static_cast<Mesh *>(geom);
|
||||
|
||||
vert_size += mesh->verts.size();
|
||||
@@ -103,7 +103,7 @@ void GeometryManager::device_update_mesh(Device *,
|
||||
dscene->tri_patch_uv.need_realloc();
|
||||
|
||||
foreach (Geometry *geom, scene->geometry) {
|
||||
if (geom->geometry_type == Geometry::MESH || geom->geometry_type == Geometry::VOLUME) {
|
||||
if (geom->is_mesh() || geom->is_volume()) {
|
||||
Mesh *mesh = static_cast<Mesh *>(geom);
|
||||
|
||||
if (mesh->shader_is_modified() || mesh->smooth_is_modified() ||
|
||||
|
||||
@@ -318,7 +318,7 @@ float Object::compute_volume_step_size() const
|
||||
/* Compute step size from voxel grids. */
|
||||
float step_size = FLT_MAX;
|
||||
|
||||
if (geometry->geometry_type == Geometry::VOLUME) {
|
||||
if (geometry->is_volume()) {
|
||||
Volume *volume = static_cast<Volume *>(geometry);
|
||||
|
||||
foreach (Attribute &attr, volume->attributes.attributes) {
|
||||
@@ -448,7 +448,7 @@ ObjectManager::~ObjectManager() {}
|
||||
|
||||
static float object_volume_density(const Transform &tfm, Geometry *geom)
|
||||
{
|
||||
if (geom->geometry_type == Geometry::VOLUME) {
|
||||
if (geom->is_volume()) {
|
||||
/* Volume density automatically adjust to object scale. */
|
||||
if (static_cast<Volume *>(geom)->get_object_space()) {
|
||||
const float3 unit = normalize(one_float3());
|
||||
@@ -510,7 +510,7 @@ void ObjectManager::device_update_object_transform(UpdateObjectTransformState *s
|
||||
flag |= SD_OBJECT_NEGATIVE_SCALE;
|
||||
}
|
||||
|
||||
if (geom->geometry_type == Geometry::MESH || geom->geometry_type == Geometry::POINTCLOUD) {
|
||||
if (geom->is_mesh() || geom->is_pointcloud()) {
|
||||
/* TODO: why only mesh? */
|
||||
Mesh *mesh = static_cast<Mesh *>(geom);
|
||||
if (mesh->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION)) {
|
||||
@@ -576,14 +576,11 @@ void ObjectManager::device_update_object_transform(UpdateObjectTransformState *s
|
||||
kobject.dupli_uv[1] = ob->dupli_uv[1];
|
||||
int totalsteps = geom->get_motion_steps();
|
||||
kobject.numsteps = (totalsteps - 1) / 2;
|
||||
kobject.numverts = (geom->geometry_type == Geometry::MESH ||
|
||||
geom->geometry_type == Geometry::VOLUME) ?
|
||||
kobject.numverts = (geom->is_mesh() || geom->is_volume()) ?
|
||||
static_cast<Mesh *>(geom)->get_verts().size() :
|
||||
(geom->geometry_type == Geometry::HAIR) ?
|
||||
static_cast<Hair *>(geom)->get_curve_keys().size() :
|
||||
(geom->geometry_type == Geometry::POINTCLOUD) ?
|
||||
static_cast<PointCloud *>(geom)->num_points() :
|
||||
0;
|
||||
geom->is_hair() ? static_cast<Hair *>(geom)->get_curve_keys().size() :
|
||||
geom->is_pointcloud() ? static_cast<PointCloud *>(geom)->num_points() :
|
||||
0;
|
||||
kobject.patch_map_offset = 0;
|
||||
kobject.attribute_map_offset = 0;
|
||||
|
||||
@@ -617,13 +614,13 @@ void ObjectManager::device_update_object_transform(UpdateObjectTransformState *s
|
||||
state->object_volume_step[ob->index] = FLT_MAX;
|
||||
|
||||
/* Have curves. */
|
||||
if (geom->geometry_type == Geometry::HAIR) {
|
||||
if (geom->is_hair()) {
|
||||
state->have_curves = true;
|
||||
}
|
||||
if (geom->geometry_type == Geometry::POINTCLOUD) {
|
||||
if (geom->is_pointcloud()) {
|
||||
state->have_points = true;
|
||||
}
|
||||
if (geom->geometry_type == Geometry::VOLUME) {
|
||||
if (geom->is_volume()) {
|
||||
state->have_volumes = true;
|
||||
}
|
||||
|
||||
@@ -655,7 +652,7 @@ void ObjectManager::device_update_prim_offsets(Device *device, DeviceScene *dsce
|
||||
foreach (Object *ob, scene->objects) {
|
||||
uint32_t prim_offset = 0;
|
||||
if (Geometry *const geom = ob->geometry) {
|
||||
if (geom->geometry_type == Geometry::HAIR) {
|
||||
if (geom->is_hair()) {
|
||||
prim_offset = ((Hair *const)geom)->curve_segment_offset;
|
||||
}
|
||||
else {
|
||||
@@ -963,7 +960,7 @@ void ObjectManager::device_update_geom_offsets(Device *, DeviceScene *dscene, Sc
|
||||
foreach (Object *object, scene->objects) {
|
||||
Geometry *geom = object->geometry;
|
||||
|
||||
if (geom->geometry_type == Geometry::MESH) {
|
||||
if (geom->is_mesh()) {
|
||||
Mesh *mesh = static_cast<Mesh *>(geom);
|
||||
if (mesh->patch_table) {
|
||||
uint patch_map_offset = 2 * (mesh->patch_table_offset + mesh->patch_table->total_size() -
|
||||
@@ -1045,11 +1042,11 @@ void ObjectManager::apply_static_transforms(DeviceScene *dscene, Scene *scene, P
|
||||
bool apply = (geometry_users[geom] == 1) && !geom->has_surface_bssrdf &&
|
||||
!geom->has_true_displacement();
|
||||
|
||||
if (geom->geometry_type == Geometry::MESH) {
|
||||
if (geom->is_mesh()) {
|
||||
Mesh *mesh = static_cast<Mesh *>(geom);
|
||||
apply = apply && mesh->get_subdivision_type() == Mesh::SUBDIVISION_NONE;
|
||||
}
|
||||
else if (geom->geometry_type == Geometry::HAIR) {
|
||||
else if (geom->is_hair()) {
|
||||
/* Can't apply non-uniform scale to curves, this can't be represented by
|
||||
* control points and radius alone. */
|
||||
float scale;
|
||||
|
||||
Reference in New Issue
Block a user