Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/blender/blender_mesh.cpp
| Show First 20 Lines • Show All 928 Lines • ▼ Show 20 Lines | static void create_subd_mesh(Scene *scene, | ||||
| scene->dicing_camera->update(scene); | scene->dicing_camera->update(scene); | ||||
| sdparams.camera = scene->dicing_camera; | sdparams.camera = scene->dicing_camera; | ||||
| sdparams.objecttoworld = get_transform(b_ob.matrix_world()); | sdparams.objecttoworld = get_transform(b_ob.matrix_world()); | ||||
| } | } | ||||
| /* Sync */ | /* Sync */ | ||||
| static void sync_mesh_manta_motion(BL::Object& b_ob, Scene *scene, Mesh *mesh) | |||||
| { | |||||
| if(scene->need_motion() == Scene::MOTION_NONE) | |||||
| return; | |||||
| BL::SmokeDomainSettings b_smoke_domain = object_smoke_domain_find(b_ob); | |||||
| if(!b_smoke_domain) | |||||
| return; | |||||
| /* If the mesh has modifiers following the fluid domain we can't export motion. */ | |||||
| if(b_smoke_domain.mesh_vertices.length() != mesh->verts.size()) | |||||
| return; | |||||
| /* Find or add attribute */ | |||||
| float3 *P = &mesh->verts[0]; | |||||
| Attribute *attr_mP = mesh->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION); | |||||
| if(!attr_mP) { | |||||
| attr_mP = mesh->attributes.add(ATTR_STD_MOTION_VERTEX_POSITION); | |||||
| } | |||||
| /* Only export previous and next frame, we don't have any in between data. */ | |||||
| float motion_times[2] = {-1.0f, 1.0f}; | |||||
| for(int step = 0; step < 2; step++) { | |||||
| float relative_time = motion_times[step] * scene->motion_shutter_time() * 0.5f; | |||||
| float3 *mP = attr_mP->data_float3() + step*mesh->verts.size(); | |||||
| BL::SmokeDomainSettings::mesh_vertices_iterator svi; | |||||
| int i = 0; | |||||
| for(b_smoke_domain.mesh_vertices.begin(svi); svi != b_smoke_domain.mesh_vertices.end(); ++svi, ++i) { | |||||
| mP[i] = P[i] + get_float3(svi->velocity()) * relative_time; | |||||
| } | |||||
| } | |||||
| } | |||||
| static void sync_mesh_fluid_motion(BL::Object& b_ob, Scene *scene, Mesh *mesh) | static void sync_mesh_fluid_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::DomainFluidSettings b_fluid_domain = object_fluid_domain_find(b_ob); | ||||
| if(!b_fluid_domain) | if(!b_fluid_domain) | ||||
| ▲ Show 20 Lines • Show All 151 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; | ||||
| /* mesh fluid motion mantaflow */ | |||||
| sync_mesh_manta_motion(b_ob, scene, mesh); | |||||
| /* fluid motion */ | /* fluid motion */ | ||||
| sync_mesh_fluid_motion(b_ob, scene, mesh); | sync_mesh_fluid_motion(b_ob, scene, mesh); | ||||
| /* tag update */ | /* tag update */ | ||||
| bool rebuild = (oldtriangles != mesh->triangles) || | bool rebuild = (oldtriangles != mesh->triangles) || | ||||
| (oldsubd_faces != mesh->subd_faces) || | (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_keys != mesh->curve_keys) || | ||||
| Show All 34 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); | ||||
| /* manta motion is exported immediate with mesh, skip here */ | |||||
| BL::SmokeDomainSettings b_smoke_domain = object_smoke_domain_find(b_ob); | |||||
| if(b_smoke_domain) | |||||
| return; | |||||
| /* fluid motion is exported immediate with mesh, skip here */ | /* fluid motion is exported immediate with mesh, skip here */ | ||||
| BL::DomainFluidSettings b_fluid_domain = object_fluid_domain_find(b_ob); | BL::DomainFluidSettings b_fluid_domain = object_fluid_domain_find(b_ob); | ||||
| if(b_fluid_domain) | if(b_fluid_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_mesh = object_to_mesh(b_data, | ||||
| ▲ Show 20 Lines • Show All 117 Lines • Show Last 20 Lines | |||||