Refactor: Access object data through accessor function in draw module
To prepare for customizing this for Meshes. Do it for everything so copy-pasting code is more likely to do the right thing. Pull Request: https://projects.blender.org/blender/blender/pulls/135895
This commit is contained in:
@@ -389,13 +389,13 @@ void LightModule::begin_sync()
|
||||
|
||||
void LightModule::sync_light(const Object *ob, ObjectHandle &handle)
|
||||
{
|
||||
const ::Light *la = static_cast<const ::Light *>(ob->data);
|
||||
const ::Light &la = DRW_object_get_data_for_drawing<const ::Light>(*ob);
|
||||
if (use_scene_lights_ == false) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (use_sun_lights_ == false) {
|
||||
if (la->type == LA_SUN) {
|
||||
if (la.type == LA_SUN) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -407,7 +407,7 @@ void LightModule::sync_light(const Object *ob, ObjectHandle &handle)
|
||||
light.sync(inst_.shadows,
|
||||
ob->object_to_world(),
|
||||
ob->visibility_flag,
|
||||
la,
|
||||
&la,
|
||||
ob->light_linking,
|
||||
light_threshold_);
|
||||
}
|
||||
|
||||
@@ -75,33 +75,33 @@ void LightProbeModule::sync_volume(const Object *ob, ObjectHandle &handle)
|
||||
VolumeProbe &grid = volume_map_.lookup_or_add_default(handle.object_key);
|
||||
grid.used = true;
|
||||
if (handle.recalc != 0 || grid.initialized == false) {
|
||||
const ::LightProbe *lightprobe = static_cast<const ::LightProbe *>(ob->data);
|
||||
const ::LightProbe &lightprobe = DRW_object_get_data_for_drawing<const ::LightProbe>(*ob);
|
||||
|
||||
grid.initialized = true;
|
||||
grid.updated = true;
|
||||
grid.surfel_density = static_cast<const ::LightProbe *>(ob->data)->grid_surfel_density;
|
||||
grid.surfel_density = lightprobe.grid_surfel_density;
|
||||
grid.object_to_world = ob->object_to_world();
|
||||
grid.cache = ob->lightprobe_cache;
|
||||
|
||||
grid.world_to_object = float4x4(
|
||||
math::normalize(math::transpose(float3x3(grid.object_to_world))));
|
||||
|
||||
grid.normal_bias = lightprobe->grid_normal_bias;
|
||||
grid.view_bias = lightprobe->grid_view_bias;
|
||||
grid.facing_bias = lightprobe->grid_facing_bias;
|
||||
grid.normal_bias = lightprobe.grid_normal_bias;
|
||||
grid.view_bias = lightprobe.grid_view_bias;
|
||||
grid.facing_bias = lightprobe.grid_facing_bias;
|
||||
|
||||
grid.validity_threshold = lightprobe->grid_validity_threshold;
|
||||
grid.dilation_threshold = lightprobe->grid_dilation_threshold;
|
||||
grid.dilation_radius = lightprobe->grid_dilation_radius;
|
||||
grid.intensity = lightprobe->intensity;
|
||||
grid.validity_threshold = lightprobe.grid_validity_threshold;
|
||||
grid.dilation_threshold = lightprobe.grid_dilation_threshold;
|
||||
grid.dilation_radius = lightprobe.grid_dilation_radius;
|
||||
grid.intensity = lightprobe.intensity;
|
||||
|
||||
const bool has_valid_cache = grid.cache && grid.cache->grid_static_cache;
|
||||
grid.viewport_display = has_valid_cache && (lightprobe->flag & LIGHTPROBE_FLAG_SHOW_DATA);
|
||||
grid.viewport_display = has_valid_cache && (lightprobe.flag & LIGHTPROBE_FLAG_SHOW_DATA);
|
||||
if (grid.viewport_display) {
|
||||
int3 cache_size = grid.cache->grid_static_cache->size;
|
||||
float3 scale = math::transform_direction(ob->object_to_world(),
|
||||
1.0f / float3(cache_size + 1));
|
||||
grid.viewport_display_size = math::reduce_min(scale) * lightprobe->data_display_size;
|
||||
grid.viewport_display_size = math::reduce_min(scale) * lightprobe.data_display_size;
|
||||
}
|
||||
|
||||
/* Force reupload. */
|
||||
@@ -114,7 +114,7 @@ void LightProbeModule::sync_sphere(const Object *ob, ObjectHandle &handle)
|
||||
SphereProbe &cube = sphere_map_.lookup_or_add_default(handle.object_key);
|
||||
cube.used = true;
|
||||
if (handle.recalc != 0 || cube.initialized == false) {
|
||||
const ::LightProbe &light_probe = *(::LightProbe *)ob->data;
|
||||
const ::LightProbe &light_probe = DRW_object_get_data_for_drawing<::LightProbe>(*ob);
|
||||
|
||||
cube.initialized = true;
|
||||
cube.updated = true;
|
||||
@@ -168,23 +168,23 @@ void LightProbeModule::sync_planar(const Object *ob, ObjectHandle &handle)
|
||||
PlanarProbe &plane = planar_map_.lookup_or_add_default(handle.object_key);
|
||||
plane.used = true;
|
||||
if (handle.recalc != 0 || plane.initialized == false) {
|
||||
const ::LightProbe *light_probe = (::LightProbe *)ob->data;
|
||||
const ::LightProbe &light_probe = DRW_object_get_data_for_drawing<::LightProbe>(*ob);
|
||||
|
||||
plane.initialized = true;
|
||||
plane.updated = true;
|
||||
plane.plane_to_world = ob->object_to_world();
|
||||
plane.plane_to_world.z_axis() = math::normalize(plane.plane_to_world.z_axis()) *
|
||||
light_probe->distinf;
|
||||
light_probe.distinf;
|
||||
plane.world_to_plane = math::invert(plane.plane_to_world);
|
||||
plane.clipping_offset = light_probe->clipsta;
|
||||
plane.viewport_display = (light_probe->flag & LIGHTPROBE_FLAG_SHOW_DATA) != 0;
|
||||
plane.clipping_offset = light_probe.clipsta;
|
||||
plane.viewport_display = (light_probe.flag & LIGHTPROBE_FLAG_SHOW_DATA) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
void LightProbeModule::sync_probe(const Object *ob, ObjectHandle &handle)
|
||||
{
|
||||
const ::LightProbe *lightprobe = static_cast<const ::LightProbe *>(ob->data);
|
||||
switch (lightprobe->type) {
|
||||
const ::LightProbe &lightprobe = DRW_object_get_data_for_drawing<const ::LightProbe>(*ob);
|
||||
switch (lightprobe.type) {
|
||||
case LIGHTPROBE_TYPE_SPHERE:
|
||||
sync_sphere(ob, handle);
|
||||
return;
|
||||
|
||||
@@ -695,14 +695,14 @@ void IrradianceBake::init(const Object &probe_object)
|
||||
{
|
||||
float max_axis_len = math::reduce_max(math::to_scale(probe_object.object_to_world()));
|
||||
|
||||
const ::LightProbe *lightprobe = static_cast<::LightProbe *>(probe_object.data);
|
||||
surfel_density_ = lightprobe->grid_surfel_density / max_axis_len;
|
||||
min_distance_to_surface_ = lightprobe->grid_surface_bias;
|
||||
max_virtual_offset_ = lightprobe->grid_escape_bias;
|
||||
clip_distance_ = lightprobe->clipend;
|
||||
capture_world_ = (lightprobe->grid_flag & LIGHTPROBE_GRID_CAPTURE_WORLD);
|
||||
capture_indirect_ = (lightprobe->grid_flag & LIGHTPROBE_GRID_CAPTURE_INDIRECT);
|
||||
capture_emission_ = (lightprobe->grid_flag & LIGHTPROBE_GRID_CAPTURE_EMISSION);
|
||||
const ::LightProbe &lightprobe = DRW_object_get_data_for_drawing<::LightProbe>(probe_object);
|
||||
surfel_density_ = lightprobe.grid_surfel_density / max_axis_len;
|
||||
min_distance_to_surface_ = lightprobe.grid_surface_bias;
|
||||
max_virtual_offset_ = lightprobe.grid_escape_bias;
|
||||
clip_distance_ = lightprobe.clipend;
|
||||
capture_world_ = (lightprobe.grid_flag & LIGHTPROBE_GRID_CAPTURE_WORLD);
|
||||
capture_indirect_ = (lightprobe.grid_flag & LIGHTPROBE_GRID_CAPTURE_INDIRECT);
|
||||
capture_emission_ = (lightprobe.grid_flag & LIGHTPROBE_GRID_CAPTURE_EMISSION);
|
||||
|
||||
/* Initialize views data, since they're used by other modules. */
|
||||
surfel_raster_views_sync(float3(0.0f), float3(1.0f), float4x4::identity());
|
||||
@@ -882,9 +882,9 @@ void IrradianceBake::surfels_create(const Object &probe_object)
|
||||
*/
|
||||
using namespace blender::math;
|
||||
|
||||
const ::LightProbe *lightprobe = static_cast<::LightProbe *>(probe_object.data);
|
||||
const ::LightProbe &lightprobe = DRW_object_get_data_for_drawing<::LightProbe>(probe_object);
|
||||
|
||||
int3 grid_resolution = int3(&lightprobe->grid_resolution_x);
|
||||
int3 grid_resolution = int3(&lightprobe.grid_resolution_x);
|
||||
float4x4 grid_local_to_world = invert(probe_object.world_to_object());
|
||||
float3 grid_scale = math::to_scale(probe_object.object_to_world());
|
||||
|
||||
@@ -914,11 +914,11 @@ void IrradianceBake::surfels_create(const Object &probe_object)
|
||||
float min_distance_between_grid_samples = math::reduce_min(grid_scale / float3(grid_resolution));
|
||||
capture_info_buf_.min_distance_to_surface *= min_distance_between_grid_samples;
|
||||
capture_info_buf_.max_virtual_offset *= min_distance_between_grid_samples;
|
||||
capture_info_buf_.clamp_direct = (lightprobe->grid_clamp_direct > 0.0) ?
|
||||
lightprobe->grid_clamp_direct :
|
||||
capture_info_buf_.clamp_direct = (lightprobe.grid_clamp_direct > 0.0) ?
|
||||
lightprobe.grid_clamp_direct :
|
||||
1e20f;
|
||||
capture_info_buf_.clamp_indirect = (lightprobe->grid_clamp_indirect > 0.0) ?
|
||||
lightprobe->grid_clamp_indirect :
|
||||
capture_info_buf_.clamp_indirect = (lightprobe.grid_clamp_indirect > 0.0) ?
|
||||
lightprobe.grid_clamp_indirect :
|
||||
1e20f;
|
||||
|
||||
eGPUTextureUsage texture_usage = GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_SHADER_WRITE |
|
||||
|
||||
@@ -85,9 +85,9 @@ void Sampling::init(const Scene *scene)
|
||||
void Sampling::init(const Object &probe_object)
|
||||
{
|
||||
BLI_assert(inst_.is_baking());
|
||||
const ::LightProbe *lightprobe = static_cast<::LightProbe *>(probe_object.data);
|
||||
const ::LightProbe &lightprobe = DRW_object_get_data_for_drawing<::LightProbe>(probe_object);
|
||||
|
||||
sample_count_ = max_ii(1, lightprobe->grid_bake_samples);
|
||||
sample_count_ = max_ii(1, lightprobe.grid_bake_samples);
|
||||
sample_ = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -297,7 +297,7 @@ GPENCIL_tLayer *grease_pencil_layer_cache_add(Instance *inst,
|
||||
|
||||
{
|
||||
using namespace blender::bke::greasepencil;
|
||||
const GreasePencil &grease_pencil = *static_cast<GreasePencil *>(ob->data);
|
||||
const GreasePencil &grease_pencil = DRW_object_get_data_for_drawing<GreasePencil>(*ob);
|
||||
|
||||
const bool is_in_front = (ob->dtx & OB_DRAW_IN_FRONT);
|
||||
|
||||
|
||||
@@ -374,7 +374,7 @@ static float light_power_get(const Light *la)
|
||||
|
||||
void gpencil_light_pool_populate(GPENCIL_LightPool *lightpool, Object *ob)
|
||||
{
|
||||
Light *la = (Light *)ob->data;
|
||||
Light &light = DRW_object_get_data_for_drawing<Light>(*ob);
|
||||
|
||||
if (lightpool->light_used >= GPENCIL_LIGHT_BUFFER_LEN) {
|
||||
return;
|
||||
@@ -383,13 +383,13 @@ void gpencil_light_pool_populate(GPENCIL_LightPool *lightpool, Object *ob)
|
||||
gpLight *gp_light = &lightpool->light_data[lightpool->light_used];
|
||||
float(*mat)[4] = reinterpret_cast<float(*)[4]>(&gp_light->right);
|
||||
|
||||
if (la->type == LA_SPOT) {
|
||||
if (light.type == LA_SPOT) {
|
||||
copy_m4_m4(mat, ob->world_to_object().ptr());
|
||||
gp_light->type = GP_LIGHT_TYPE_SPOT;
|
||||
gp_light->spot_size = cosf(la->spotsize * 0.5f);
|
||||
gp_light->spot_blend = (1.0f - gp_light->spot_size) * la->spotblend;
|
||||
gp_light->spot_size = cosf(light.spotsize * 0.5f);
|
||||
gp_light->spot_blend = (1.0f - gp_light->spot_size) * light.spotblend;
|
||||
}
|
||||
else if (la->type == LA_AREA) {
|
||||
else if (light.type == LA_AREA) {
|
||||
/* Simulate area lights using a spot light. */
|
||||
normalize_m4_m4(mat, ob->object_to_world().ptr());
|
||||
invert_m4(mat);
|
||||
@@ -397,7 +397,7 @@ void gpencil_light_pool_populate(GPENCIL_LightPool *lightpool, Object *ob)
|
||||
gp_light->spot_size = cosf(M_PI_2);
|
||||
gp_light->spot_blend = (1.0f - gp_light->spot_size) * 1.0f;
|
||||
}
|
||||
else if (la->type == LA_SUN) {
|
||||
else if (light.type == LA_SUN) {
|
||||
normalize_v3_v3(gp_light->forward, ob->object_to_world().ptr()[2]);
|
||||
gp_light->type = GP_LIGHT_TYPE_SUN;
|
||||
}
|
||||
@@ -405,8 +405,8 @@ void gpencil_light_pool_populate(GPENCIL_LightPool *lightpool, Object *ob)
|
||||
gp_light->type = GP_LIGHT_TYPE_POINT;
|
||||
}
|
||||
copy_v4_v4(gp_light->position, ob->object_to_world().location());
|
||||
copy_v3_v3(gp_light->color, &la->r);
|
||||
mul_v3_fl(gp_light->color, la->energy * light_power_get(la));
|
||||
copy_v3_v3(gp_light->color, &light.r);
|
||||
mul_v3_fl(gp_light->color, light.energy * light_power_get(&light));
|
||||
|
||||
lightpool->light_used++;
|
||||
|
||||
|
||||
@@ -354,7 +354,7 @@ GPENCIL_tObject *Instance::object_sync_do(Object *ob, blender::draw::ResourceHan
|
||||
using namespace blender;
|
||||
using namespace blender::ed::greasepencil;
|
||||
using namespace blender::bke::greasepencil;
|
||||
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(ob->data);
|
||||
GreasePencil &grease_pencil = DRW_object_get_data_for_drawing<GreasePencil>(*ob);
|
||||
const bool is_vertex_mode = (ob->mode & OB_MODE_VERTEX_PAINT) != 0;
|
||||
const blender::Bounds<float3> bounds = grease_pencil.bounds_min_max_eval().value_or(
|
||||
blender::Bounds(float3(0)));
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
#include "BKE_image.hh"
|
||||
|
||||
#include "DRW_render.hh"
|
||||
|
||||
#include "image_enums.hh"
|
||||
#include "image_space.hh"
|
||||
|
||||
@@ -41,8 +43,8 @@ struct ShaderParameters {
|
||||
use_premul_alpha = BKE_image_has_gpu_texture_premultiplied_alpha(image, image_buffer);
|
||||
|
||||
if (scene->camera && scene->camera->type == OB_CAMERA) {
|
||||
const Camera *camera = static_cast<const Camera *>(scene->camera->data);
|
||||
far_near = float2(camera->clip_end, camera->clip_start);
|
||||
const Camera &camera = DRW_object_get_data_for_drawing<const Camera>(*scene->camera);
|
||||
far_near = float2(camera.clip_end, camera.clip_start);
|
||||
}
|
||||
space->get_shader_parameters(*this, image_buffer);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,6 @@
|
||||
#include "UI_resources.hh"
|
||||
|
||||
#include "draw_cache.hh"
|
||||
#include "draw_common_c.hh"
|
||||
#include "draw_context_private.hh"
|
||||
#include "draw_manager_text.hh"
|
||||
|
||||
@@ -530,7 +529,7 @@ static void drw_shgroup_bone_custom_solid(const Armatures::DrawContext *ctx,
|
||||
|
||||
if (ELEM(custom->type, OB_CURVES_LEGACY, OB_FONT, OB_SURF)) {
|
||||
drw_shgroup_custom_bone_curve(ctx,
|
||||
static_cast<Curve *>(custom->data),
|
||||
&DRW_object_get_data_for_drawing<Curve>(*custom),
|
||||
bone_mat,
|
||||
outline_color,
|
||||
wire_width,
|
||||
@@ -554,8 +553,13 @@ static void drw_shgroup_bone_custom_wire(const Armatures::DrawContext *ctx,
|
||||
}
|
||||
|
||||
if (ELEM(custom->type, OB_CURVES_LEGACY, OB_FONT, OB_SURF)) {
|
||||
drw_shgroup_custom_bone_curve(
|
||||
ctx, static_cast<Curve *>(custom->data), bone_mat, color, wire_width, select_id, custom);
|
||||
drw_shgroup_custom_bone_curve(ctx,
|
||||
&DRW_object_get_data_for_drawing<Curve>(*custom),
|
||||
bone_mat,
|
||||
color,
|
||||
wire_width,
|
||||
select_id,
|
||||
custom);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -699,9 +703,9 @@ static void drw_shgroup_bone_ik_spline_lines(const Armatures::DrawContext *ctx,
|
||||
/* This function sets the color-set for coloring a certain bone */
|
||||
static void set_ctx_bcolor(Armatures::DrawContext *ctx, const UnifiedBonePtr bone)
|
||||
{
|
||||
bArmature *arm = static_cast<bArmature *>(ctx->ob->data);
|
||||
bArmature &arm = DRW_object_get_data_for_drawing<bArmature>(*ctx->ob);
|
||||
|
||||
if ((arm->flag & ARM_COL_CUSTOM) == 0) {
|
||||
if ((arm.flag & ARM_COL_CUSTOM) == 0) {
|
||||
/* Only set a custom color if that's enabled on this armature. */
|
||||
ctx->bcolor = nullptr;
|
||||
return;
|
||||
@@ -1215,7 +1219,7 @@ static void draw_bone_update_disp_matrix_bbone(UnifiedBonePtr bone)
|
||||
|
||||
static void draw_axes(const Armatures::DrawContext *ctx,
|
||||
const UnifiedBonePtr bone,
|
||||
const bArmature *arm)
|
||||
const bArmature &arm)
|
||||
{
|
||||
float final_col[4];
|
||||
const float *col = (ctx->const_color) ? ctx->const_color :
|
||||
@@ -1225,7 +1229,7 @@ static void draw_axes(const Armatures::DrawContext *ctx,
|
||||
/* Mix with axes color. */
|
||||
final_col[3] = (ctx->const_color) ? 1.0 : (bone.flag() & BONE_SELECTED) ? 0.1 : 0.65;
|
||||
|
||||
if (bone.is_posebone() && bone.as_posebone()->custom && !(arm->flag & ARM_NO_CUSTOM)) {
|
||||
if (bone.is_posebone() && bone.as_posebone()->custom && !(arm.flag & ARM_NO_CUSTOM)) {
|
||||
const bPoseChannel *pchan = bone.as_posebone();
|
||||
/* Special case: Custom bones can have different scale than the bone.
|
||||
* Recompute display matrix without the custom scaling applied. (#65640). */
|
||||
@@ -1234,14 +1238,14 @@ static void draw_axes(const Armatures::DrawContext *ctx,
|
||||
copy_m4_m4(axis_mat, pchan->custom_tx ? pchan->custom_tx->pose_mat : pchan->pose_mat);
|
||||
const float3 length_vec = {length, length, length};
|
||||
rescale_m4(axis_mat, length_vec);
|
||||
translate_m4(axis_mat, 0.0, arm->axes_position - 1.0, 0.0);
|
||||
translate_m4(axis_mat, 0.0, arm.axes_position - 1.0, 0.0);
|
||||
|
||||
drw_shgroup_bone_axes(ctx, axis_mat, final_col);
|
||||
}
|
||||
else {
|
||||
float disp_mat[4][4];
|
||||
copy_m4_m4(disp_mat, bone.disp_mat());
|
||||
translate_m4(disp_mat, 0.0, arm->axes_position - 1.0, 0.0);
|
||||
translate_m4(disp_mat, 0.0, arm.axes_position - 1.0, 0.0);
|
||||
drw_shgroup_bone_axes(ctx, disp_mat, final_col);
|
||||
}
|
||||
}
|
||||
@@ -2019,21 +2023,21 @@ void Armatures::draw_armature_edit(Armatures::DrawContext *ctx)
|
||||
* however the active bone isn't updated. Long term solution is an 'EditArmature' struct.
|
||||
* for now we can draw from the original armature. See: #66773. */
|
||||
// bArmature *arm = ob->data;
|
||||
bArmature *arm = static_cast<bArmature *>(ob_orig->data);
|
||||
bArmature &arm = DRW_object_get_data_for_drawing<bArmature>(*ob_orig);
|
||||
|
||||
edbo_compute_bbone_child(arm);
|
||||
edbo_compute_bbone_child(&arm);
|
||||
|
||||
/* Determine drawing strategy. */
|
||||
const ArmatureBoneDrawStrategy &draw_strat = strategy_for_armature_drawtype(
|
||||
eArmature_Drawtype(arm->drawtype));
|
||||
eArmature_Drawtype(arm.drawtype));
|
||||
|
||||
for (eBone = static_cast<EditBone *>(arm->edbo->first),
|
||||
for (eBone = static_cast<EditBone *>(arm.edbo->first),
|
||||
/* Note: Selection Next handles the object id merging later. */
|
||||
index = ctx->bone_buf ? 0x0 : ob_orig->runtime->select_id;
|
||||
eBone;
|
||||
eBone = eBone->next, index += 0x10000)
|
||||
{
|
||||
if (!EBONE_VISIBLE(arm, eBone)) {
|
||||
if (!EBONE_VISIBLE(&arm, eBone)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -2041,12 +2045,12 @@ void Armatures::draw_armature_edit(Armatures::DrawContext *ctx)
|
||||
|
||||
/* catch exception for bone with hidden parent */
|
||||
eBone_Flag boneflag = eBone_Flag(eBone->flag);
|
||||
if ((eBone->parent) && !EBONE_VISIBLE(arm, eBone->parent)) {
|
||||
if ((eBone->parent) && !EBONE_VISIBLE(&arm, eBone->parent)) {
|
||||
boneflag &= ~BONE_CONNECTED;
|
||||
}
|
||||
|
||||
/* set temporary flag for drawing bone as active, but only if selected */
|
||||
if (eBone == arm->act_edbone) {
|
||||
if (eBone == arm.act_edbone) {
|
||||
boneflag |= BONE_DRAW_ACTIVE;
|
||||
}
|
||||
|
||||
@@ -2065,11 +2069,11 @@ void Armatures::draw_armature_edit(Armatures::DrawContext *ctx)
|
||||
draw_strat.draw_bone(ctx, bone, boneflag, select_id);
|
||||
|
||||
if (!is_select) {
|
||||
if (show_text && (arm->flag & ARM_DRAWNAMES)) {
|
||||
if (show_text && (arm.flag & ARM_DRAWNAMES)) {
|
||||
draw_bone_name(ctx, bone, boneflag);
|
||||
}
|
||||
|
||||
if (arm->flag & ARM_DRAWAXES) {
|
||||
if (arm.flag & ARM_DRAWAXES) {
|
||||
draw_axes(ctx, bone, arm);
|
||||
}
|
||||
}
|
||||
@@ -2081,7 +2085,7 @@ void Armatures::draw_armature_pose(Armatures::DrawContext *ctx)
|
||||
Object *ob = ctx->ob;
|
||||
const DRWContext *draw_ctx = DRW_context_get();
|
||||
const Scene *scene = draw_ctx->scene;
|
||||
bArmature *arm = static_cast<bArmature *>(ob->data);
|
||||
bArmature &arm = DRW_object_get_data_for_drawing<bArmature>(*ob);
|
||||
int index = -1;
|
||||
const bool show_text = ctx->show_text;
|
||||
bool draw_locked_weights = false;
|
||||
@@ -2151,14 +2155,14 @@ void Armatures::draw_armature_pose(Armatures::DrawContext *ctx)
|
||||
}
|
||||
|
||||
const ArmatureBoneDrawStrategy &draw_strat_normal = strategy_for_armature_drawtype(
|
||||
eArmature_Drawtype(arm->drawtype));
|
||||
eArmature_Drawtype(arm.drawtype));
|
||||
const ArmatureBoneDrawStrategyCustomShape draw_strat_custom;
|
||||
|
||||
for (bPoseChannel *pchan = static_cast<bPoseChannel *>(ob->pose->chanbase.first); pchan;
|
||||
pchan = pchan->next, index += 0x10000)
|
||||
{
|
||||
Bone *bone = pchan->bone;
|
||||
if (!ANIM_bone_is_visible(arm, bone)) {
|
||||
if (!ANIM_bone_is_visible(&arm, bone)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -2181,7 +2185,7 @@ void Armatures::draw_armature_pose(Armatures::DrawContext *ctx)
|
||||
/* Avoid drawing connection line to hidden parent. */
|
||||
boneflag &= ~BONE_CONNECTED;
|
||||
}
|
||||
if (bone == arm->act_bone) {
|
||||
if (bone == arm.act_bone) {
|
||||
/* Draw bone as active, but only if selected. */
|
||||
boneflag |= BONE_DRAW_ACTIVE;
|
||||
}
|
||||
@@ -2189,7 +2193,7 @@ void Armatures::draw_armature_pose(Armatures::DrawContext *ctx)
|
||||
boneflag &= ~BONE_DRAW_LOCKED_WEIGHT;
|
||||
}
|
||||
|
||||
const bool use_custom_shape = (pchan->custom) && !(arm->flag & ARM_NO_CUSTOM);
|
||||
const bool use_custom_shape = (pchan->custom) && !(arm.flag & ARM_NO_CUSTOM);
|
||||
const ArmatureBoneDrawStrategy &draw_strat = use_custom_shape ? draw_strat_custom :
|
||||
draw_strat_normal;
|
||||
if (!is_pose_select) {
|
||||
@@ -2207,10 +2211,10 @@ void Armatures::draw_armature_pose(Armatures::DrawContext *ctx)
|
||||
if (draw_dofs) {
|
||||
draw_bone_degrees_of_freedom(ctx, pchan);
|
||||
}
|
||||
if (show_text && (arm->flag & ARM_DRAWNAMES)) {
|
||||
if (show_text && (arm.flag & ARM_DRAWNAMES)) {
|
||||
draw_bone_name(ctx, bone_ptr, boneflag);
|
||||
}
|
||||
if (arm->flag & ARM_DRAWAXES) {
|
||||
if (arm.flag & ARM_DRAWAXES) {
|
||||
draw_axes(ctx, bone_ptr, arm);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
|
||||
#include "ED_view3d.hh"
|
||||
|
||||
#include "DRW_render.hh"
|
||||
|
||||
#include "overlay_next_base.hh"
|
||||
#include "overlay_shader_shared.h"
|
||||
|
||||
@@ -506,7 +508,7 @@ class Armatures : Overlay {
|
||||
const State &state,
|
||||
eArmatureDrawMode draw_mode)
|
||||
{
|
||||
bArmature *arm = static_cast<bArmature *>(ob_ref.object->data);
|
||||
bArmature &arm = DRW_object_get_data_for_drawing<bArmature>(*ob_ref.object);
|
||||
|
||||
DrawContext ctx;
|
||||
ctx.ob = ob_ref.object;
|
||||
@@ -514,7 +516,7 @@ class Armatures : Overlay {
|
||||
ctx.res = &res;
|
||||
ctx.dt = state.dt;
|
||||
ctx.draw_mode = draw_mode;
|
||||
ctx.drawtype = eArmature_Drawtype(arm->drawtype);
|
||||
ctx.drawtype = eArmature_Drawtype(arm.drawtype);
|
||||
|
||||
const bool is_edit_or_pose_mode = draw_mode != ARM_DRAW_MODE_OBJECT;
|
||||
const bool draw_as_wire = (ctx.ob->dt < OB_SOLID);
|
||||
@@ -526,7 +528,7 @@ class Armatures : Overlay {
|
||||
ctx.show_relations = show_relations;
|
||||
ctx.do_relations = show_relations && is_edit_or_pose_mode;
|
||||
ctx.draw_envelope_distance = is_edit_or_pose_mode;
|
||||
ctx.draw_relation_from_head = (arm->flag & ARM_DRAW_RELATION_FROM_HEAD);
|
||||
ctx.draw_relation_from_head = (arm.flag & ARM_DRAW_RELATION_FROM_HEAD);
|
||||
ctx.show_text = state.show_text;
|
||||
ctx.const_color = is_edit_or_pose_mode ? nullptr : &res.object_wire_color(ob_ref, state)[0];
|
||||
ctx.const_wire = (!ctx.is_filled || is_transparent) ? 1.0f : 0.0f;
|
||||
|
||||
@@ -73,26 +73,26 @@ class AttributeTexts : Overlay {
|
||||
|
||||
switch (object.type) {
|
||||
case OB_MESH: {
|
||||
const Mesh *mesh = static_cast<Mesh *>(object.data);
|
||||
add_attributes_to_text_cache(dt, mesh->attributes(), object_to_world);
|
||||
const Mesh &mesh = DRW_object_get_data_for_drawing<Mesh>(object);
|
||||
add_attributes_to_text_cache(dt, mesh.attributes(), object_to_world);
|
||||
break;
|
||||
}
|
||||
case OB_POINTCLOUD: {
|
||||
const PointCloud *pointcloud = static_cast<PointCloud *>(object.data);
|
||||
add_attributes_to_text_cache(dt, pointcloud->attributes(), object_to_world);
|
||||
const PointCloud &pointcloud = DRW_object_get_data_for_drawing<PointCloud>(object);
|
||||
add_attributes_to_text_cache(dt, pointcloud.attributes(), object_to_world);
|
||||
break;
|
||||
}
|
||||
case OB_CURVES_LEGACY: {
|
||||
const Curve *curve = static_cast<const Curve *>(object.data);
|
||||
if (curve->curve_eval) {
|
||||
const bke::CurvesGeometry &curves = curve->curve_eval->geometry.wrap();
|
||||
const Curve &curve = DRW_object_get_data_for_drawing<Curve>(object);
|
||||
if (curve.curve_eval) {
|
||||
const bke::CurvesGeometry &curves = curve.curve_eval->geometry.wrap();
|
||||
add_attributes_to_text_cache(dt, curves.attributes(), object_to_world);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case OB_CURVES: {
|
||||
const Curves *curves_id = static_cast<Curves *>(object.data);
|
||||
const bke::CurvesGeometry &curves = curves_id->geometry.wrap();
|
||||
const Curves &curves_id = DRW_object_get_data_for_drawing<Curves>(object);
|
||||
const bke::CurvesGeometry &curves = curves_id.geometry.wrap();
|
||||
add_attributes_to_text_cache(dt, curves.attributes(), object_to_world);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -176,9 +176,9 @@ class AttributeViewer : Overlay {
|
||||
Object &object = *ob_ref.object;
|
||||
switch (object.type) {
|
||||
case OB_MESH: {
|
||||
Mesh *mesh = static_cast<Mesh *>(object.data);
|
||||
Mesh &mesh = DRW_object_get_data_for_drawing<Mesh>(object);
|
||||
if (const std::optional<bke::AttributeMetaData> meta_data =
|
||||
mesh->attributes().lookup_meta_data(".viewer"))
|
||||
mesh.attributes().lookup_meta_data(".viewer"))
|
||||
{
|
||||
if (attribute_type_supports_viewer_overlay(meta_data->data_type)) {
|
||||
gpu::Batch *batch = DRW_cache_mesh_surface_viewer_attribute_get(&object);
|
||||
@@ -190,12 +190,12 @@ class AttributeViewer : Overlay {
|
||||
break;
|
||||
}
|
||||
case OB_POINTCLOUD: {
|
||||
PointCloud *pointcloud = static_cast<PointCloud *>(object.data);
|
||||
PointCloud &pointcloud = DRW_object_get_data_for_drawing<PointCloud>(object);
|
||||
if (const std::optional<bke::AttributeMetaData> meta_data =
|
||||
pointcloud->attributes().lookup_meta_data(".viewer"))
|
||||
pointcloud.attributes().lookup_meta_data(".viewer"))
|
||||
{
|
||||
if (attribute_type_supports_viewer_overlay(meta_data->data_type)) {
|
||||
gpu::VertBuf **vertbuf = DRW_pointcloud_evaluated_attribute(pointcloud, ".viewer");
|
||||
gpu::VertBuf **vertbuf = DRW_pointcloud_evaluated_attribute(&pointcloud, ".viewer");
|
||||
auto &sub = *pointcloud_sub_;
|
||||
gpu::Batch *batch = pointcloud_sub_pass_setup(sub, &object, nullptr);
|
||||
sub.push_constant("opacity", opacity);
|
||||
@@ -206,9 +206,9 @@ class AttributeViewer : Overlay {
|
||||
break;
|
||||
}
|
||||
case OB_CURVES_LEGACY: {
|
||||
Curve *curve = static_cast<Curve *>(object.data);
|
||||
if (curve->curve_eval) {
|
||||
const bke::CurvesGeometry &curves = curve->curve_eval->geometry.wrap();
|
||||
Curve &curve = DRW_object_get_data_for_drawing<Curve>(object);
|
||||
if (curve.curve_eval) {
|
||||
const bke::CurvesGeometry &curves = curve.curve_eval->geometry.wrap();
|
||||
if (const std::optional<bke::AttributeMetaData> meta_data =
|
||||
curves.attributes().lookup_meta_data(".viewer"))
|
||||
{
|
||||
@@ -224,15 +224,15 @@ class AttributeViewer : Overlay {
|
||||
break;
|
||||
}
|
||||
case OB_CURVES: {
|
||||
::Curves *curves_id = static_cast<::Curves *>(object.data);
|
||||
const bke::CurvesGeometry &curves = curves_id->geometry.wrap();
|
||||
::Curves &curves_id = DRW_object_get_data_for_drawing<::Curves>(object);
|
||||
const bke::CurvesGeometry &curves = curves_id.geometry.wrap();
|
||||
if (const std::optional<bke::AttributeMetaData> meta_data =
|
||||
curves.attributes().lookup_meta_data(".viewer"))
|
||||
{
|
||||
if (attribute_type_supports_viewer_overlay(meta_data->data_type)) {
|
||||
bool is_point_domain;
|
||||
gpu::VertBuf **texture = DRW_curves_texture_for_evaluated_attribute(
|
||||
curves_id, ".viewer", &is_point_domain);
|
||||
&curves_id, ".viewer", &is_point_domain);
|
||||
auto &sub = *curves_sub_;
|
||||
gpu::Batch *batch = curves_sub_pass_setup(sub, state.scene, ob_ref.object);
|
||||
sub.push_constant("opacity", opacity);
|
||||
|
||||
@@ -170,20 +170,20 @@ class Bounds : Overlay {
|
||||
if (!from_dupli && ob->data && (ob->dtx & OB_TEXSPACE)) {
|
||||
switch (GS(static_cast<ID *>(ob->data)->name)) {
|
||||
case ID_ME: {
|
||||
Mesh *me = static_cast<Mesh *>(ob->data);
|
||||
BKE_mesh_texspace_ensure(me);
|
||||
add_bounds_ex(me->texspace_location, me->texspace_size, OB_BOUND_BOX);
|
||||
Mesh &me = DRW_object_get_data_for_drawing<Mesh>(*ob);
|
||||
BKE_mesh_texspace_ensure(&me);
|
||||
add_bounds_ex(me.texspace_location, me.texspace_size, OB_BOUND_BOX);
|
||||
break;
|
||||
}
|
||||
case ID_CU_LEGACY: {
|
||||
Curve *cu = static_cast<Curve *>(ob->data);
|
||||
BKE_curve_texspace_ensure(cu);
|
||||
add_bounds_ex(cu->texspace_location, cu->texspace_size, OB_BOUND_BOX);
|
||||
Curve &cu = DRW_object_get_data_for_drawing<Curve>(*ob);
|
||||
BKE_curve_texspace_ensure(&cu);
|
||||
add_bounds_ex(cu.texspace_location, cu.texspace_size, OB_BOUND_BOX);
|
||||
break;
|
||||
}
|
||||
case ID_MB: {
|
||||
MetaBall *mb = static_cast<MetaBall *>(ob->data);
|
||||
add_bounds_ex(mb->texspace_location, mb->texspace_size, OB_BOUND_BOX);
|
||||
MetaBall &mb = DRW_object_get_data_for_drawing<MetaBall>(*ob);
|
||||
add_bounds_ex(mb.texspace_location, mb.texspace_size, OB_BOUND_BOX);
|
||||
break;
|
||||
}
|
||||
case ID_CV:
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "BLI_math_rotation.h"
|
||||
#include "DEG_depsgraph_query.hh"
|
||||
#include "DNA_camera_types.h"
|
||||
#include "DRW_render.hh"
|
||||
#include "ED_view3d.hh"
|
||||
|
||||
#include "draw_manager_text.hh"
|
||||
@@ -290,7 +291,7 @@ class Cameras : Overlay {
|
||||
const Scene *scene = state.scene;
|
||||
const RegionView3D *rv3d = state.rv3d;
|
||||
|
||||
const Camera *cam = static_cast<Camera *>(ob->data);
|
||||
const Camera &cam = DRW_object_get_data_for_drawing<Camera>(*ob);
|
||||
const Object *camera_object = DEG_get_evaluated_object(state.depsgraph, v3d->camera);
|
||||
const bool is_select = res.is_selection();
|
||||
const bool is_active = (ob == camera_object);
|
||||
@@ -318,8 +319,8 @@ class Cameras : Overlay {
|
||||
float2 shift;
|
||||
float drawsize;
|
||||
BKE_camera_view_frame_ex(scene,
|
||||
cam,
|
||||
cam->drawsize,
|
||||
&cam,
|
||||
cam.drawsize,
|
||||
is_camera_view,
|
||||
1.0f / scale,
|
||||
aspect_ratio,
|
||||
@@ -383,19 +384,19 @@ class Cameras : Overlay {
|
||||
(is_active ? call_buffers_.tria_buf : call_buffers_.tria_wire_buf).append(data, select_id);
|
||||
}
|
||||
|
||||
if (cam->flag & CAM_SHOWLIMITS) {
|
||||
if (cam.flag & CAM_SHOWLIMITS) {
|
||||
/* Scale focus point. */
|
||||
data.matrix.x_axis() *= cam->drawsize;
|
||||
data.matrix.y_axis() *= cam->drawsize;
|
||||
data.matrix.x_axis() *= cam.drawsize;
|
||||
data.matrix.y_axis() *= cam.drawsize;
|
||||
|
||||
data.dist_color_id = (is_active) ? 3 : 2;
|
||||
data.focus = -BKE_camera_object_dof_distance(ob);
|
||||
data.clip_start = cam->clip_start;
|
||||
data.clip_end = cam->clip_end;
|
||||
data.clip_start = cam.clip_start;
|
||||
data.clip_end = cam.clip_end;
|
||||
call_buffers_.distances_buf.append(data, select_id);
|
||||
}
|
||||
|
||||
if (cam->flag & CAM_SHOWMIST) {
|
||||
if (cam.flag & CAM_SHOWMIST) {
|
||||
World *world = scene->world;
|
||||
if (world) {
|
||||
data.dist_color_id = (is_active) ? 1 : 0;
|
||||
@@ -558,13 +559,13 @@ class Cameras : Overlay {
|
||||
Resources &res)
|
||||
{
|
||||
Object *ob = ob_ref.object;
|
||||
const Camera *cam = static_cast<Camera *>(ob_ref.object->data);
|
||||
const Camera &cam = DRW_object_get_data_for_drawing<Camera>(*ob_ref.object);
|
||||
const Object *camera_object = DEG_get_evaluated_object(state.depsgraph, state.v3d->camera);
|
||||
|
||||
const bool is_active = ob_ref.object == camera_object;
|
||||
const bool is_camera_view = (is_active && (state.rv3d->persp == RV3D_CAMOB));
|
||||
const bool show_image = (cam->flag & CAM_SHOW_BG_IMAGE) &&
|
||||
!BLI_listbase_is_empty(&cam->bg_images);
|
||||
const bool show_image = (cam.flag & CAM_SHOW_BG_IMAGE) &&
|
||||
!BLI_listbase_is_empty(&cam.bg_images);
|
||||
const bool show_frame = BKE_object_empty_image_frame_is_visible_in_view3d(ob, state.rv3d);
|
||||
|
||||
if (!images_enabled_ || !is_camera_view || !show_image || !show_frame) {
|
||||
@@ -576,7 +577,7 @@ class Cameras : Overlay {
|
||||
float4x4 modelmat;
|
||||
BKE_camera_multiview_model_matrix(&state.scene->r, ob, viewname, modelmat.ptr());
|
||||
|
||||
for (const CameraBGImage *bgpic : ConstListBaseWrapper<CameraBGImage>(&cam->bg_images)) {
|
||||
for (const CameraBGImage *bgpic : ConstListBaseWrapper<CameraBGImage>(&cam.bg_images)) {
|
||||
if (bgpic->flag & CAM_BGIMG_FLAG_DISABLED) {
|
||||
continue;
|
||||
}
|
||||
@@ -591,7 +592,7 @@ class Cameras : Overlay {
|
||||
bgpic, state, res, aspect, use_alpha_premult, use_view_transform);
|
||||
|
||||
if (tex) {
|
||||
image_camera_background_matrix_get(cam, bgpic, state, aspect, mat);
|
||||
image_camera_background_matrix_get(&cam, bgpic, state, aspect, mat);
|
||||
|
||||
const bool is_foreground = (bgpic->flag & CAM_BGIMG_FLAG_FOREGROUND) != 0;
|
||||
/* Alpha is clamped just below 1.0 to fix background images to interfere with foreground
|
||||
@@ -780,7 +781,7 @@ class Cameras : Overlay {
|
||||
{
|
||||
CameraInstanceData stereodata = instdata;
|
||||
|
||||
const Camera *cam = static_cast<const Camera *>(ob->data);
|
||||
const Camera &cam = DRW_object_get_data_for_drawing<const Camera>(*ob);
|
||||
const char *viewnames[2] = {STEREO_LEFT_NAME, STEREO_RIGHT_NAME};
|
||||
|
||||
const bool is_stereo3d_cameras = (v3d->stereo3d_flag & V3D_S3D_DISPCAMERAS) != 0;
|
||||
@@ -818,8 +819,8 @@ class Cameras : Overlay {
|
||||
if (is_stereo3d_volume && !is_selection) {
|
||||
float r = (eye == 1) ? 2.0f : 1.0f;
|
||||
|
||||
stereodata.volume_start = -cam->clip_start;
|
||||
stereodata.volume_end = -cam->clip_end;
|
||||
stereodata.volume_start = -cam.clip_start;
|
||||
stereodata.volume_end = -cam.clip_end;
|
||||
/* Encode eye + intensity and alpha (see shader) */
|
||||
stereodata.color_.x = r + 0.15f;
|
||||
stereodata.color_.y = 1.0f;
|
||||
@@ -839,7 +840,7 @@ class Cameras : Overlay {
|
||||
}
|
||||
|
||||
if (is_stereo3d_plane && !is_selection) {
|
||||
if (cam->stereo.convergence_mode == CAM_S3D_TOE) {
|
||||
if (cam.stereo.convergence_mode == CAM_S3D_TOE) {
|
||||
/* There is no real convergence plane but we highlight the center
|
||||
* point where the views are pointing at. */
|
||||
// stereodata.matrix.x_axis() = float3(0.0f); /* We reconstruct from Z and Y */
|
||||
@@ -857,7 +858,7 @@ class Cameras : Overlay {
|
||||
stereodata.matrix.x_axis() = math::cross(stereodata.matrix.y_axis(),
|
||||
stereodata.matrix.z_axis());
|
||||
}
|
||||
else if (cam->stereo.convergence_mode == CAM_S3D_PARALLEL) {
|
||||
else if (cam.stereo.convergence_mode == CAM_S3D_PARALLEL) {
|
||||
/* Show plane at the given distance between the views even if it makes no sense. */
|
||||
stereodata.matrix.location() = float3(0.0f);
|
||||
for (int i : IndexRange(2)) {
|
||||
@@ -866,11 +867,11 @@ class Cameras : Overlay {
|
||||
stereodata.matrix.location() += mat.location() * 0.5f;
|
||||
}
|
||||
}
|
||||
else if (cam->stereo.convergence_mode == CAM_S3D_OFFAXIS) {
|
||||
else if (cam.stereo.convergence_mode == CAM_S3D_OFFAXIS) {
|
||||
/* Nothing to do. Everything is already setup. */
|
||||
}
|
||||
stereodata.volume_start = -cam->stereo.convergence_distance;
|
||||
stereodata.volume_end = -cam->stereo.convergence_distance;
|
||||
stereodata.volume_start = -cam.stereo.convergence_distance;
|
||||
stereodata.volume_end = -cam.stereo.convergence_distance;
|
||||
/* Encode eye + intensity and alpha (see shader) */
|
||||
stereodata.color_.x = 0.1f;
|
||||
stereodata.color_.y = 1.0f;
|
||||
@@ -890,11 +891,11 @@ class Cameras : Overlay {
|
||||
float corner_x,
|
||||
bool right_eye)
|
||||
{
|
||||
const Camera *cam = static_cast<const Camera *>(ob->data);
|
||||
if (cam->stereo.convergence_mode == CAM_S3D_OFFAXIS) {
|
||||
const Camera &cam = DRW_object_get_data_for_drawing<const Camera>(*ob);
|
||||
if (cam.stereo.convergence_mode == CAM_S3D_OFFAXIS) {
|
||||
const char *viewnames[2] = {STEREO_LEFT_NAME, STEREO_RIGHT_NAME};
|
||||
const float shiftx = BKE_camera_multiview_shift_x(&scene->r, ob, viewnames[right_eye]);
|
||||
const float delta_shiftx = shiftx - cam->shiftx;
|
||||
const float delta_shiftx = shiftx - cam.shiftx;
|
||||
const float width = corner_x * 2.0f;
|
||||
return delta_shiftx * width;
|
||||
}
|
||||
|
||||
@@ -9,12 +9,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "BKE_attribute.hh"
|
||||
#include "BKE_curves.h"
|
||||
|
||||
#include "DNA_curves_types.h"
|
||||
|
||||
#include "GPU_capabilities.hh"
|
||||
|
||||
#include "draw_cache.hh"
|
||||
#include "draw_cache_impl.hh"
|
||||
|
||||
#include "overlay_next_base.hh"
|
||||
@@ -183,7 +183,7 @@ class Curves : Overlay {
|
||||
}
|
||||
|
||||
Object *ob = ob_ref.object;
|
||||
::Curves &curves = *static_cast<::Curves *>(ob->data);
|
||||
::Curves &curves = DRW_object_get_data_for_drawing<::Curves>(*ob);
|
||||
const bool show_points = bke::AttrDomain(curves.selection_domain) == bke::AttrDomain::Point;
|
||||
|
||||
if (show_points) {
|
||||
@@ -210,7 +210,7 @@ class Curves : Overlay {
|
||||
ResourceHandle res_handle = manager.unique_handle(ob_ref);
|
||||
|
||||
Object *ob = ob_ref.object;
|
||||
::Curve &curve = *static_cast<::Curve *>(ob->data);
|
||||
::Curve &curve = DRW_object_get_data_for_drawing<::Curve>(*ob);
|
||||
|
||||
if (ob->type == OB_CURVES_LEGACY) {
|
||||
gpu::Batch *geom = DRW_cache_curve_edge_wire_get(ob);
|
||||
|
||||
@@ -102,7 +102,7 @@ class EditText : Overlay {
|
||||
return;
|
||||
}
|
||||
|
||||
const Curve &cu = *static_cast<Curve *>(ob_ref.object->data);
|
||||
const Curve &cu = DRW_object_get_data_for_drawing<Curve>(*ob_ref.object);
|
||||
add_select(manager, cu, ob_ref.object->object_to_world());
|
||||
add_cursor(manager, cu, ob_ref.object->object_to_world());
|
||||
add_boxes(res, cu, ob_ref.object->object_to_world());
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "DRW_render.hh"
|
||||
#include "overlay_next_base.hh"
|
||||
#include "overlay_next_image.hh"
|
||||
|
||||
|
||||
@@ -65,7 +65,8 @@ class ForceFields : Overlay {
|
||||
const select::ID select_id = res.select_id(ob_ref);
|
||||
const Object *ob = ob_ref.object;
|
||||
PartDeflect *pd = ob->pd;
|
||||
Curve *cu = (ob->type == OB_CURVES_LEGACY) ? static_cast<Curve *>(ob->data) : nullptr;
|
||||
Curve *cu = (ob->type == OB_CURVES_LEGACY) ? &DRW_object_get_data_for_drawing<Curve>(*ob) :
|
||||
nullptr;
|
||||
|
||||
ExtraInstanceData data(
|
||||
ob->object_to_world(), res.object_background_blend_color(ob_ref, state), 1.0f);
|
||||
|
||||
@@ -288,7 +288,7 @@ class GreasePencil : Overlay {
|
||||
{
|
||||
using namespace blender;
|
||||
using namespace blender::ed::greasepencil;
|
||||
::GreasePencil &grease_pencil = *static_cast<::GreasePencil *>(ob->data);
|
||||
::GreasePencil &grease_pencil = DRW_object_get_data_for_drawing<::GreasePencil>(*ob);
|
||||
|
||||
const bool is_stroke_order_3d = (grease_pencil.flag & GREASE_PENCIL_STROKE_ORDER_3D) != 0;
|
||||
|
||||
@@ -412,7 +412,7 @@ class GreasePencil : Overlay {
|
||||
{
|
||||
const ToolSettings *ts = scene->toolsettings;
|
||||
|
||||
const ::GreasePencil &grease_pencil = *static_cast<::GreasePencil *>(object.data);
|
||||
const ::GreasePencil &grease_pencil = DRW_object_get_data_for_drawing<::GreasePencil>(object);
|
||||
const blender::bke::greasepencil::Layer *active_layer = grease_pencil.get_active_layer();
|
||||
|
||||
float4x4 mat = object.object_to_world();
|
||||
@@ -464,7 +464,7 @@ class GreasePencil : Overlay {
|
||||
uchar4 color;
|
||||
UI_GetThemeColor4ubv(res.object_wire_theme_id(ob_ref, state), color);
|
||||
|
||||
::GreasePencil &grease_pencil = *static_cast<::GreasePencil *>(object.data);
|
||||
::GreasePencil &grease_pencil = DRW_object_get_data_for_drawing<::GreasePencil>(object);
|
||||
|
||||
Vector<ed::greasepencil::DrawingInfo> drawings = ed::greasepencil::retrieve_visible_drawings(
|
||||
*state.scene, grease_pencil, false);
|
||||
|
||||
@@ -86,7 +86,7 @@ class Lights : Overlay {
|
||||
float &clip_start = matrix[2].w;
|
||||
float &clip_end = matrix[3].w;
|
||||
|
||||
const Light &la = *static_cast<Light *>(ob_ref.object->data);
|
||||
const Light &la = DRW_object_get_data_for_drawing<Light>(*ob_ref.object);
|
||||
const select::ID select_id = res.select_id(ob_ref);
|
||||
|
||||
/* FIXME / TODO: clip_end has no meaning nowadays.
|
||||
|
||||
@@ -81,10 +81,10 @@ class LightProbes : Overlay {
|
||||
}
|
||||
|
||||
const Object *ob = ob_ref.object;
|
||||
const LightProbe *prb = static_cast<LightProbe *>(ob_ref.object->data);
|
||||
const bool show_clipping = (prb->flag & LIGHTPROBE_FLAG_SHOW_CLIP_DIST) != 0;
|
||||
const bool show_parallax = (prb->flag & LIGHTPROBE_FLAG_SHOW_PARALLAX) != 0;
|
||||
const bool show_influence = (prb->flag & LIGHTPROBE_FLAG_SHOW_INFLUENCE) != 0;
|
||||
const LightProbe &prb = DRW_object_get_data_for_drawing<LightProbe>(*ob_ref.object);
|
||||
const bool show_clipping = (prb.flag & LIGHTPROBE_FLAG_SHOW_CLIP_DIST) != 0;
|
||||
const bool show_parallax = (prb.flag & LIGHTPROBE_FLAG_SHOW_PARALLAX) != 0;
|
||||
const bool show_influence = (prb.flag & LIGHTPROBE_FLAG_SHOW_INFLUENCE) != 0;
|
||||
const bool show_data = (ob_ref.object->base_flag & BASE_SELECTED) || res.is_selection();
|
||||
|
||||
const select::ID select_id = res.select_id(ob_ref);
|
||||
@@ -95,43 +95,43 @@ class LightProbes : Overlay {
|
||||
float &clip_end = matrix[3].w;
|
||||
float &draw_size = matrix[3].w;
|
||||
|
||||
switch (prb->type) {
|
||||
switch (prb.type) {
|
||||
case LIGHTPROBE_TYPE_SPHERE:
|
||||
clip_start = show_clipping ? prb->clipsta : -1.0;
|
||||
clip_end = show_clipping ? prb->clipend : -1.0;
|
||||
clip_start = show_clipping ? prb.clipsta : -1.0;
|
||||
clip_end = show_clipping ? prb.clipend : -1.0;
|
||||
call_buffers_.probe_cube_buf.append(data, select_id);
|
||||
|
||||
call_buffers_.ground_line_buf.append(float4(matrix.location(), 0.0f), select_id);
|
||||
|
||||
if (show_influence) {
|
||||
LightProbeInstanceBuf &attenuation = (prb->attenuation_type == LIGHTPROBE_SHAPE_BOX) ?
|
||||
LightProbeInstanceBuf &attenuation = (prb.attenuation_type == LIGHTPROBE_SHAPE_BOX) ?
|
||||
call_buffers_.cube_buf :
|
||||
call_buffers_.sphere_buf;
|
||||
const float f = 1.0f - prb->falloff;
|
||||
ExtraInstanceData data(ob->object_to_world(), color, prb->distinf);
|
||||
const float f = 1.0f - prb.falloff;
|
||||
ExtraInstanceData data(ob->object_to_world(), color, prb.distinf);
|
||||
attenuation.append(data, select_id);
|
||||
data.object_to_world[3].w = prb->distinf * f;
|
||||
data.object_to_world[3].w = prb.distinf * f;
|
||||
attenuation.append(data, select_id);
|
||||
}
|
||||
|
||||
if (show_parallax) {
|
||||
LightProbeInstanceBuf ¶llax = (prb->parallax_type == LIGHTPROBE_SHAPE_BOX) ?
|
||||
LightProbeInstanceBuf ¶llax = (prb.parallax_type == LIGHTPROBE_SHAPE_BOX) ?
|
||||
call_buffers_.cube_buf :
|
||||
call_buffers_.sphere_buf;
|
||||
const float dist = ((prb->flag & LIGHTPROBE_FLAG_CUSTOM_PARALLAX) != 0) ? prb->distpar :
|
||||
prb->distinf;
|
||||
const float dist = ((prb.flag & LIGHTPROBE_FLAG_CUSTOM_PARALLAX) != 0) ? prb.distpar :
|
||||
prb.distinf;
|
||||
parallax.append(ExtraInstanceData(ob->object_to_world(), color, dist), select_id);
|
||||
}
|
||||
break;
|
||||
case LIGHTPROBE_TYPE_VOLUME: {
|
||||
clip_start = show_clipping ? 0.0f : -1.0f;
|
||||
clip_end = show_clipping ? prb->clipend : -1.0f;
|
||||
clip_end = show_clipping ? prb.clipend : -1.0f;
|
||||
call_buffers_.probe_grid_buf.append(data, select_id);
|
||||
{
|
||||
/* Display surfel density as a cube. */
|
||||
float3 axes_len = math::to_scale(ob->object_to_world());
|
||||
float max_axis_len = math::reduce_max(axes_len);
|
||||
float3 local_surfel_size = (0.5f / prb->grid_surfel_density) * (max_axis_len / axes_len);
|
||||
float3 local_surfel_size = (0.5f / prb.grid_surfel_density) * (max_axis_len / axes_len);
|
||||
|
||||
float4x4 surfel_density_mat = math::from_loc_rot_scale<float4x4>(
|
||||
float3(-1.0f + local_surfel_size),
|
||||
@@ -149,14 +149,14 @@ class LightProbes : Overlay {
|
||||
|
||||
/* Data dots */
|
||||
if (show_data) {
|
||||
matrix[0].w = prb->grid_resolution_x;
|
||||
matrix[1].w = prb->grid_resolution_y;
|
||||
matrix[2].w = prb->grid_resolution_z;
|
||||
matrix[0].w = prb.grid_resolution_x;
|
||||
matrix[1].w = prb.grid_resolution_y;
|
||||
matrix[2].w = prb.grid_resolution_z;
|
||||
/* Put theme id in matrix. */
|
||||
matrix[3].w = res.object_wire_theme_id(ob_ref, state) == TH_ACTIVE ? 1.0f : 2.0f;
|
||||
|
||||
const uint cell_count = prb->grid_resolution_x * prb->grid_resolution_y *
|
||||
prb->grid_resolution_z;
|
||||
const uint cell_count = prb.grid_resolution_x * prb.grid_resolution_y *
|
||||
prb.grid_resolution_z;
|
||||
ps_dots_.push_constant("gridModelMatrix", matrix);
|
||||
ps_dots_.draw_procedural(GPU_PRIM_POINTS, 1, cell_count, 0, {0}, select_id.get());
|
||||
}
|
||||
@@ -165,14 +165,14 @@ class LightProbes : Overlay {
|
||||
case LIGHTPROBE_TYPE_PLANE:
|
||||
call_buffers_.probe_planar_buf.append(data, select_id);
|
||||
|
||||
if (res.is_selection() && (prb->flag & LIGHTPROBE_FLAG_SHOW_DATA)) {
|
||||
if (res.is_selection() && (prb.flag & LIGHTPROBE_FLAG_SHOW_DATA)) {
|
||||
call_buffers_.quad_solid_buf.append(data, select_id);
|
||||
}
|
||||
|
||||
if (show_influence) {
|
||||
matrix.z_axis() = math::normalize(matrix.z_axis()) * prb->distinf;
|
||||
matrix.z_axis() = math::normalize(matrix.z_axis()) * prb.distinf;
|
||||
call_buffers_.cube_buf.append(data, select_id);
|
||||
matrix.z_axis() *= 1.0f - prb->falloff;
|
||||
matrix.z_axis() *= 1.0f - prb.falloff;
|
||||
call_buffers_.cube_buf.append(data, select_id);
|
||||
}
|
||||
|
||||
|
||||
@@ -308,10 +308,10 @@ class Meshes : Overlay {
|
||||
ResourceHandle res_handle = manager.unique_handle(ob_ref);
|
||||
|
||||
Object *ob = ob_ref.object;
|
||||
Mesh &mesh = *static_cast<Mesh *>(ob->data);
|
||||
Mesh &mesh = DRW_object_get_data_for_drawing<Mesh>(*ob);
|
||||
/* WORKAROUND: GPU subdiv uses a different normal format. Remove this once GPU subdiv is
|
||||
* refactored. */
|
||||
const bool use_gpu_subdiv = BKE_subsurf_modifier_has_gpu_subdiv(static_cast<Mesh *>(ob->data));
|
||||
const bool use_gpu_subdiv = BKE_subsurf_modifier_has_gpu_subdiv(&mesh);
|
||||
const bool draw_as_solid = (ob->dt > OB_WIRE) && !state.xray_enabled;
|
||||
const bool has_edit_cage = mesh_has_edit_cage(ob);
|
||||
|
||||
@@ -443,7 +443,7 @@ class Meshes : Overlay {
|
||||
static bool mesh_has_edit_cage(const Object *ob)
|
||||
{
|
||||
BLI_assert(ob->type == OB_MESH);
|
||||
const Mesh &mesh = *static_cast<const Mesh *>(ob->data);
|
||||
Mesh &mesh = DRW_object_get_data_for_drawing<Mesh>(*ob);
|
||||
if (mesh.runtime->edit_mesh != nullptr) {
|
||||
const Mesh *editmesh_eval_final = BKE_object_get_editmesh_eval_final(ob);
|
||||
const Mesh *editmesh_eval_cage = BKE_object_get_editmesh_eval_cage(ob);
|
||||
@@ -469,7 +469,7 @@ class Meshes : Overlay {
|
||||
|
||||
static bool mesh_has_skin_roots(const Object *ob)
|
||||
{
|
||||
const Mesh &mesh = *static_cast<const Mesh *>(ob->data);
|
||||
Mesh &mesh = DRW_object_get_data_for_drawing<Mesh>(*ob);
|
||||
if (BMEditMesh *em = mesh.runtime->edit_mesh.get()) {
|
||||
return CustomData_get_offset(&em->bm->vdata, CD_MVERT_SKIN) != -1;
|
||||
}
|
||||
@@ -753,7 +753,7 @@ class MeshUVs : Overlay {
|
||||
}
|
||||
|
||||
Object &ob = *ob_ref.object;
|
||||
Mesh &mesh = *static_cast<Mesh *>(ob.data);
|
||||
Mesh &mesh = DRW_object_get_data_for_drawing<Mesh>(ob);
|
||||
|
||||
const bool is_edit_object = DRW_object_is_in_edit_mode(&ob);
|
||||
const bool has_active_object_uvmap = CustomData_get_active_layer(&mesh.corner_data,
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#include "ED_mball.hh"
|
||||
|
||||
#include "overlay_next_base.hh"
|
||||
#include "overlay_shader_shared.h"
|
||||
|
||||
namespace blender::draw::overlay {
|
||||
|
||||
@@ -42,7 +41,7 @@ class Metaballs : Overlay {
|
||||
const State & /*state*/) final
|
||||
{
|
||||
const Object *ob = ob_ref.object;
|
||||
const MetaBall *mb = static_cast<MetaBall *>(ob->data);
|
||||
const MetaBall &mb = DRW_object_get_data_for_drawing<MetaBall>(*ob);
|
||||
|
||||
const float *color;
|
||||
const float *col_radius = res.theme_settings.color_mball_radius;
|
||||
@@ -51,7 +50,7 @@ class Metaballs : Overlay {
|
||||
const float *col_stiffness_select = res.theme_settings.color_mball_stiffness_select;
|
||||
|
||||
int elem_num = 0;
|
||||
LISTBASE_FOREACH (MetaElem *, ml, mb->editelems) {
|
||||
LISTBASE_FOREACH (MetaElem *, ml, mb.editelems) {
|
||||
const bool is_selected = (ml->flag & SELECT) != 0;
|
||||
const bool is_scale_radius = (ml->flag & MB_SCALE_RAD) != 0;
|
||||
const float stiffness_radius = ml->rad * atanf(ml->s) * 2.0f / math::numbers::pi;
|
||||
@@ -74,7 +73,7 @@ class Metaballs : Overlay {
|
||||
const State &state) final
|
||||
{
|
||||
const Object *ob = ob_ref.object;
|
||||
const MetaBall *mb = static_cast<MetaBall *>(ob->data);
|
||||
const MetaBall *mb = &DRW_object_get_data_for_drawing<MetaBall>(*ob);
|
||||
|
||||
const float4 &color = res.object_wire_color(ob_ref, state);
|
||||
const select::ID select_id = res.select_id(ob_ref);
|
||||
|
||||
@@ -224,7 +224,8 @@ class Paints : Overlay {
|
||||
/* Selection Display. */
|
||||
{
|
||||
/* NOTE(fclem): Why do we need original mesh here, only to get the flag? */
|
||||
const Mesh &mesh_orig = *static_cast<Mesh *>(DEG_get_original_object(ob_ref.object)->data);
|
||||
const Mesh &mesh_orig = DRW_object_get_data_for_drawing<Mesh>(
|
||||
*DEG_get_original_object(ob_ref.object));
|
||||
const bool use_face_selection = (mesh_orig.editflag & ME_EDIT_PAINT_FACE_SEL);
|
||||
const bool use_vert_selection = (mesh_orig.editflag & ME_EDIT_PAINT_VERT_SEL);
|
||||
/* Texture paint mode only draws the face selection without wires or vertices as we don't
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "BKE_subdiv_ccg.hh"
|
||||
#include "DEG_depsgraph_query.hh"
|
||||
|
||||
#include "DRW_render.hh"
|
||||
#include "bmesh.hh"
|
||||
|
||||
#include "draw_cache_impl.hh"
|
||||
@@ -120,14 +121,14 @@ class Sculpts : Overlay {
|
||||
|
||||
void curves_sync(Manager &manager, const ObjectRef &ob_ref, const State &state)
|
||||
{
|
||||
::Curves *curves = static_cast<::Curves *>(ob_ref.object->data);
|
||||
::Curves &curves = DRW_object_get_data_for_drawing<::Curves>(*ob_ref.object);
|
||||
|
||||
/* As an optimization, draw nothing if everything is selected. */
|
||||
if (show_mask_ && !everything_selected(*curves)) {
|
||||
if (show_mask_ && !everything_selected(curves)) {
|
||||
/* Retrieve the location of the texture. */
|
||||
bool is_point_domain;
|
||||
gpu::VertBuf **select_attr_buf = DRW_curves_texture_for_evaluated_attribute(
|
||||
curves, ".selection", &is_point_domain);
|
||||
&curves, ".selection", &is_point_domain);
|
||||
if (select_attr_buf) {
|
||||
/* Evaluate curves and their attributes if necessary. */
|
||||
gpu::Batch *geometry = curves_sub_pass_setup(*curves_ps_, state.scene, ob_ref.object);
|
||||
@@ -144,7 +145,7 @@ class Sculpts : Overlay {
|
||||
if (show_curves_cage_) {
|
||||
ResourceHandle handle = manager.unique_handle(ob_ref);
|
||||
|
||||
blender::gpu::Batch *geometry = DRW_curves_batch_cache_get_sculpt_curves_cage(curves);
|
||||
blender::gpu::Batch *geometry = DRW_curves_batch_cache_get_sculpt_curves_cage(&curves);
|
||||
sculpt_curve_cage_.draw(geometry, handle);
|
||||
}
|
||||
}
|
||||
@@ -179,7 +180,7 @@ class Sculpts : Overlay {
|
||||
|
||||
switch (pbvh->type()) {
|
||||
case blender::bke::pbvh::Type::Mesh: {
|
||||
const Mesh &mesh = *static_cast<const Mesh *>(object_orig->data);
|
||||
const Mesh &mesh = DRW_object_get_data_for_drawing<Mesh>(*object_orig);
|
||||
if (!mesh.attributes().contains(".sculpt_face_set") &&
|
||||
!mesh.attributes().contains(".sculpt_mask"))
|
||||
{
|
||||
@@ -189,7 +190,7 @@ class Sculpts : Overlay {
|
||||
}
|
||||
case blender::bke::pbvh::Type::Grids: {
|
||||
const SubdivCCG &subdiv_ccg = *sculpt_session->subdiv_ccg;
|
||||
const Mesh &base_mesh = *static_cast<const Mesh *>(object_orig->data);
|
||||
const Mesh &base_mesh = DRW_object_get_data_for_drawing<Mesh>(*object_orig);
|
||||
if (subdiv_ccg.masks.is_empty() && !base_mesh.attributes().contains(".sculpt_face_set")) {
|
||||
return;
|
||||
}
|
||||
@@ -222,7 +223,7 @@ class Sculpts : Overlay {
|
||||
else {
|
||||
ResourceHandle handle = manager.unique_handle(ob_ref);
|
||||
|
||||
Mesh &mesh = *static_cast<Mesh *>(ob_ref.object->data);
|
||||
Mesh &mesh = DRW_object_get_data_for_drawing<Mesh>(*ob_ref.object);
|
||||
gpu::Batch *sculpt_overlays = DRW_mesh_batch_cache_get_sculpt_overlays(mesh);
|
||||
mesh_ps_->draw(sculpt_overlays, handle);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "BKE_paint.hh"
|
||||
#include "DNA_volume_types.h"
|
||||
|
||||
#include "DRW_render.hh"
|
||||
#include "draw_common.hh"
|
||||
#include "draw_sculpt.hh"
|
||||
|
||||
@@ -194,9 +195,9 @@ class Wireframe : Overlay {
|
||||
|
||||
/* Draw loose geometry. */
|
||||
if (!in_edit_paint_mode || bypass_mode_check) {
|
||||
const Mesh *mesh = static_cast<const Mesh *>(ob_ref.object->data);
|
||||
const Mesh &mesh = DRW_object_get_data_for_drawing<Mesh>(*ob_ref.object);
|
||||
gpu::Batch *geom;
|
||||
if ((mesh->edges_num == 0) && (mesh->verts_num > 0)) {
|
||||
if ((mesh.edges_num == 0) && (mesh.verts_num > 0)) {
|
||||
geom = DRW_cache_mesh_all_verts_get(ob_ref.object);
|
||||
coloring.pointcloud_ps_->draw(
|
||||
geom, manager.unique_handle(ob_ref), res.select_id(ob_ref).get());
|
||||
@@ -222,7 +223,7 @@ class Wireframe : Overlay {
|
||||
if (geom == nullptr) {
|
||||
break;
|
||||
}
|
||||
if (static_cast<Volume *>(ob_ref.object->data)->display.wireframe_type ==
|
||||
if (DRW_object_get_data_for_drawing<Volume>(*ob_ref.object).display.wireframe_type ==
|
||||
VOLUME_WIREFRAME_POINTS)
|
||||
{
|
||||
coloring.pointcloud_ps_->draw(
|
||||
@@ -293,7 +294,7 @@ class Wireframe : Overlay {
|
||||
if (!in_edit_mode) {
|
||||
return false;
|
||||
}
|
||||
const Mesh &mesh = *static_cast<const Mesh *>(ob_ref.object->data);
|
||||
const Mesh &mesh = DRW_object_get_data_for_drawing<Mesh>(*ob_ref.object);
|
||||
const Mesh *orig_edit_mesh = BKE_object_get_pre_modified_mesh(ob_ref.object);
|
||||
const bool edit_mapping_valid = BKE_editmesh_eval_orig_map_available(mesh, orig_edit_mesh);
|
||||
if (!edit_mapping_valid) {
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "BLT_translation.hh"
|
||||
|
||||
#include "DEG_depsgraph_query.hh"
|
||||
#include "DRW_render.hh"
|
||||
#include "ED_view3d.hh"
|
||||
|
||||
#include "RE_engine.h"
|
||||
@@ -209,7 +210,7 @@ struct Instance : public DrawEngine {
|
||||
{
|
||||
using namespace blender::draw;
|
||||
using namespace blender;
|
||||
Mesh &mesh = *static_cast<Mesh *>(ob->data);
|
||||
Mesh &mesh = DRW_object_get_data_for_drawing<Mesh>(*ob);
|
||||
BMEditMesh *em = mesh.runtime->edit_mesh.get();
|
||||
|
||||
ElemIndexRanges ranges{};
|
||||
@@ -268,7 +269,7 @@ struct Instance : public DrawEngine {
|
||||
{
|
||||
using namespace blender::draw;
|
||||
using namespace blender;
|
||||
Mesh &mesh = *static_cast<Mesh *>(ob->data);
|
||||
Mesh &mesh = DRW_object_get_data_for_drawing<Mesh>(*ob);
|
||||
|
||||
ElemIndexRanges ranges{};
|
||||
ranges.total = IndexRange::from_begin_size(initial_index, 0);
|
||||
@@ -311,7 +312,7 @@ struct Instance : public DrawEngine {
|
||||
|
||||
switch (ob->type) {
|
||||
case OB_MESH: {
|
||||
const Mesh &mesh = *static_cast<const Mesh *>(ob->data);
|
||||
const Mesh &mesh = DRW_object_get_data_for_drawing<Mesh>(*ob);
|
||||
if (mesh.runtime->edit_mesh) {
|
||||
bool draw_facedot = check_ob_drawface_dot(select_mode, v3d, eDrawType(ob->dt));
|
||||
return edit_mesh_sync(ob, res_handle, select_mode, draw_facedot, index_start);
|
||||
@@ -336,7 +337,7 @@ struct Instance : public DrawEngine {
|
||||
/* This object is not selectable. It is here to participate in occlusion.
|
||||
* This is the case in retopology mode. */
|
||||
blender::gpu::Batch *geom_faces = DRW_mesh_batch_cache_get_surface(
|
||||
*static_cast<Mesh *>(ob->data));
|
||||
DRW_object_get_data_for_drawing<Mesh>(*ob));
|
||||
|
||||
depth_occlude->draw(geom_faces, manager.resource_handle(ob_ref));
|
||||
return;
|
||||
|
||||
@@ -115,7 +115,7 @@ void SceneState::init(const DRWContext *context,
|
||||
camera_object = (rv3d->persp == RV3D_CAMOB) ? v3d->camera : nullptr;
|
||||
}
|
||||
camera = camera_object && camera_object->type == OB_CAMERA ?
|
||||
static_cast<Camera *>(camera_object->data) :
|
||||
&DRW_object_get_data_for_drawing<Camera>(*camera_object) :
|
||||
nullptr;
|
||||
|
||||
object_mode = CTX_data_mode_enum_ex(context->object_edit, context->obact, context->object_mode);
|
||||
@@ -295,9 +295,9 @@ ObjectState::ObjectState(const DRWContext *draw_ctx,
|
||||
bool has_uv = false;
|
||||
|
||||
if (ob->type == OB_MESH) {
|
||||
const Mesh *mesh = static_cast<Mesh *>(ob->data);
|
||||
const CustomData *cd_vdata = get_vert_custom_data(mesh);
|
||||
const CustomData *cd_ldata = get_loop_custom_data(mesh);
|
||||
const Mesh &mesh = DRW_object_get_data_for_drawing<Mesh>(*ob);
|
||||
const CustomData *cd_vdata = get_vert_custom_data(&mesh);
|
||||
const CustomData *cd_ldata = get_loop_custom_data(&mesh);
|
||||
|
||||
has_color = (CustomData_has_layer(cd_vdata, CD_PROP_COLOR) ||
|
||||
CustomData_has_layer(cd_vdata, CD_PROP_BYTE_COLOR) ||
|
||||
|
||||
@@ -35,14 +35,14 @@ void VolumePass::object_sync_volume(Manager &manager,
|
||||
{
|
||||
Object *ob = ob_ref.object;
|
||||
/* Create 3D textures. */
|
||||
Volume *volume = static_cast<Volume *>(ob->data);
|
||||
BKE_volume_load(volume, G.main);
|
||||
const bke::VolumeGridData *volume_grid = BKE_volume_grid_active_get_for_read(volume);
|
||||
Volume &volume = DRW_object_get_data_for_drawing<Volume>(*ob);
|
||||
BKE_volume_load(&volume, G.main);
|
||||
const bke::VolumeGridData *volume_grid = BKE_volume_grid_active_get_for_read(&volume);
|
||||
if (volume_grid == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
DRWVolumeGrid *grid = DRW_volume_batch_cache_get_grid(volume, volume_grid);
|
||||
DRWVolumeGrid *grid = DRW_volume_batch_cache_get_grid(&volume, volume_grid);
|
||||
if (grid == nullptr) {
|
||||
return;
|
||||
}
|
||||
@@ -51,14 +51,14 @@ void VolumePass::object_sync_volume(Manager &manager,
|
||||
|
||||
PassMain::Sub &sub_ps = ps_.sub("Volume Object SubPass");
|
||||
|
||||
const bool use_slice = (volume->display.axis_slice_method == AXIS_SLICE_SINGLE);
|
||||
const bool use_slice = (volume.display.axis_slice_method == AXIS_SLICE_SINGLE);
|
||||
|
||||
sub_ps.shader_set(ShaderCache::get().volume_get(
|
||||
false, volume->display.interpolation_method, false, use_slice));
|
||||
sub_ps.shader_set(
|
||||
ShaderCache::get().volume_get(false, volume.display.interpolation_method, false, use_slice));
|
||||
sub_ps.push_constant("do_depth_test", scene_state.shading.type >= OB_SOLID);
|
||||
|
||||
const float density_scale = volume->display.density *
|
||||
BKE_volume_density_scale(volume, ob->object_to_world().ptr());
|
||||
const float density_scale = volume.display.density *
|
||||
BKE_volume_density_scale(&volume, ob->object_to_world().ptr());
|
||||
|
||||
sub_ps.bind_texture("depthBuffer", &resources.depth_tx);
|
||||
sub_ps.bind_texture("stencil_tx", &stencil_tx_);
|
||||
@@ -71,12 +71,8 @@ void VolumePass::object_sync_volume(Manager &manager,
|
||||
sub_ps.push_constant("volumeTextureToObject", float4x4(grid->texture_to_object));
|
||||
|
||||
if (use_slice) {
|
||||
draw_slice_ps(manager,
|
||||
resources,
|
||||
sub_ps,
|
||||
ob_ref,
|
||||
volume->display.slice_axis,
|
||||
volume->display.slice_depth);
|
||||
draw_slice_ps(
|
||||
manager, resources, sub_ps, ob_ref, volume.display.slice_axis, volume.display.slice_depth);
|
||||
}
|
||||
else {
|
||||
float4x4 texture_to_world = ob->object_to_world() * float4x4(grid->texture_to_object);
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "BLI_math_vector_types.hh"
|
||||
#include "DNA_object_enums.h"
|
||||
#include "DNA_object_types.h"
|
||||
|
||||
#include "GPU_material.hh"
|
||||
|
||||
@@ -30,6 +31,7 @@ struct GPUMaterial;
|
||||
struct GPUShader;
|
||||
struct GPUTexture;
|
||||
struct GPUUniformBuf;
|
||||
struct Mesh;
|
||||
struct Object;
|
||||
struct ParticleSystem;
|
||||
struct rcti;
|
||||
@@ -204,6 +206,15 @@ bool DRW_object_use_hide_faces(const Object *ob);
|
||||
bool DRW_object_is_visible_psys_in_active_context(const Object *object,
|
||||
const ParticleSystem *psys);
|
||||
|
||||
/**
|
||||
* Convenient accessor for object data, that also automatically returns
|
||||
* the base or tessellated mesh depending if GPU subdivision is enabled.
|
||||
*/
|
||||
template<typename T> T &DRW_object_get_data_for_drawing(const Object &object)
|
||||
{
|
||||
return *static_cast<T *>(object.data);
|
||||
}
|
||||
|
||||
/* Draw State. */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
@@ -18,16 +18,17 @@
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_volume_types.h"
|
||||
|
||||
#include "UI_resources.hh"
|
||||
|
||||
#include "BLI_ghash.h"
|
||||
#include "BLI_listbase.h"
|
||||
#include "BLI_string.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BKE_context.hh"
|
||||
#include "BKE_mesh_wrapper.hh"
|
||||
#include "BKE_object.hh"
|
||||
#include "BKE_subdiv_modifier.hh"
|
||||
|
||||
#include "DRW_render.hh"
|
||||
#include "GPU_batch.hh"
|
||||
#include "GPU_batch_utils.hh"
|
||||
#include "GPU_capabilities.hh"
|
||||
@@ -183,7 +184,7 @@ blender::gpu::VertBuf *DRW_cache_object_pos_vertbuf_get(Object *ob)
|
||||
switch (type) {
|
||||
case OB_MESH:
|
||||
return DRW_mesh_batch_cache_pos_vertbuf_get(
|
||||
*static_cast<Mesh *>((mesh != nullptr) ? mesh : ob->data));
|
||||
(mesh != nullptr) ? *mesh : DRW_object_get_data_for_drawing<Mesh>(*ob));
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
@@ -210,42 +211,43 @@ blender::gpu::Batch *DRW_cache_mesh_all_verts_get(Object *ob)
|
||||
{
|
||||
using namespace blender::draw;
|
||||
BLI_assert(ob->type == OB_MESH);
|
||||
return DRW_mesh_batch_cache_get_all_verts(*static_cast<Mesh *>(ob->data));
|
||||
return DRW_mesh_batch_cache_get_all_verts(DRW_object_get_data_for_drawing<Mesh>(*ob));
|
||||
}
|
||||
|
||||
blender::gpu::Batch *DRW_cache_mesh_all_edges_get(Object *ob)
|
||||
{
|
||||
using namespace blender::draw;
|
||||
BLI_assert(ob->type == OB_MESH);
|
||||
return DRW_mesh_batch_cache_get_all_edges(*static_cast<Mesh *>(ob->data));
|
||||
return DRW_mesh_batch_cache_get_all_edges(DRW_object_get_data_for_drawing<Mesh>(*ob));
|
||||
}
|
||||
|
||||
blender::gpu::Batch *DRW_cache_mesh_loose_edges_get(Object *ob)
|
||||
{
|
||||
using namespace blender::draw;
|
||||
BLI_assert(ob->type == OB_MESH);
|
||||
return DRW_mesh_batch_cache_get_loose_edges(*static_cast<Mesh *>(ob->data));
|
||||
return DRW_mesh_batch_cache_get_loose_edges(DRW_object_get_data_for_drawing<Mesh>(*ob));
|
||||
}
|
||||
|
||||
blender::gpu::Batch *DRW_cache_mesh_edge_detection_get(Object *ob, bool *r_is_manifold)
|
||||
{
|
||||
using namespace blender::draw;
|
||||
BLI_assert(ob->type == OB_MESH);
|
||||
return DRW_mesh_batch_cache_get_edge_detection(*static_cast<Mesh *>(ob->data), r_is_manifold);
|
||||
return DRW_mesh_batch_cache_get_edge_detection(DRW_object_get_data_for_drawing<Mesh>(*ob),
|
||||
r_is_manifold);
|
||||
}
|
||||
|
||||
blender::gpu::Batch *DRW_cache_mesh_surface_get(Object *ob)
|
||||
{
|
||||
using namespace blender::draw;
|
||||
BLI_assert(ob->type == OB_MESH);
|
||||
return DRW_mesh_batch_cache_get_surface(*static_cast<Mesh *>(ob->data));
|
||||
return DRW_mesh_batch_cache_get_surface(DRW_object_get_data_for_drawing<Mesh>(*ob));
|
||||
}
|
||||
|
||||
blender::gpu::Batch *DRW_cache_mesh_surface_edges_get(Object *ob)
|
||||
{
|
||||
using namespace blender::draw;
|
||||
BLI_assert(ob->type == OB_MESH);
|
||||
return DRW_mesh_batch_cache_get_surface_edges(*static_cast<Mesh *>(ob->data));
|
||||
return DRW_mesh_batch_cache_get_surface_edges(DRW_object_get_data_for_drawing<Mesh>(*ob));
|
||||
}
|
||||
|
||||
Span<blender::gpu::Batch *> DRW_cache_mesh_surface_shaded_get(
|
||||
@@ -253,63 +255,68 @@ Span<blender::gpu::Batch *> DRW_cache_mesh_surface_shaded_get(
|
||||
{
|
||||
using namespace blender::draw;
|
||||
BLI_assert(ob->type == OB_MESH);
|
||||
return DRW_mesh_batch_cache_get_surface_shaded(*ob, *static_cast<Mesh *>(ob->data), materials);
|
||||
return DRW_mesh_batch_cache_get_surface_shaded(
|
||||
*ob, DRW_object_get_data_for_drawing<Mesh>(*ob), materials);
|
||||
}
|
||||
|
||||
Span<blender::gpu::Batch *> DRW_cache_mesh_surface_texpaint_get(Object *ob)
|
||||
{
|
||||
using namespace blender::draw;
|
||||
BLI_assert(ob->type == OB_MESH);
|
||||
return DRW_mesh_batch_cache_get_surface_texpaint(*ob, *static_cast<Mesh *>(ob->data));
|
||||
return DRW_mesh_batch_cache_get_surface_texpaint(*ob,
|
||||
DRW_object_get_data_for_drawing<Mesh>(*ob));
|
||||
}
|
||||
|
||||
blender::gpu::Batch *DRW_cache_mesh_surface_texpaint_single_get(Object *ob)
|
||||
{
|
||||
using namespace blender::draw;
|
||||
BLI_assert(ob->type == OB_MESH);
|
||||
return DRW_mesh_batch_cache_get_surface_texpaint_single(*ob, *static_cast<Mesh *>(ob->data));
|
||||
return DRW_mesh_batch_cache_get_surface_texpaint_single(
|
||||
*ob, DRW_object_get_data_for_drawing<Mesh>(*ob));
|
||||
}
|
||||
|
||||
blender::gpu::Batch *DRW_cache_mesh_surface_vertpaint_get(Object *ob)
|
||||
{
|
||||
using namespace blender::draw;
|
||||
BLI_assert(ob->type == OB_MESH);
|
||||
return DRW_mesh_batch_cache_get_surface_vertpaint(*ob, *static_cast<Mesh *>(ob->data));
|
||||
return DRW_mesh_batch_cache_get_surface_vertpaint(*ob,
|
||||
DRW_object_get_data_for_drawing<Mesh>(*ob));
|
||||
}
|
||||
|
||||
blender::gpu::Batch *DRW_cache_mesh_surface_sculptcolors_get(Object *ob)
|
||||
{
|
||||
using namespace blender::draw;
|
||||
BLI_assert(ob->type == OB_MESH);
|
||||
return DRW_mesh_batch_cache_get_surface_sculpt(*ob, *static_cast<Mesh *>(ob->data));
|
||||
return DRW_mesh_batch_cache_get_surface_sculpt(*ob, DRW_object_get_data_for_drawing<Mesh>(*ob));
|
||||
}
|
||||
|
||||
blender::gpu::Batch *DRW_cache_mesh_surface_weights_get(Object *ob)
|
||||
{
|
||||
using namespace blender::draw;
|
||||
BLI_assert(ob->type == OB_MESH);
|
||||
return DRW_mesh_batch_cache_get_surface_weights(*static_cast<Mesh *>(ob->data));
|
||||
return DRW_mesh_batch_cache_get_surface_weights(DRW_object_get_data_for_drawing<Mesh>(*ob));
|
||||
}
|
||||
|
||||
blender::gpu::Batch *DRW_cache_mesh_face_wireframe_get(Object *ob)
|
||||
{
|
||||
using namespace blender::draw;
|
||||
BLI_assert(ob->type == OB_MESH);
|
||||
return DRW_mesh_batch_cache_get_wireframes_face(*static_cast<Mesh *>(ob->data));
|
||||
return DRW_mesh_batch_cache_get_wireframes_face(DRW_object_get_data_for_drawing<Mesh>(*ob));
|
||||
}
|
||||
|
||||
blender::gpu::Batch *DRW_cache_mesh_surface_mesh_analysis_get(Object *ob)
|
||||
{
|
||||
using namespace blender::draw;
|
||||
BLI_assert(ob->type == OB_MESH);
|
||||
return DRW_mesh_batch_cache_get_edit_mesh_analysis(*static_cast<Mesh *>(ob->data));
|
||||
return DRW_mesh_batch_cache_get_edit_mesh_analysis(DRW_object_get_data_for_drawing<Mesh>(*ob));
|
||||
}
|
||||
|
||||
blender::gpu::Batch *DRW_cache_mesh_surface_viewer_attribute_get(Object *ob)
|
||||
{
|
||||
using namespace blender::draw;
|
||||
BLI_assert(ob->type == OB_MESH);
|
||||
return DRW_mesh_batch_cache_get_surface_viewer_attribute(*static_cast<Mesh *>(ob->data));
|
||||
return DRW_mesh_batch_cache_get_surface_viewer_attribute(
|
||||
DRW_object_get_data_for_drawing<Mesh>(*ob));
|
||||
}
|
||||
|
||||
/** \} */
|
||||
@@ -322,24 +329,24 @@ blender::gpu::Batch *DRW_cache_curve_edge_wire_get(Object *ob)
|
||||
{
|
||||
using namespace blender::draw;
|
||||
BLI_assert(ob->type == OB_CURVES_LEGACY);
|
||||
Curve *cu = static_cast<Curve *>(ob->data);
|
||||
return DRW_curve_batch_cache_get_wire_edge(cu);
|
||||
Curve &cu = DRW_object_get_data_for_drawing<Curve>(*ob);
|
||||
return DRW_curve_batch_cache_get_wire_edge(&cu);
|
||||
}
|
||||
|
||||
blender::gpu::Batch *DRW_cache_curve_edge_wire_viewer_attribute_get(Object *ob)
|
||||
{
|
||||
using namespace blender::draw;
|
||||
BLI_assert(ob->type == OB_CURVES_LEGACY);
|
||||
Curve *cu = static_cast<Curve *>(ob->data);
|
||||
return DRW_curve_batch_cache_get_wire_edge_viewer_attribute(cu);
|
||||
Curve &cu = DRW_object_get_data_for_drawing<Curve>(*ob);
|
||||
return DRW_curve_batch_cache_get_wire_edge_viewer_attribute(&cu);
|
||||
}
|
||||
|
||||
blender::gpu::Batch *DRW_cache_curve_edge_normal_get(Object *ob)
|
||||
{
|
||||
using namespace blender::draw;
|
||||
BLI_assert(ob->type == OB_CURVES_LEGACY);
|
||||
Curve *cu = static_cast<Curve *>(ob->data);
|
||||
return DRW_curve_batch_cache_get_normal_edge(cu);
|
||||
Curve &cu = DRW_object_get_data_for_drawing<Curve>(*ob);
|
||||
return DRW_curve_batch_cache_get_normal_edge(&cu);
|
||||
}
|
||||
|
||||
blender::gpu::Batch *DRW_cache_curve_edge_overlay_get(Object *ob)
|
||||
@@ -347,8 +354,8 @@ blender::gpu::Batch *DRW_cache_curve_edge_overlay_get(Object *ob)
|
||||
using namespace blender::draw;
|
||||
BLI_assert(ELEM(ob->type, OB_CURVES_LEGACY, OB_SURF));
|
||||
|
||||
Curve *cu = static_cast<Curve *>(ob->data);
|
||||
return DRW_curve_batch_cache_get_edit_edges(cu);
|
||||
Curve &cu = DRW_object_get_data_for_drawing<Curve>(*ob);
|
||||
return DRW_curve_batch_cache_get_edit_edges(&cu);
|
||||
}
|
||||
|
||||
blender::gpu::Batch *DRW_cache_curve_vert_overlay_get(Object *ob)
|
||||
@@ -356,8 +363,8 @@ blender::gpu::Batch *DRW_cache_curve_vert_overlay_get(Object *ob)
|
||||
using namespace blender::draw;
|
||||
BLI_assert(ELEM(ob->type, OB_CURVES_LEGACY, OB_SURF));
|
||||
|
||||
Curve *cu = static_cast<Curve *>(ob->data);
|
||||
return DRW_curve_batch_cache_get_edit_verts(cu);
|
||||
Curve &cu = DRW_object_get_data_for_drawing<Curve>(*ob);
|
||||
return DRW_curve_batch_cache_get_edit_verts(&cu);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
@@ -370,8 +377,8 @@ blender::gpu::Batch *DRW_cache_text_edge_wire_get(Object *ob)
|
||||
{
|
||||
using namespace blender::draw;
|
||||
BLI_assert(ob->type == OB_FONT);
|
||||
Curve *cu = static_cast<Curve *>(ob->data);
|
||||
return DRW_curve_batch_cache_get_wire_edge(cu);
|
||||
Curve &cu = DRW_object_get_data_for_drawing<Curve>(*ob);
|
||||
return DRW_curve_batch_cache_get_wire_edge(&cu);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
@@ -384,8 +391,8 @@ blender::gpu::Batch *DRW_cache_surf_edge_wire_get(Object *ob)
|
||||
{
|
||||
using namespace blender::draw;
|
||||
BLI_assert(ob->type == OB_SURF);
|
||||
Curve *cu = static_cast<Curve *>(ob->data);
|
||||
return DRW_curve_batch_cache_get_wire_edge(cu);
|
||||
Curve &cu = DRW_object_get_data_for_drawing<Curve>(*ob);
|
||||
return DRW_curve_batch_cache_get_wire_edge(&cu);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
@@ -399,8 +406,8 @@ blender::gpu::Batch *DRW_cache_lattice_verts_get(Object *ob)
|
||||
using namespace blender::draw;
|
||||
BLI_assert(ob->type == OB_LATTICE);
|
||||
|
||||
Lattice *lt = static_cast<Lattice *>(ob->data);
|
||||
return DRW_lattice_batch_cache_get_all_verts(lt);
|
||||
Lattice < = DRW_object_get_data_for_drawing<Lattice>(*ob);
|
||||
return DRW_lattice_batch_cache_get_all_verts(<);
|
||||
}
|
||||
|
||||
blender::gpu::Batch *DRW_cache_lattice_wire_get(Object *ob, bool use_weight)
|
||||
@@ -408,14 +415,14 @@ blender::gpu::Batch *DRW_cache_lattice_wire_get(Object *ob, bool use_weight)
|
||||
using namespace blender::draw;
|
||||
BLI_assert(ob->type == OB_LATTICE);
|
||||
|
||||
Lattice *lt = static_cast<Lattice *>(ob->data);
|
||||
Lattice < = DRW_object_get_data_for_drawing<Lattice>(*ob);
|
||||
int actdef = -1;
|
||||
|
||||
if (use_weight && !BLI_listbase_is_empty(<->vertex_group_names) && lt->editlatt->latt->dvert) {
|
||||
actdef = lt->vertex_group_active_index - 1;
|
||||
if (use_weight && !BLI_listbase_is_empty(<.vertex_group_names) && lt.editlatt->latt->dvert) {
|
||||
actdef = lt.vertex_group_active_index - 1;
|
||||
}
|
||||
|
||||
return DRW_lattice_batch_cache_get_all_edges(lt, use_weight, actdef);
|
||||
return DRW_lattice_batch_cache_get_all_edges(<, use_weight, actdef);
|
||||
}
|
||||
|
||||
blender::gpu::Batch *DRW_cache_lattice_vert_overlay_get(Object *ob)
|
||||
@@ -423,8 +430,8 @@ blender::gpu::Batch *DRW_cache_lattice_vert_overlay_get(Object *ob)
|
||||
using namespace blender::draw;
|
||||
BLI_assert(ob->type == OB_LATTICE);
|
||||
|
||||
Lattice *lt = static_cast<Lattice *>(ob->data);
|
||||
return DRW_lattice_batch_cache_get_edit_verts(lt);
|
||||
Lattice < = DRW_object_get_data_for_drawing<Lattice>(*ob);
|
||||
return DRW_lattice_batch_cache_get_edit_verts(<);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
@@ -438,8 +445,8 @@ blender::gpu::Batch *DRW_cache_pointcloud_vert_overlay_get(Object *ob)
|
||||
using namespace blender::draw;
|
||||
BLI_assert(ob->type == OB_POINTCLOUD);
|
||||
|
||||
PointCloud *pointcloud = static_cast<PointCloud *>(ob->data);
|
||||
return DRW_pointcloud_batch_cache_get_edit_dots(pointcloud);
|
||||
PointCloud &pointcloud = DRW_object_get_data_for_drawing<PointCloud>(*ob);
|
||||
return DRW_pointcloud_batch_cache_get_edit_dots(&pointcloud);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
@@ -453,13 +460,14 @@ namespace blender::draw {
|
||||
blender::gpu::Batch *DRW_cache_volume_face_wireframe_get(Object *ob)
|
||||
{
|
||||
BLI_assert(ob->type == OB_VOLUME);
|
||||
return DRW_volume_batch_cache_get_wireframes_face(static_cast<Volume *>(ob->data));
|
||||
return DRW_volume_batch_cache_get_wireframes_face(&DRW_object_get_data_for_drawing<Volume>(*ob));
|
||||
}
|
||||
|
||||
blender::gpu::Batch *DRW_cache_volume_selection_surface_get(Object *ob)
|
||||
{
|
||||
BLI_assert(ob->type == OB_VOLUME);
|
||||
return DRW_volume_batch_cache_get_selection_surface(static_cast<Volume *>(ob->data));
|
||||
return DRW_volume_batch_cache_get_selection_surface(
|
||||
&DRW_object_get_data_for_drawing<Volume>(*ob));
|
||||
}
|
||||
|
||||
} // namespace blender::draw
|
||||
@@ -520,27 +528,27 @@ void drw_batch_cache_validate(Object *ob)
|
||||
using namespace blender::draw;
|
||||
switch (ob->type) {
|
||||
case OB_MESH:
|
||||
DRW_mesh_batch_cache_validate(*(Mesh *)ob->data);
|
||||
DRW_mesh_batch_cache_validate(DRW_object_get_data_for_drawing<Mesh>(*ob));
|
||||
break;
|
||||
case OB_CURVES_LEGACY:
|
||||
case OB_FONT:
|
||||
case OB_SURF:
|
||||
DRW_curve_batch_cache_validate((Curve *)ob->data);
|
||||
DRW_curve_batch_cache_validate(&DRW_object_get_data_for_drawing<Curve>(*ob));
|
||||
break;
|
||||
case OB_LATTICE:
|
||||
DRW_lattice_batch_cache_validate((Lattice *)ob->data);
|
||||
DRW_lattice_batch_cache_validate(&DRW_object_get_data_for_drawing<Lattice>(*ob));
|
||||
break;
|
||||
case OB_CURVES:
|
||||
DRW_curves_batch_cache_validate((Curves *)ob->data);
|
||||
DRW_curves_batch_cache_validate(&DRW_object_get_data_for_drawing<Curves>(*ob));
|
||||
break;
|
||||
case OB_POINTCLOUD:
|
||||
DRW_pointcloud_batch_cache_validate((PointCloud *)ob->data);
|
||||
DRW_pointcloud_batch_cache_validate(&DRW_object_get_data_for_drawing<PointCloud>(*ob));
|
||||
break;
|
||||
case OB_VOLUME:
|
||||
DRW_volume_batch_cache_validate((Volume *)ob->data);
|
||||
DRW_volume_batch_cache_validate(&DRW_object_get_data_for_drawing<Volume>(*ob));
|
||||
break;
|
||||
case OB_GREASE_PENCIL:
|
||||
DRW_grease_pencil_batch_cache_validate((GreasePencil *)ob->data);
|
||||
DRW_grease_pencil_batch_cache_validate(&DRW_object_get_data_for_drawing<GreasePencil>(*ob));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -563,8 +571,12 @@ void drw_batch_cache_generate_requested(Object *ob, TaskGraph &task_graph)
|
||||
|
||||
switch (ob->type) {
|
||||
case OB_MESH:
|
||||
DRW_mesh_batch_cache_create_requested(
|
||||
task_graph, *ob, *(Mesh *)ob->data, *scene, is_paint_mode, use_hide);
|
||||
DRW_mesh_batch_cache_create_requested(task_graph,
|
||||
*ob,
|
||||
DRW_object_get_data_for_drawing<Mesh>(*ob),
|
||||
*scene,
|
||||
is_paint_mode,
|
||||
use_hide);
|
||||
break;
|
||||
case OB_CURVES_LEGACY:
|
||||
case OB_FONT:
|
||||
@@ -627,13 +639,14 @@ void DRW_batch_cache_free_old(Object *ob, int ctime)
|
||||
{
|
||||
switch (ob->type) {
|
||||
case OB_MESH:
|
||||
DRW_mesh_batch_cache_free_old((Mesh *)ob->data, ctime);
|
||||
DRW_mesh_batch_cache_free_old(&DRW_object_get_data_for_drawing<Mesh>(*ob), ctime);
|
||||
break;
|
||||
case OB_CURVES:
|
||||
DRW_curves_batch_cache_free_old((Curves *)ob->data, ctime);
|
||||
DRW_curves_batch_cache_free_old(&DRW_object_get_data_for_drawing<Curves>(*ob), ctime);
|
||||
break;
|
||||
case OB_POINTCLOUD:
|
||||
DRW_pointcloud_batch_cache_free_old((PointCloud *)ob->data, ctime);
|
||||
DRW_pointcloud_batch_cache_free_old(&DRW_object_get_data_for_drawing<PointCloud>(*ob),
|
||||
ctime);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -1095,15 +1095,15 @@ static void create_edit_points_position_vbo(
|
||||
|
||||
void DRW_curves_batch_cache_create_requested(Object *ob)
|
||||
{
|
||||
Curves *curves_id = static_cast<Curves *>(ob->data);
|
||||
Curves &curves_id = DRW_object_get_data_for_drawing<Curves>(*ob);
|
||||
Object *ob_orig = DEG_get_original_object(ob);
|
||||
if (ob_orig == nullptr) {
|
||||
return;
|
||||
}
|
||||
const Curves *curves_orig_id = static_cast<Curves *>(ob_orig->data);
|
||||
const Curves &curves_orig_id = DRW_object_get_data_for_drawing<Curves>(*ob_orig);
|
||||
|
||||
draw::CurvesBatchCache &cache = draw::get_batch_cache(*curves_id);
|
||||
const bke::CurvesGeometry &curves_orig = curves_orig_id->geometry.wrap();
|
||||
draw::CurvesBatchCache &cache = draw::get_batch_cache(curves_id);
|
||||
const bke::CurvesGeometry &curves_orig = curves_orig_id.geometry.wrap();
|
||||
|
||||
bool is_edit_data_needed = false;
|
||||
|
||||
|
||||
@@ -1484,7 +1484,7 @@ void DRW_grease_pencil_batch_cache_free(GreasePencil *grease_pencil)
|
||||
|
||||
gpu::Batch *DRW_cache_grease_pencil_get(const Scene *scene, Object *ob)
|
||||
{
|
||||
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(ob->data);
|
||||
GreasePencil &grease_pencil = DRW_object_get_data_for_drawing<GreasePencil>(*ob);
|
||||
GreasePencilBatchCache *cache = grease_pencil_batch_cache_get(grease_pencil);
|
||||
grease_pencil_geom_batch_ensure(*ob, grease_pencil, *scene);
|
||||
|
||||
@@ -1493,7 +1493,7 @@ gpu::Batch *DRW_cache_grease_pencil_get(const Scene *scene, Object *ob)
|
||||
|
||||
gpu::Batch *DRW_cache_grease_pencil_edit_points_get(const Scene *scene, Object *ob)
|
||||
{
|
||||
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(ob->data);
|
||||
GreasePencil &grease_pencil = DRW_object_get_data_for_drawing<GreasePencil>(*ob);
|
||||
GreasePencilBatchCache *cache = grease_pencil_batch_cache_get(grease_pencil);
|
||||
grease_pencil_edit_batch_ensure(*ob, grease_pencil, *scene);
|
||||
|
||||
@@ -1503,7 +1503,7 @@ gpu::Batch *DRW_cache_grease_pencil_edit_points_get(const Scene *scene, Object *
|
||||
|
||||
gpu::Batch *DRW_cache_grease_pencil_edit_lines_get(const Scene *scene, Object *ob)
|
||||
{
|
||||
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(ob->data);
|
||||
GreasePencil &grease_pencil = DRW_object_get_data_for_drawing<GreasePencil>(*ob);
|
||||
GreasePencilBatchCache *cache = grease_pencil_batch_cache_get(grease_pencil);
|
||||
grease_pencil_edit_batch_ensure(*ob, grease_pencil, *scene);
|
||||
|
||||
@@ -1513,7 +1513,7 @@ gpu::Batch *DRW_cache_grease_pencil_edit_lines_get(const Scene *scene, Object *o
|
||||
|
||||
gpu::VertBuf *DRW_cache_grease_pencil_position_buffer_get(const Scene *scene, Object *ob)
|
||||
{
|
||||
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(ob->data);
|
||||
GreasePencil &grease_pencil = DRW_object_get_data_for_drawing<GreasePencil>(*ob);
|
||||
GreasePencilBatchCache *cache = grease_pencil_batch_cache_get(grease_pencil);
|
||||
grease_pencil_geom_batch_ensure(*ob, grease_pencil, *scene);
|
||||
|
||||
@@ -1522,7 +1522,7 @@ gpu::VertBuf *DRW_cache_grease_pencil_position_buffer_get(const Scene *scene, Ob
|
||||
|
||||
gpu::VertBuf *DRW_cache_grease_pencil_color_buffer_get(const Scene *scene, Object *ob)
|
||||
{
|
||||
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(ob->data);
|
||||
GreasePencil &grease_pencil = DRW_object_get_data_for_drawing<GreasePencil>(*ob);
|
||||
GreasePencilBatchCache *cache = grease_pencil_batch_cache_get(grease_pencil);
|
||||
grease_pencil_geom_batch_ensure(*ob, grease_pencil, *scene);
|
||||
|
||||
@@ -1531,7 +1531,7 @@ gpu::VertBuf *DRW_cache_grease_pencil_color_buffer_get(const Scene *scene, Objec
|
||||
|
||||
gpu::Batch *DRW_cache_grease_pencil_weight_points_get(const Scene *scene, Object *ob)
|
||||
{
|
||||
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(ob->data);
|
||||
GreasePencil &grease_pencil = DRW_object_get_data_for_drawing<GreasePencil>(*ob);
|
||||
GreasePencilBatchCache *cache = grease_pencil_batch_cache_get(grease_pencil);
|
||||
grease_pencil_weight_batch_ensure(*ob, grease_pencil, *scene);
|
||||
|
||||
@@ -1541,7 +1541,7 @@ gpu::Batch *DRW_cache_grease_pencil_weight_points_get(const Scene *scene, Object
|
||||
|
||||
gpu::Batch *DRW_cache_grease_pencil_weight_lines_get(const Scene *scene, Object *ob)
|
||||
{
|
||||
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(ob->data);
|
||||
GreasePencil &grease_pencil = DRW_object_get_data_for_drawing<GreasePencil>(*ob);
|
||||
GreasePencilBatchCache *cache = grease_pencil_batch_cache_get(grease_pencil);
|
||||
grease_pencil_weight_batch_ensure(*ob, grease_pencil, *scene);
|
||||
|
||||
@@ -1551,7 +1551,7 @@ gpu::Batch *DRW_cache_grease_pencil_weight_lines_get(const Scene *scene, Object
|
||||
|
||||
gpu::Batch *DRW_cache_grease_pencil_face_wireframe_get(const Scene *scene, Object *ob)
|
||||
{
|
||||
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(ob->data);
|
||||
GreasePencil &grease_pencil = DRW_object_get_data_for_drawing<GreasePencil>(*ob);
|
||||
GreasePencilBatchCache *cache = grease_pencil_batch_cache_get(grease_pencil);
|
||||
grease_pencil_wire_batch_ensure(*ob, grease_pencil, *scene);
|
||||
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
#include "GPU_batch.hh"
|
||||
#include "GPU_material.hh"
|
||||
|
||||
#include "DRW_render.hh"
|
||||
|
||||
#include "draw_attributes.hh"
|
||||
#include "draw_cache_impl.hh"
|
||||
#include "draw_cache_inline.hh"
|
||||
@@ -392,14 +394,14 @@ gpu::Batch *pointcloud_surface_get(PointCloud *pointcloud)
|
||||
|
||||
gpu::Batch *DRW_pointcloud_batch_cache_get_dots(Object *ob)
|
||||
{
|
||||
PointCloud &pointcloud = *static_cast<PointCloud *>(ob->data);
|
||||
PointCloud &pointcloud = DRW_object_get_data_for_drawing<PointCloud>(*ob);
|
||||
PointCloudBatchCache *cache = pointcloud_batch_cache_get(pointcloud);
|
||||
return DRW_batch_request(&cache->eval_cache.dots);
|
||||
}
|
||||
|
||||
gpu::VertBuf *DRW_pointcloud_position_and_radius_buffer_get(Object *ob)
|
||||
{
|
||||
PointCloud &pointcloud = *static_cast<PointCloud *>(ob->data);
|
||||
PointCloud &pointcloud = DRW_object_get_data_for_drawing<PointCloud>(*ob);
|
||||
return pointcloud_position_and_radius_get(&pointcloud);
|
||||
}
|
||||
|
||||
@@ -453,8 +455,8 @@ static void build_edit_selection_indices(const PointCloud &pointcloud, gpu::Inde
|
||||
|
||||
void DRW_pointcloud_batch_cache_create_requested(Object *ob)
|
||||
{
|
||||
PointCloud *pointcloud = static_cast<PointCloud *>(ob->data);
|
||||
PointCloudBatchCache &cache = *pointcloud_batch_cache_get(*pointcloud);
|
||||
PointCloud &pointcloud = DRW_object_get_data_for_drawing<PointCloud>(*ob);
|
||||
PointCloudBatchCache &cache = *pointcloud_batch_cache_get(pointcloud);
|
||||
|
||||
if (DRW_batch_requested(cache.eval_cache.dots, GPU_PRIM_POINTS)) {
|
||||
DRW_vbo_request(cache.eval_cache.dots, &cache.eval_cache.pos_rad);
|
||||
@@ -479,20 +481,20 @@ void DRW_pointcloud_batch_cache_create_requested(Object *ob)
|
||||
DRW_vbo_request(nullptr, &cache.eval_cache.attributes_buf[j]);
|
||||
|
||||
if (DRW_vbo_requested(cache.eval_cache.attributes_buf[j])) {
|
||||
pointcloud_extract_attribute(*pointcloud, cache, cache.eval_cache.attr_used.requests[j], j);
|
||||
pointcloud_extract_attribute(pointcloud, cache, cache.eval_cache.attr_used.requests[j], j);
|
||||
}
|
||||
}
|
||||
|
||||
if (DRW_ibo_requested(cache.edit_selection_indices)) {
|
||||
build_edit_selection_indices(*pointcloud, *cache.edit_selection_indices);
|
||||
build_edit_selection_indices(pointcloud, *cache.edit_selection_indices);
|
||||
}
|
||||
|
||||
if (DRW_ibo_requested(cache.eval_cache.geom_indices)) {
|
||||
pointcloud_extract_indices(*pointcloud, cache);
|
||||
pointcloud_extract_indices(pointcloud, cache);
|
||||
}
|
||||
|
||||
if (DRW_vbo_requested(cache.eval_cache.pos_rad)) {
|
||||
pointcloud_extract_position_and_radius(*pointcloud, cache);
|
||||
pointcloud_extract_position_and_radius(pointcloud, cache);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -369,6 +369,18 @@ bool DRW_object_is_visible_psys_in_active_context(const Object *object, const Pa
|
||||
return true;
|
||||
}
|
||||
|
||||
template<> Mesh &DRW_object_get_data_for_drawing(const Object &object)
|
||||
{
|
||||
/* For drawing we want either the base mesh if GPU subdivision is enabled, or the
|
||||
* tessellated mesh if GPU subdivision is disabled. */
|
||||
BLI_assert(object.type == OB_MESH);
|
||||
Mesh &mesh = *static_cast<Mesh *>(object.data);
|
||||
if (BKE_subsurf_modifier_has_gpu_subdiv(&mesh)) {
|
||||
return mesh;
|
||||
}
|
||||
return *BKE_mesh_wrapper_ensure_subdivision(&mesh);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
@@ -157,7 +157,7 @@ gpu::VertBuf *DRW_curves_pos_buffer_get(Object *object)
|
||||
const int subdiv = scene->r.hair_subdiv;
|
||||
const int thickness_res = (scene->r.hair_type == SCE_HAIR_SHAPE_STRAND) ? 1 : 2;
|
||||
|
||||
Curves &curves = *static_cast<Curves *>(object->data);
|
||||
Curves &curves = DRW_object_get_data_for_drawing<Curves>(*object);
|
||||
CurvesEvalCache *cache = drw_curves_cache_get(curves, nullptr, subdiv, thickness_res);
|
||||
|
||||
return cache->final.proc_buf;
|
||||
@@ -262,7 +262,7 @@ gpu::VertBuf *curves_pos_buffer_get(Scene *scene, Object *object)
|
||||
const int subdiv = scene->r.hair_subdiv;
|
||||
const int thickness_res = (scene->r.hair_type == SCE_HAIR_SHAPE_STRAND) ? 1 : 2;
|
||||
|
||||
Curves &curves = *static_cast<Curves *>(object->data);
|
||||
Curves &curves = DRW_object_get_data_for_drawing<Curves>(*object);
|
||||
CurvesEvalCache *cache = curves_cache_get(curves, nullptr, subdiv, thickness_res);
|
||||
|
||||
return cache->final.proc_buf;
|
||||
@@ -279,7 +279,7 @@ gpu::Batch *curves_sub_pass_setup_implementation(PassT &sub_ps,
|
||||
CurvesModule &module = *drw_get().data->curves_module;
|
||||
CurvesInfosBuf &curves_infos = module.ubo_pool.alloc();
|
||||
BLI_assert(ob->type == OB_CURVES);
|
||||
Curves &curves_id = *static_cast<Curves *>(ob->data);
|
||||
Curves &curves_id = DRW_object_get_data_for_drawing<Curves>(*ob);
|
||||
|
||||
const int subdiv = scene->r.hair_subdiv;
|
||||
const int thickness_res = (scene->r.hair_type == SCE_HAIR_SHAPE_STRAND) ? 1 : 2;
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
|
||||
#include "DRW_engine.hh"
|
||||
#include "DRW_pbvh.hh"
|
||||
#include "DRW_render.hh"
|
||||
|
||||
#include "attribute_convert.hh"
|
||||
#include "bmesh.hh"
|
||||
@@ -620,7 +621,7 @@ static void update_positions_mesh(const Object &object,
|
||||
{
|
||||
const bke::pbvh::Tree &pbvh = *bke::object::pbvh_get(object);
|
||||
const Span<bke::pbvh::MeshNode> nodes = pbvh.nodes<bke::pbvh::MeshNode>();
|
||||
const Mesh &mesh = *static_cast<const Mesh *>(object.data);
|
||||
const Mesh &mesh = DRW_object_get_data_for_drawing<Mesh>(object);
|
||||
const OffsetIndices<int> faces = mesh.faces();
|
||||
const Span<int> corner_verts = mesh.corner_verts();
|
||||
const Span<float3> vert_positions = bke::pbvh::vert_positions_eval_from_eval(object);
|
||||
@@ -637,7 +638,7 @@ static void update_normals_mesh(const Object &object,
|
||||
{
|
||||
const bke::pbvh::Tree &pbvh = *bke::object::pbvh_get(object);
|
||||
const Span<bke::pbvh::MeshNode> nodes = pbvh.nodes<bke::pbvh::MeshNode>();
|
||||
const Mesh &mesh = *static_cast<const Mesh *>(object.data);
|
||||
const Mesh &mesh = DRW_object_get_data_for_drawing<Mesh>(object);
|
||||
const OffsetIndices<int> faces = mesh.faces();
|
||||
const Span<int> corner_verts = mesh.corner_verts();
|
||||
const Span<float3> vert_normals = bke::pbvh::vert_normals_eval_from_eval(object);
|
||||
@@ -671,7 +672,7 @@ BLI_NOINLINE static void update_masks_mesh(const Object &object,
|
||||
{
|
||||
const bke::pbvh::Tree &pbvh = *bke::object::pbvh_get(object);
|
||||
const Span<bke::pbvh::MeshNode> nodes = pbvh.nodes<bke::pbvh::MeshNode>();
|
||||
const Mesh &mesh = *static_cast<const Mesh *>(object.data);
|
||||
const Mesh &mesh = DRW_object_get_data_for_drawing<Mesh>(object);
|
||||
const OffsetIndices<int> faces = mesh.faces();
|
||||
const Span<int> corner_verts = mesh.corner_verts();
|
||||
const VArraySpan mask = *orig_mesh_data.attributes.lookup<float>(".sculpt_mask",
|
||||
@@ -701,7 +702,7 @@ BLI_NOINLINE static void update_face_sets_mesh(const Object &object,
|
||||
{
|
||||
const bke::pbvh::Tree &pbvh = *bke::object::pbvh_get(object);
|
||||
const Span<bke::pbvh::MeshNode> nodes = pbvh.nodes<bke::pbvh::MeshNode>();
|
||||
const Mesh &mesh = *static_cast<const Mesh *>(object.data);
|
||||
const Mesh &mesh = DRW_object_get_data_for_drawing<Mesh>(object);
|
||||
const OffsetIndices<int> faces = mesh.faces();
|
||||
const int color_default = orig_mesh_data.face_set_default;
|
||||
const int color_seed = orig_mesh_data.face_set_seed;
|
||||
@@ -743,7 +744,7 @@ BLI_NOINLINE static void update_generic_attribute_mesh(const Object &object,
|
||||
{
|
||||
const bke::pbvh::Tree &pbvh = *bke::object::pbvh_get(object);
|
||||
const Span<bke::pbvh::MeshNode> nodes = pbvh.nodes<bke::pbvh::MeshNode>();
|
||||
const Mesh &mesh = *static_cast<const Mesh *>(object.data);
|
||||
const Mesh &mesh = DRW_object_get_data_for_drawing<Mesh>(object);
|
||||
const OffsetIndices<int> faces = mesh.faces();
|
||||
const Span<int> corner_verts = mesh.corner_verts();
|
||||
const StringRefNull name = attr.name;
|
||||
@@ -1414,7 +1415,7 @@ static Array<int> calc_material_indices(const Object &object, const OrigMeshData
|
||||
switch (pbvh.type()) {
|
||||
case bke::pbvh::Type::Mesh: {
|
||||
const Span<bke::pbvh::MeshNode> nodes = pbvh.nodes<bke::pbvh::MeshNode>();
|
||||
const Mesh &mesh = *static_cast<const Mesh *>(object.data);
|
||||
const Mesh &mesh = DRW_object_get_data_for_drawing<Mesh>(object);
|
||||
const bke::AttributeAccessor attributes = mesh.attributes();
|
||||
const VArray material_indices = *attributes.lookup<int>("material_index",
|
||||
bke::AttrDomain::Face);
|
||||
@@ -1644,7 +1645,7 @@ Span<gpu::IndexBuf *> DrawCacheImpl::ensure_lines_indices(const Object &object,
|
||||
switch (pbvh.type()) {
|
||||
case bke::pbvh::Type::Mesh: {
|
||||
const Span<bke::pbvh::MeshNode> nodes = pbvh.nodes<bke::pbvh::MeshNode>();
|
||||
const Mesh &mesh = *static_cast<const Mesh *>(object.data);
|
||||
const Mesh &mesh = DRW_object_get_data_for_drawing<Mesh>(object);
|
||||
const OffsetIndices<int> faces = mesh.faces();
|
||||
const bke::AttributeAccessor attributes = orig_mesh_data.attributes;
|
||||
const VArraySpan hide_poly = *attributes.lookup<bool>(".hide_poly", bke::AttrDomain::Face);
|
||||
@@ -1826,7 +1827,7 @@ Span<gpu::IndexBuf *> DrawCacheImpl::ensure_tri_indices(const Object &object,
|
||||
const IndexMask nodes_to_calculate = IndexMask::from_predicate(
|
||||
node_mask, GrainSize(8196), memory, [&](const int i) { return !ibos[i]; });
|
||||
|
||||
const Mesh &mesh = *static_cast<const Mesh *>(object.data);
|
||||
const Mesh &mesh = DRW_object_get_data_for_drawing<Mesh>(object);
|
||||
const OffsetIndices<int> faces = mesh.faces();
|
||||
const Span<int3> corner_tris = mesh.corner_tris();
|
||||
const bke::AttributeAccessor attributes = orig_mesh_data.attributes;
|
||||
|
||||
@@ -71,7 +71,7 @@ gpu::Batch *pointcloud_sub_pass_setup_implementation(PassT &sub_ps,
|
||||
GPUMaterial *gpu_material)
|
||||
{
|
||||
BLI_assert(object->type == OB_POINTCLOUD);
|
||||
PointCloud &pointcloud = *static_cast<PointCloud *>(object->data);
|
||||
PointCloud &pointcloud = DRW_object_get_data_for_drawing<PointCloud>(*object);
|
||||
|
||||
PointCloudModule &module = *drw_get().data->pointcloud_module;
|
||||
/* Fix issue with certain driver not drawing anything if there is no texture bound to
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "DNA_meta_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
|
||||
#include "DRW_render.hh"
|
||||
#include "draw_handle.hh"
|
||||
#include "draw_shader_shared.hh"
|
||||
|
||||
@@ -116,7 +117,7 @@ inline void ObjectInfos::sync(const blender::draw::ObjectRef ref, bool is_active
|
||||
switch (GS(reinterpret_cast<ID *>(ref.object->data)->name)) {
|
||||
case ID_VO: {
|
||||
std::optional<const blender::Bounds<float3>> bounds = BKE_volume_min_max(
|
||||
static_cast<const Volume *>(ref.object->data));
|
||||
&DRW_object_get_data_for_drawing<const Volume>(*ref.object));
|
||||
if (bounds) {
|
||||
orco_add = blender::math::midpoint(bounds->min, bounds->max);
|
||||
orco_mul = (bounds->max - bounds->min) * 0.5f;
|
||||
@@ -128,18 +129,19 @@ inline void ObjectInfos::sync(const blender::draw::ObjectRef ref, bool is_active
|
||||
break;
|
||||
}
|
||||
case ID_ME: {
|
||||
BKE_mesh_texspace_get(static_cast<Mesh *>(ref.object->data), orco_add, orco_mul);
|
||||
BKE_mesh_texspace_get(
|
||||
&DRW_object_get_data_for_drawing<Mesh>(*ref.object), orco_add, orco_mul);
|
||||
break;
|
||||
}
|
||||
case ID_CU_LEGACY: {
|
||||
Curve &cu = *static_cast<Curve *>(ref.object->data);
|
||||
Curve &cu = DRW_object_get_data_for_drawing<Curve>(*ref.object);
|
||||
BKE_curve_texspace_ensure(&cu);
|
||||
orco_add = cu.texspace_location;
|
||||
orco_mul = cu.texspace_size;
|
||||
break;
|
||||
}
|
||||
case ID_MB: {
|
||||
MetaBall &mb = *static_cast<MetaBall *>(ref.object->data);
|
||||
MetaBall &mb = DRW_object_get_data_for_drawing<MetaBall>(*ref.object);
|
||||
orco_add = mb.texspace_location;
|
||||
orco_mul = mb.texspace_size;
|
||||
break;
|
||||
|
||||
@@ -162,11 +162,11 @@ Vector<SculptBatch> sculpt_batches_per_material_get(const Object *ob,
|
||||
Span<const GPUMaterial *> materials)
|
||||
{
|
||||
BLI_assert(ob->type == OB_MESH);
|
||||
const Mesh *mesh = static_cast<const Mesh *>(ob->data);
|
||||
const Mesh &mesh = DRW_object_get_data_for_drawing<Mesh>(*ob);
|
||||
|
||||
DRW_Attributes draw_attrs;
|
||||
DRW_MeshCDMask cd_needed;
|
||||
DRW_mesh_get_attributes(*ob, *mesh, materials, &draw_attrs, &cd_needed);
|
||||
DRW_mesh_get_attributes(*ob, mesh, materials, &draw_attrs, &cd_needed);
|
||||
|
||||
Vector<pbvh::AttributeRequest, 16> attrs;
|
||||
|
||||
@@ -181,8 +181,8 @@ Vector<SculptBatch> sculpt_batches_per_material_get(const Object *ob,
|
||||
/* UV maps are not in attribute requests. */
|
||||
for (uint i = 0; i < 32; i++) {
|
||||
if (cd_needed.uv & (1 << i)) {
|
||||
int layer_i = CustomData_get_layer_index_n(&mesh->corner_data, CD_PROP_FLOAT2, i);
|
||||
CustomDataLayer *layer = layer_i != -1 ? mesh->corner_data.layers + layer_i : nullptr;
|
||||
int layer_i = CustomData_get_layer_index_n(&mesh.corner_data, CD_PROP_FLOAT2, i);
|
||||
CustomDataLayer *layer = layer_i != -1 ? mesh.corner_data.layers + layer_i : nullptr;
|
||||
if (layer) {
|
||||
attrs.append(pbvh::GenericRequest{layer->name, CD_PROP_FLOAT2, bke::AttrDomain::Corner});
|
||||
}
|
||||
|
||||
@@ -126,18 +126,18 @@ PassType *volume_object_grids_init(PassType &ps,
|
||||
Object *ob,
|
||||
ListBaseWrapper<GPUMaterialAttribute> &attrs)
|
||||
{
|
||||
Volume *volume = (Volume *)ob->data;
|
||||
BKE_volume_load(volume, G.main);
|
||||
Volume &volume = DRW_object_get_data_for_drawing<Volume>(*ob);
|
||||
BKE_volume_load(&volume, G.main);
|
||||
|
||||
/* Render nothing if there is no attribute. */
|
||||
if (BKE_volume_num_grids(volume) == 0) {
|
||||
if (BKE_volume_num_grids(&volume) == 0) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
VolumeModule &module = *drw_get().data->volume_module;
|
||||
VolumeInfosBuf &volume_infos = *module.ubo_pool.alloc();
|
||||
|
||||
volume_infos.density_scale = BKE_volume_density_scale(volume, ob->object_to_world().ptr());
|
||||
volume_infos.density_scale = BKE_volume_density_scale(&volume, ob->object_to_world().ptr());
|
||||
volume_infos.color_mul = float4(1.0f);
|
||||
volume_infos.temperature_mul = 1.0f;
|
||||
volume_infos.temperature_bias = 0.0f;
|
||||
@@ -147,9 +147,9 @@ PassType *volume_object_grids_init(PassType &ps,
|
||||
/* Bind volume grid textures. */
|
||||
int grid_id = 0;
|
||||
for (const GPUMaterialAttribute *attr : attrs) {
|
||||
const bke::VolumeGridData *volume_grid = BKE_volume_grid_find(volume, attr->name);
|
||||
const bke::VolumeGridData *volume_grid = BKE_volume_grid_find(&volume, attr->name);
|
||||
const DRWVolumeGrid *drw_grid = (volume_grid) ?
|
||||
DRW_volume_batch_cache_get_grid(volume, volume_grid) :
|
||||
DRW_volume_batch_cache_get_grid(&volume, volume_grid) :
|
||||
nullptr;
|
||||
/* Handle 3 cases here:
|
||||
* - Grid exists and texture was loaded -> use texture.
|
||||
@@ -212,7 +212,7 @@ PassType *drw_volume_object_mesh_init(PassType &ps,
|
||||
sub = &ps.sub("Volume Modifier SubPass");
|
||||
|
||||
float3 location, scale;
|
||||
BKE_mesh_texspace_get(static_cast<Mesh *>(ob->data), location, scale);
|
||||
BKE_mesh_texspace_get(&DRW_object_get_data_for_drawing<Mesh>(*ob), location, scale);
|
||||
float3 orco_mul = math::safe_rcp(scale * 2.0);
|
||||
float3 orco_add = (location - scale) * -orco_mul;
|
||||
/* Replace OrcoTexCoFactors with a matrix multiplication. */
|
||||
|
||||
Reference in New Issue
Block a user