Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/fluid.c
| Show First 20 Lines • Show All 1,783 Lines • ▼ Show 20 Lines | static void update_distances(int index, | ||||
| CLAMP(distance_map[index], -PHI_MAX, PHI_MAX); | CLAMP(distance_map[index], -PHI_MAX, PHI_MAX); | ||||
| } | } | ||||
| static void sample_mesh(FluidFlowSettings *ffs, | static void sample_mesh(FluidFlowSettings *ffs, | ||||
| const float (*vert_positions)[3], | const float (*vert_positions)[3], | ||||
| const float (*vert_normals)[3], | const float (*vert_normals)[3], | ||||
| const MLoop *mloop, | const MLoop *mloop, | ||||
| const MLoopTri *mlooptri, | const MLoopTri *mlooptri, | ||||
| const MLoopUV *mloopuv, | const float (*mloopuv)[2], | ||||
| float *influence_map, | float *influence_map, | ||||
| float *velocity_map, | float *velocity_map, | ||||
| int index, | int index, | ||||
| const int base_res[3], | const int base_res[3], | ||||
| const float global_size[3], | const float global_size[3], | ||||
| const float flow_center[3], | const float flow_center[3], | ||||
| BVHTreeFromMesh *tree_data, | BVHTreeFromMesh *tree_data, | ||||
| const float ray_start[3], | const float ray_start[3], | ||||
| ▲ Show 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | if (is_gas_flow) { | ||||
| if (ffs->texture_type == FLUID_FLOW_TEXTURE_MAP_AUTO) { | if (ffs->texture_type == FLUID_FLOW_TEXTURE_MAP_AUTO) { | ||||
| tex_co[0] = ((x - flow_center[0]) / base_res[0]) / ffs->texture_size; | tex_co[0] = ((x - flow_center[0]) / base_res[0]) / ffs->texture_size; | ||||
| tex_co[1] = ((y - flow_center[1]) / base_res[1]) / ffs->texture_size; | tex_co[1] = ((y - flow_center[1]) / base_res[1]) / ffs->texture_size; | ||||
| tex_co[2] = ((z - flow_center[2]) / base_res[2] - ffs->texture_offset) / | tex_co[2] = ((z - flow_center[2]) / base_res[2] - ffs->texture_offset) / | ||||
| ffs->texture_size; | ffs->texture_size; | ||||
| } | } | ||||
| else if (mloopuv) { | else if (mloopuv) { | ||||
| const float *uv[3]; | const float *uv[3]; | ||||
| uv[0] = mloopuv[mlooptri[f_index].tri[0]].uv; | uv[0] = mloopuv[mlooptri[f_index].tri[0]]; | ||||
| uv[1] = mloopuv[mlooptri[f_index].tri[1]].uv; | uv[1] = mloopuv[mlooptri[f_index].tri[1]]; | ||||
| uv[2] = mloopuv[mlooptri[f_index].tri[2]].uv; | uv[2] = mloopuv[mlooptri[f_index].tri[2]]; | ||||
| interp_v2_v2v2v2(tex_co, UNPACK3(uv), weights); | interp_v2_v2v2v2(tex_co, UNPACK3(uv), weights); | ||||
| /* Map texture coord between -1.0f and 1.0f. */ | /* Map texture coord between -1.0f and 1.0f. */ | ||||
| tex_co[0] = tex_co[0] * 2.0f - 1.0f; | tex_co[0] = tex_co[0] * 2.0f - 1.0f; | ||||
| tex_co[1] = tex_co[1] * 2.0f - 1.0f; | tex_co[1] = tex_co[1] * 2.0f - 1.0f; | ||||
| tex_co[2] = ffs->texture_offset; | tex_co[2] = ffs->texture_offset; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | |||||
| typedef struct EmitFromDMData { | typedef struct EmitFromDMData { | ||||
| FluidDomainSettings *fds; | FluidDomainSettings *fds; | ||||
| FluidFlowSettings *ffs; | FluidFlowSettings *ffs; | ||||
| const float (*vert_positions)[3]; | const float (*vert_positions)[3]; | ||||
| const float (*vert_normals)[3]; | const float (*vert_normals)[3]; | ||||
| const MLoop *mloop; | const MLoop *mloop; | ||||
| const MLoopTri *mlooptri; | const MLoopTri *mlooptri; | ||||
| const MLoopUV *mloopuv; | const float (*mloopuv)[2]; | ||||
| const MDeformVert *dvert; | const MDeformVert *dvert; | ||||
| int defgrp_index; | int defgrp_index; | ||||
| BVHTreeFromMesh *tree; | BVHTreeFromMesh *tree; | ||||
| FluidObjectBB *bb; | FluidObjectBB *bb; | ||||
| bool has_velocity; | bool has_velocity; | ||||
| float *vert_vel; | float *vert_vel; | ||||
| ▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | if (ffs->mesh) { | ||||
| * Main issue is its VertArray being modified, then replaced and freed. */ | * Main issue is its VertArray being modified, then replaced and freed. */ | ||||
| Mesh *me = BKE_mesh_copy_for_eval(ffs->mesh, false); | Mesh *me = BKE_mesh_copy_for_eval(ffs->mesh, false); | ||||
| float(*positions)[3] = BKE_mesh_vert_positions_for_write(me); | float(*positions)[3] = BKE_mesh_vert_positions_for_write(me); | ||||
| const MLoop *mloop = BKE_mesh_loops(me); | const MLoop *mloop = BKE_mesh_loops(me); | ||||
| const MLoopTri *mlooptri = BKE_mesh_runtime_looptri_ensure(me); | const MLoopTri *mlooptri = BKE_mesh_runtime_looptri_ensure(me); | ||||
| const int numverts = me->totvert; | const int numverts = me->totvert; | ||||
| const MDeformVert *dvert = BKE_mesh_deform_verts(me); | const MDeformVert *dvert = BKE_mesh_deform_verts(me); | ||||
| const MLoopUV *mloopuv = CustomData_get_layer_named(&me->ldata, CD_MLOOPUV, ffs->uvlayer_name); | const float(*mloopuv)[2] = CustomData_get_layer_named( | ||||
| &me->ldata, CD_PROP_FLOAT2, ffs->uvlayer_name); | |||||
| if (ffs->flags & FLUID_FLOW_INITVELOCITY) { | if (ffs->flags & FLUID_FLOW_INITVELOCITY) { | ||||
| vert_vel = MEM_callocN(sizeof(float[3]) * numverts, "manta_flow_velocity"); | vert_vel = MEM_callocN(sizeof(float[3]) * numverts, "manta_flow_velocity"); | ||||
| if (ffs->numverts != numverts || !ffs->verts_old) { | if (ffs->numverts != numverts || !ffs->verts_old) { | ||||
| if (ffs->verts_old) { | if (ffs->verts_old) { | ||||
| MEM_freeN(ffs->verts_old); | MEM_freeN(ffs->verts_old); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 3,024 Lines • Show Last 20 Lines | |||||