Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/blender/blender_mesh.cpp
| Show First 20 Lines • Show All 277 Lines • ▼ Show 20 Lines | static void mikk_compute_tangents( | ||||
| genTangSpaceDefault(&context); | genTangSpaceDefault(&context); | ||||
| } | } | ||||
| /* Create Volume Attribute */ | /* Create Volume Attribute */ | ||||
| static void create_mesh_volume_attribute( | static void create_mesh_volume_attribute( | ||||
| BL::Object &b_ob, Mesh *mesh, ImageManager *image_manager, AttributeStandard std, float frame) | BL::Object &b_ob, Mesh *mesh, ImageManager *image_manager, AttributeStandard std, float frame) | ||||
| { | { | ||||
| BL::SmokeDomainSettings b_domain = object_smoke_domain_find(b_ob); | BL::FluidDomainSettings b_domain = object_fluid_domain_find(b_ob); | ||||
| if (!b_domain) | if (!b_domain) | ||||
| return; | return; | ||||
| mesh->volume_isovalue = b_domain.clipping(); | mesh->volume_isovalue = b_domain.clipping(); | ||||
| Attribute *attr = mesh->attributes.add(std); | Attribute *attr = mesh->attributes.add(std); | ||||
| VoxelAttribute *volume_data = attr->data_voxel(); | VoxelAttribute *volume_data = attr->data_voxel(); | ||||
| ▲ Show 20 Lines • Show All 625 Lines • ▼ Show 20 Lines | static void create_subd_mesh(Scene *scene, | ||||
| sdparams.dicing_rate = max(0.1f, RNA_float_get(&cobj, "dicing_rate") * dicing_rate); | sdparams.dicing_rate = max(0.1f, RNA_float_get(&cobj, "dicing_rate") * dicing_rate); | ||||
| sdparams.max_level = max_subdivisions; | sdparams.max_level = max_subdivisions; | ||||
| sdparams.objecttoworld = get_transform(b_ob.matrix_world()); | sdparams.objecttoworld = get_transform(b_ob.matrix_world()); | ||||
| } | } | ||||
| /* Sync */ | /* Sync */ | ||||
| static void sync_mesh_fluid_motion(BL::Object &b_ob, Scene *scene, Mesh *mesh) | static void sync_mesh_manta_motion(BL::Object &b_ob, Scene *scene, Mesh *mesh) | ||||
| { | { | ||||
| if (scene->need_motion() == Scene::MOTION_NONE) | if (scene->need_motion() == Scene::MOTION_NONE) | ||||
| return; | return; | ||||
| BL::DomainFluidSettings b_fluid_domain = object_fluid_domain_find(b_ob); | BL::FluidDomainSettings b_manta_domain = object_fluid_domain_find(b_ob); | ||||
| if (!b_fluid_domain) | if (!b_manta_domain) | ||||
| return; | return; | ||||
| /* If the mesh has modifiers following the fluid domain we can't export motion. */ | /* If the mesh has modifiers following the fluid domain we can't export motion. */ | ||||
| if (b_fluid_domain.fluid_mesh_vertices.length() != mesh->verts.size()) | if (b_manta_domain.mesh_vertices.length() != mesh->verts.size()) | ||||
| return; | return; | ||||
| /* Find or add attribute */ | /* Find or add attribute */ | ||||
| float3 *P = &mesh->verts[0]; | float3 *P = &mesh->verts[0]; | ||||
| Attribute *attr_mP = mesh->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION); | Attribute *attr_mP = mesh->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION); | ||||
| if (!attr_mP) { | if (!attr_mP) { | ||||
| attr_mP = mesh->attributes.add(ATTR_STD_MOTION_VERTEX_POSITION); | attr_mP = mesh->attributes.add(ATTR_STD_MOTION_VERTEX_POSITION); | ||||
| } | } | ||||
| /* Only export previous and next frame, we don't have any in between data. */ | /* Only export previous and next frame, we don't have any in between data. */ | ||||
| float motion_times[2] = {-1.0f, 1.0f}; | float motion_times[2] = {-1.0f, 1.0f}; | ||||
| for (int step = 0; step < 2; step++) { | for (int step = 0; step < 2; step++) { | ||||
| float relative_time = motion_times[step] * scene->motion_shutter_time() * 0.5f; | float relative_time = motion_times[step] * scene->motion_shutter_time() * 0.5f; | ||||
| float3 *mP = attr_mP->data_float3() + step * mesh->verts.size(); | float3 *mP = attr_mP->data_float3() + step * mesh->verts.size(); | ||||
| BL::DomainFluidSettings::fluid_mesh_vertices_iterator fvi; | BL::FluidDomainSettings::mesh_vertices_iterator svi; | ||||
| int i = 0; | int i = 0; | ||||
| for (b_fluid_domain.fluid_mesh_vertices.begin(fvi); | for (b_manta_domain.mesh_vertices.begin(svi); svi != b_manta_domain.mesh_vertices.end(); | ||||
| fvi != b_fluid_domain.fluid_mesh_vertices.end(); | ++svi, ++i) { | ||||
| ++fvi, ++i) { | mP[i] = P[i] + get_float3(svi->velocity()) * relative_time; | ||||
| mP[i] = P[i] + get_float3(fvi->velocity()) * relative_time; | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| Mesh *BlenderSync::sync_mesh(BL::Depsgraph &b_depsgraph, | Mesh *BlenderSync::sync_mesh(BL::Depsgraph &b_depsgraph, | ||||
| BL::Object &b_ob, | BL::Object &b_ob, | ||||
| BL::Object &b_ob_instance, | BL::Object &b_ob_instance, | ||||
| bool object_updated, | bool object_updated, | ||||
| ▲ Show 20 Lines • Show All 123 Lines • ▼ Show 20 Lines | if (b_mesh) { | ||||
| sync_curves(mesh, b_mesh, b_ob, false); | sync_curves(mesh, b_mesh, b_ob, false); | ||||
| } | } | ||||
| free_object_to_mesh(b_data, b_ob, b_mesh); | free_object_to_mesh(b_data, b_ob, b_mesh); | ||||
| } | } | ||||
| } | } | ||||
| mesh->geometry_flags = requested_geometry_flags; | mesh->geometry_flags = requested_geometry_flags; | ||||
| /* fluid motion */ | /* mesh fluid motion mantaflow */ | ||||
| sync_mesh_fluid_motion(b_ob, scene, mesh); | sync_mesh_manta_motion(b_ob, scene, mesh); | ||||
| /* tag update */ | /* tag update */ | ||||
| bool rebuild = (oldtriangles != mesh->triangles) || (oldsubd_faces != mesh->subd_faces) || | bool rebuild = (oldtriangles != mesh->triangles) || (oldsubd_faces != mesh->subd_faces) || | ||||
| (oldsubd_face_corners != mesh->subd_face_corners) || | (oldsubd_face_corners != mesh->subd_face_corners) || | ||||
| (oldcurve_keys != mesh->curve_keys) || (oldcurve_radius != mesh->curve_radius) || | (oldcurve_keys != mesh->curve_keys) || (oldcurve_radius != mesh->curve_radius) || | ||||
| (oldhas_voxel_attributes != mesh->has_voxel_attributes()); | (oldhas_voxel_attributes != mesh->has_voxel_attributes()); | ||||
| mesh->tag_update(scene, rebuild); | mesh->tag_update(scene, rebuild); | ||||
| Show All 31 Lines | void BlenderSync::sync_mesh_motion(BL::Depsgraph &b_depsgraph, | ||||
| if (!numverts && !numkeys) | if (!numverts && !numkeys) | ||||
| return; | return; | ||||
| /* skip objects without deforming modifiers. this is not totally reliable, | /* skip objects without deforming modifiers. this is not totally reliable, | ||||
| * would need a more extensive check to see which objects are animated */ | * would need a more extensive check to see which objects are animated */ | ||||
| BL::Mesh b_mesh(PointerRNA_NULL); | BL::Mesh b_mesh(PointerRNA_NULL); | ||||
| /* fluid motion is exported immediate with mesh, skip here */ | /* manta motion is exported immediate with mesh, skip here */ | ||||
| BL::DomainFluidSettings b_fluid_domain = object_fluid_domain_find(b_ob); | BL::FluidDomainSettings b_manta_domain = object_fluid_domain_find(b_ob); | ||||
| if (b_fluid_domain) | if (b_manta_domain) | ||||
| return; | return; | ||||
| if (ccl::BKE_object_is_deform_modified(b_ob, b_scene, preview)) { | if (ccl::BKE_object_is_deform_modified(b_ob, b_scene, preview)) { | ||||
| /* get derived mesh */ | /* get derived mesh */ | ||||
| b_mesh = object_to_mesh(b_data, b_ob, b_depsgraph, false, Mesh::SUBDIVISION_NONE); | b_mesh = object_to_mesh(b_data, b_ob, b_depsgraph, false, Mesh::SUBDIVISION_NONE); | ||||
| } | } | ||||
| if (!b_mesh) { | if (!b_mesh) { | ||||
| ▲ Show 20 Lines • Show All 107 Lines • Show Last 20 Lines | |||||