Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/overlay/overlay_extra.c
| Show All 39 Lines | |||||
| #include "DNA_constraint_types.h" | #include "DNA_constraint_types.h" | ||||
| #include "DNA_gpencil_types.h" | #include "DNA_gpencil_types.h" | ||||
| #include "DNA_lightprobe_types.h" | #include "DNA_lightprobe_types.h" | ||||
| #include "DNA_mesh_types.h" | #include "DNA_mesh_types.h" | ||||
| #include "DNA_meta_types.h" | #include "DNA_meta_types.h" | ||||
| #include "DNA_modifier_types.h" | #include "DNA_modifier_types.h" | ||||
| #include "DNA_object_force_types.h" | #include "DNA_object_force_types.h" | ||||
| #include "DNA_rigidbody_types.h" | #include "DNA_rigidbody_types.h" | ||||
| #include "DNA_smoke_types.h" | #include "DNA_fluid_types.h" | ||||
| #include "DEG_depsgraph_query.h" | #include "DEG_depsgraph_query.h" | ||||
| #include "ED_view3d.h" | #include "ED_view3d.h" | ||||
| #include "GPU_draw.h" | #include "GPU_draw.h" | ||||
| #include "overlay_private.h" | #include "overlay_private.h" | ||||
| ▲ Show 20 Lines • Show All 1,348 Lines • ▼ Show 20 Lines | |||||
| static void OVERLAY_volume_extra(OVERLAY_ExtraCallBuffers *cb, | static void OVERLAY_volume_extra(OVERLAY_ExtraCallBuffers *cb, | ||||
| OVERLAY_Data *data, | OVERLAY_Data *data, | ||||
| Object *ob, | Object *ob, | ||||
| ModifierData *md, | ModifierData *md, | ||||
| Scene *scene, | Scene *scene, | ||||
| float *color) | float *color) | ||||
| { | { | ||||
| SmokeModifierData *smd = (SmokeModifierData *)md; | FluidModifierData *mmd = (FluidModifierData *)md; | ||||
| SmokeDomainSettings *sds = smd->domain; | FluidDomainSettings *mds = mmd->domain; | ||||
| /* Don't show smoke before simulation starts, this could be made an option in the future. */ | /* Don't show smoke before simulation starts, this could be made an option in the future. */ | ||||
| const bool draw_velocity = (sds->draw_velocity && sds->fluid && | const bool draw_velocity = (mds->draw_velocity && mds->fluid && | ||||
| CFRA >= sds->point_cache[0]->startframe); | CFRA >= mds->point_cache[0]->startframe); | ||||
| /* Small cube showing voxel size. */ | /* Small cube showing voxel size. */ | ||||
| { | { | ||||
| float min[3]; | float min[3]; | ||||
| madd_v3fl_v3fl_v3fl_v3i(min, sds->p0, sds->cell_size, sds->res_min); | madd_v3fl_v3fl_v3fl_v3i(min, mds->p0, mds->cell_size, mds->res_min); | ||||
| float voxel_cubemat[4][4] = {{0.0f}}; | float voxel_cubemat[4][4] = {{0.0f}}; | ||||
| /* scale small cube to voxel size */ | /* scale small cube to voxel size */ | ||||
| voxel_cubemat[0][0] = 1.0f / (float)sds->base_res[0]; | voxel_cubemat[0][0] = 1.0f / (float)mds->base_res[0]; | ||||
| voxel_cubemat[1][1] = 1.0f / (float)sds->base_res[1]; | voxel_cubemat[1][1] = 1.0f / (float)mds->base_res[1]; | ||||
| voxel_cubemat[2][2] = 1.0f / (float)sds->base_res[2]; | voxel_cubemat[2][2] = 1.0f / (float)mds->base_res[2]; | ||||
| voxel_cubemat[3][3] = 1.0f; | voxel_cubemat[3][3] = 1.0f; | ||||
| /* translate small cube to corner */ | /* translate small cube to corner */ | ||||
| copy_v3_v3(voxel_cubemat[3], min); | copy_v3_v3(voxel_cubemat[3], min); | ||||
| /* move small cube into the domain (otherwise its centered on vertex of domain object) */ | /* move small cube into the domain (otherwise its centered on vertex of domain object) */ | ||||
| translate_m4(voxel_cubemat, 1.0f, 1.0f, 1.0f); | translate_m4(voxel_cubemat, 1.0f, 1.0f, 1.0f); | ||||
| mul_m4_m4m4(voxel_cubemat, ob->obmat, voxel_cubemat); | mul_m4_m4m4(voxel_cubemat, ob->obmat, voxel_cubemat); | ||||
| DRW_buffer_add_entry(cb->empty_cube, color, voxel_cubemat); | DRW_buffer_add_entry(cb->empty_cube, color, voxel_cubemat); | ||||
| } | } | ||||
| if (draw_velocity) { | if (draw_velocity) { | ||||
| const bool use_needle = (sds->vector_draw_type == VECTOR_DRAW_NEEDLE); | const bool use_needle = (mds->vector_draw_type == VECTOR_DRAW_NEEDLE); | ||||
| int line_count = (use_needle) ? 6 : 1; | int line_count = (use_needle) ? 6 : 1; | ||||
| int slice_axis = -1; | int slice_axis = -1; | ||||
| line_count *= sds->res[0] * sds->res[1] * sds->res[2]; | line_count *= mds->res[0] * mds->res[1] * mds->res[2]; | ||||
| if (sds->slice_method == MOD_SMOKE_SLICE_AXIS_ALIGNED && | if (mds->slice_method == FLUID_DOMAIN_SLICE_AXIS_ALIGNED && | ||||
| sds->axis_slice_method == AXIS_SLICE_SINGLE) { | mds->axis_slice_method == AXIS_SLICE_SINGLE) { | ||||
| float viewinv[4][4]; | float viewinv[4][4]; | ||||
| DRW_view_viewmat_get(NULL, viewinv, true); | DRW_view_viewmat_get(NULL, viewinv, true); | ||||
| const int axis = (sds->slice_axis == SLICE_AXIS_AUTO) ? axis_dominant_v3_single(viewinv[2]) : | const int axis = (mds->slice_axis == SLICE_AXIS_AUTO) ? axis_dominant_v3_single(viewinv[2]) : | ||||
| sds->slice_axis - 1; | mds->slice_axis - 1; | ||||
| slice_axis = axis; | slice_axis = axis; | ||||
| line_count /= sds->res[axis]; | line_count /= mds->res[axis]; | ||||
| } | } | ||||
| GPU_create_smoke_velocity(smd); | GPU_create_smoke_velocity(mmd); | ||||
| GPUShader *sh = OVERLAY_shader_volume_velocity(use_needle); | GPUShader *sh = OVERLAY_shader_volume_velocity(use_needle); | ||||
| DRWShadingGroup *grp = DRW_shgroup_create(sh, data->psl->extra_ps[0]); | DRWShadingGroup *grp = DRW_shgroup_create(sh, data->psl->extra_ps[0]); | ||||
| DRW_shgroup_uniform_texture(grp, "velocityX", sds->tex_velocity_x); | DRW_shgroup_uniform_texture(grp, "velocityX", mds->tex_velocity_x); | ||||
| DRW_shgroup_uniform_texture(grp, "velocityY", sds->tex_velocity_y); | DRW_shgroup_uniform_texture(grp, "velocityY", mds->tex_velocity_y); | ||||
| DRW_shgroup_uniform_texture(grp, "velocityZ", sds->tex_velocity_z); | DRW_shgroup_uniform_texture(grp, "velocityZ", mds->tex_velocity_z); | ||||
| DRW_shgroup_uniform_float_copy(grp, "displaySize", sds->vector_scale); | DRW_shgroup_uniform_float_copy(grp, "displaySize", mds->vector_scale); | ||||
| DRW_shgroup_uniform_float_copy(grp, "slicePosition", sds->slice_depth); | DRW_shgroup_uniform_float_copy(grp, "slicePosition", mds->slice_depth); | ||||
| DRW_shgroup_uniform_vec3_copy(grp, "cellSize", sds->cell_size); | DRW_shgroup_uniform_vec3_copy(grp, "cellSize", mds->cell_size); | ||||
| DRW_shgroup_uniform_vec3_copy(grp, "domainOriginOffset", sds->p0); | DRW_shgroup_uniform_vec3_copy(grp, "domainOriginOffset", mds->p0); | ||||
| DRW_shgroup_uniform_ivec3_copy(grp, "adaptiveCellOffset", sds->res_min); | DRW_shgroup_uniform_ivec3_copy(grp, "adaptiveCellOffset", mds->res_min); | ||||
| DRW_shgroup_uniform_int_copy(grp, "sliceAxis", slice_axis); | DRW_shgroup_uniform_int_copy(grp, "sliceAxis", slice_axis); | ||||
| DRW_shgroup_call_procedural_lines(grp, ob, line_count); | DRW_shgroup_call_procedural_lines(grp, ob, line_count); | ||||
| BLI_addtail(&data->stl->pd->smoke_domains, BLI_genericNodeN(smd)); | BLI_addtail(&data->stl->pd->smoke_domains, BLI_genericNodeN(mmd)); | ||||
| } | } | ||||
| } | } | ||||
| static void OVERLAY_volume_free_smoke_textures(OVERLAY_Data *data) | static void OVERLAY_volume_free_smoke_textures(OVERLAY_Data *data) | ||||
| { | { | ||||
| /* Free Smoke Textures after rendering */ | /* Free Smoke Textures after rendering */ | ||||
| /* XXX This is a waste of processing and GPU bandwidth if nothing | /* XXX This is a waste of processing and GPU bandwidth if nothing | ||||
| * is updated. But the problem is since Textures are stored in the | * is updated. But the problem is since Textures are stored in the | ||||
| * modifier we don't want them to take precious VRAM if the | * modifier we don't want them to take precious VRAM if the | ||||
| * modifier is not used for display. We should share them for | * modifier is not used for display. We should share them for | ||||
| * all viewport in a redraw at least. */ | * all viewport in a redraw at least. */ | ||||
| LinkData *link; | LinkData *link; | ||||
| while ((link = BLI_pophead(&data->stl->pd->smoke_domains))) { | while ((link = BLI_pophead(&data->stl->pd->smoke_domains))) { | ||||
| SmokeModifierData *smd = (SmokeModifierData *)link->data; | FluidModifierData *mmd = (FluidModifierData *)link->data; | ||||
| GPU_free_smoke_velocity(smd); | GPU_free_smoke_velocity(mmd); | ||||
| MEM_freeN(link); | MEM_freeN(link); | ||||
| } | } | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| ▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | const bool draw_obcenters = !is_paint_mode && | ||||
| (pd->overlay.flag & V3D_OVERLAY_HIDE_OBJECT_ORIGINS) == 0; | (pd->overlay.flag & V3D_OVERLAY_HIDE_OBJECT_ORIGINS) == 0; | ||||
| const bool draw_texspace = (ob->dtx & OB_TEXSPACE) && has_texspace; | const bool draw_texspace = (ob->dtx & OB_TEXSPACE) && has_texspace; | ||||
| const bool draw_obname = (ob->dtx & OB_DRAWNAME) && DRW_state_show_text(); | const bool draw_obname = (ob->dtx & OB_DRAWNAME) && DRW_state_show_text(); | ||||
| const bool draw_bounds = has_bounds && ((ob->dt == OB_BOUNDBOX) || | const bool draw_bounds = has_bounds && ((ob->dt == OB_BOUNDBOX) || | ||||
| ((ob->dtx & OB_DRAWBOUNDOX) && !from_dupli)); | ((ob->dtx & OB_DRAWBOUNDOX) && !from_dupli)); | ||||
| const bool draw_xform = draw_ctx->object_mode == OB_MODE_OBJECT && | const bool draw_xform = draw_ctx->object_mode == OB_MODE_OBJECT && | ||||
| (scene->toolsettings->transform_flag & SCE_XFORM_DATA_ORIGIN) && | (scene->toolsettings->transform_flag & SCE_XFORM_DATA_ORIGIN) && | ||||
| (ob->base_flag & BASE_SELECTED) && !is_select_mode; | (ob->base_flag & BASE_SELECTED) && !is_select_mode; | ||||
| const bool draw_volume = !from_dupli && (md = modifiers_findByType(ob, eModifierType_Smoke)) && | const bool draw_volume = !from_dupli && (md = modifiers_findByType(ob, eModifierType_Fluid)) && | ||||
| (modifier_isEnabled(scene, md, eModifierMode_Realtime)) && | (modifier_isEnabled(scene, md, eModifierMode_Realtime)) && | ||||
| (((SmokeModifierData *)md)->domain != NULL); | (((FluidModifierData *)md)->domain != NULL); | ||||
| float *color; | float *color; | ||||
| int theme_id = DRW_object_wire_theme_get(ob, view_layer, &color); | int theme_id = DRW_object_wire_theme_get(ob, view_layer, &color); | ||||
| if (ob->pd && ob->pd->forcefield) { | if (ob->pd && ob->pd->forcefield) { | ||||
| OVERLAY_forcefield(cb, ob, view_layer); | OVERLAY_forcefield(cb, ob, view_layer); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 58 Lines • Show Last 20 Lines | |||||