Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/modes/object_mode.c
| Show All 30 Lines | |||||
| #include "DNA_gpencil_types.h" | #include "DNA_gpencil_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_lightprobe_types.h" | #include "DNA_lightprobe_types.h" | ||||
| #include "DNA_particle_types.h" | #include "DNA_particle_types.h" | ||||
| #include "DNA_rigidbody_types.h" | #include "DNA_rigidbody_types.h" | ||||
| #include "DNA_smoke_types.h" | #include "DNA_manta_types.h" | ||||
| #include "DNA_view3d_types.h" | #include "DNA_view3d_types.h" | ||||
| #include "DNA_screen_types.h" | #include "DNA_screen_types.h" | ||||
| #include "DNA_world_types.h" | #include "DNA_world_types.h" | ||||
| #include "BKE_anim.h" | #include "BKE_anim.h" | ||||
| #include "BKE_camera.h" | #include "BKE_camera.h" | ||||
| #include "BKE_constraint.h" | #include "BKE_constraint.h" | ||||
| #include "BKE_curve.h" | #include "BKE_curve.h" | ||||
| ▲ Show 20 Lines • Show All 2,619 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| static void DRW_shgroup_volume_extra(OBJECT_ShadingGroupList *sgl, | static void DRW_shgroup_volume_extra(OBJECT_ShadingGroupList *sgl, | ||||
| Object *ob, | Object *ob, | ||||
| ViewLayer *view_layer, | ViewLayer *view_layer, | ||||
| Scene *scene, | Scene *scene, | ||||
| ModifierData *md) | ModifierData *md) | ||||
| { | { | ||||
| SmokeModifierData *smd = (SmokeModifierData *)md; | MantaModifierData *mmd = (MantaModifierData *)md; | ||||
| SmokeDomainSettings *sds = smd->domain; | MantaDomainSettings *mds = mmd->domain; | ||||
| float *color; | float *color; | ||||
| float one = 1.0f; | float one = 1.0f; | ||||
| if (sds == NULL) { | if (mds == NULL) { | ||||
| return; | return; | ||||
| } | } | ||||
| DRW_object_wire_theme_get(ob, view_layer, &color); | DRW_object_wire_theme_get(ob, view_layer, &color); | ||||
| /* Small cube showing voxel size. */ | /* Small cube showing voxel size (adjusts with adaptive domain) */ | ||||
| float min[3], max[3], size[3]; | |||||
| madd_v3fl_v3fl_v3fl_v3i(min, mds->p0, mds->cell_size, mds->res_min); | |||||
| madd_v3fl_v3fl_v3fl_v3i(max, mds->p0, mds->cell_size, mds->res_max); | |||||
| sub_v3_v3v3(size, max, min); | |||||
| float voxel_cubemat[4][4] = {{0.0f}}; | float voxel_cubemat[4][4] = {{0.0f}}; | ||||
| voxel_cubemat[0][0] = 1.0f / (float)sds->res[0]; | /* scale small cube */ | ||||
| voxel_cubemat[1][1] = 1.0f / (float)sds->res[1]; | voxel_cubemat[0][0] = (1.0f / (float)mds->res[0]) * size[0] * ob->obmat[0][0] * 0.5; | ||||
| voxel_cubemat[2][2] = 1.0f / (float)sds->res[2]; | voxel_cubemat[1][1] = (1.0f / (float)mds->res[1]) * size[1] * ob->obmat[1][1] * 0.5; | ||||
| voxel_cubemat[3][0] = voxel_cubemat[3][1] = voxel_cubemat[3][2] = -1.0f; | voxel_cubemat[2][2] = (1.0f / (float)mds->res[2]) * size[2] * ob->obmat[2][2] * 0.5; | ||||
| /* translate small cube */ | |||||
| voxel_cubemat[3][0] = min[0] * ob->obmat[0][0] + ob->obmat[3][0]; | |||||
| voxel_cubemat[3][1] = min[1] * ob->obmat[1][1] + ob->obmat[3][1]; | |||||
| voxel_cubemat[3][2] = min[2] * ob->obmat[2][2] + ob->obmat[3][2]; | |||||
| voxel_cubemat[3][3] = 1.0f; | voxel_cubemat[3][3] = 1.0f; | ||||
| /* move small cube into the domain (before centered on vertex) */ | |||||
| 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); | |||||
| DRW_buffer_add_entry(sgl->empties.cube, color, &one, voxel_cubemat); | DRW_buffer_add_entry(sgl->empties.cube, color, &one, voxel_cubemat); | ||||
| /* 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. */ | ||||
| if (!sds->draw_velocity || !sds->fluid || CFRA < sds->point_cache[0]->startframe) { | if (!mds->draw_velocity || !mds->fluid || CFRA < mds->point_cache[0]->startframe) { | ||||
| return; | return; | ||||
| } | } | ||||
| 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); | ||||
| DRWShadingGroup *grp = DRW_shgroup_create(volume_velocity_shader_get(use_needle), | DRWShadingGroup *grp = DRW_shgroup_create(volume_velocity_shader_get(use_needle), | ||||
| sgl->non_meshes); | sgl->non_meshes); | ||||
| 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_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(&e_data.smoke_domains, BLI_genericNodeN(smd)); | BLI_addtail(&e_data.smoke_domains, BLI_genericNodeN(mmd)); | ||||
| } | } | ||||
| static void volumes_free_smoke_textures(void) | static void volumes_free_smoke_textures(void) | ||||
| { | { | ||||
| /* 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. */ | ||||
| for (LinkData *link = e_data.smoke_domains.first; link; link = link->next) { | for (LinkData *link = e_data.smoke_domains.first; link; link = link->next) { | ||||
| SmokeModifierData *smd = (SmokeModifierData *)link->data; | MantaModifierData *mmd = (MantaModifierData *)link->data; | ||||
| GPU_free_smoke_velocity(smd); | GPU_free_smoke_velocity(mmd); | ||||
| } | } | ||||
| BLI_freelistN(&e_data.smoke_domains); | BLI_freelistN(&e_data.smoke_domains); | ||||
| } | } | ||||
| static void DRW_shgroup_speaker(OBJECT_ShadingGroupList *sgl, Object *ob, ViewLayer *view_layer) | static void DRW_shgroup_speaker(OBJECT_ShadingGroupList *sgl, Object *ob, ViewLayer *view_layer) | ||||
| { | { | ||||
| float *color; | float *color; | ||||
| static float one = 1.0f; | static float one = 1.0f; | ||||
| ▲ Show 20 Lines • Show All 970 Lines • ▼ Show 20 Lines | if ((ob->base_flag & (BASE_FROM_SET | BASE_FROM_DUPLI)) == 0) { | ||||
| if (ob->dtx & OB_AXIS) { | if (ob->dtx & OB_AXIS) { | ||||
| float *color, axes_size = 1.0f; | float *color, axes_size = 1.0f; | ||||
| DRW_object_wire_theme_get(ob, view_layer, &color); | DRW_object_wire_theme_get(ob, view_layer, &color); | ||||
| DRW_buffer_add_entry(sgl->empties.empty_axes, color, &axes_size, ob->obmat); | DRW_buffer_add_entry(sgl->empties.empty_axes, color, &axes_size, ob->obmat); | ||||
| } | } | ||||
| if ((md = modifiers_findByType(ob, eModifierType_Smoke)) && | if ((md = modifiers_findByType(ob, eModifierType_Manta)) && | ||||
| (modifier_isEnabled(scene, md, eModifierMode_Realtime)) && | (modifier_isEnabled(scene, md, eModifierMode_Realtime)) && | ||||
| (((SmokeModifierData *)md)->domain != NULL)) { | (((MantaModifierData *)md)->domain != NULL)) { | ||||
| DRW_shgroup_volume_extra(sgl, ob, view_layer, scene, md); | DRW_shgroup_volume_extra(sgl, ob, view_layer, scene, md); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void OBJECT_cache_finish(void *vedata) | static void OBJECT_cache_finish(void *vedata) | ||||
| { | { | ||||
| OBJECT_StorageList *stl = ((OBJECT_Data *)vedata)->stl; | OBJECT_StorageList *stl = ((OBJECT_Data *)vedata)->stl; | ||||
| ▲ Show 20 Lines • Show All 177 Lines • Show Last 20 Lines | |||||