Cleanup: Overlay-Next: Move ShapeCache access to Resources
This commit is contained in:
@@ -1094,25 +1094,25 @@ static void drw_shgroup_bone_custom_empty(const Armatures::DrawContext *ctx,
|
||||
gpu::Batch *geom = nullptr;
|
||||
switch (custom->empty_drawtype) {
|
||||
case OB_PLAINAXES:
|
||||
geom = ctx->shapes->plain_axes.get();
|
||||
geom = ctx->res->shapes.plain_axes.get();
|
||||
break;
|
||||
case OB_SINGLE_ARROW:
|
||||
geom = ctx->shapes->single_arrow.get();
|
||||
geom = ctx->res->shapes.single_arrow.get();
|
||||
break;
|
||||
case OB_CUBE:
|
||||
geom = ctx->shapes->cube.get();
|
||||
geom = ctx->res->shapes.cube.get();
|
||||
break;
|
||||
case OB_CIRCLE:
|
||||
geom = ctx->shapes->circle.get();
|
||||
geom = ctx->res->shapes.circle.get();
|
||||
break;
|
||||
case OB_EMPTY_SPHERE:
|
||||
geom = ctx->shapes->empty_sphere.get();
|
||||
geom = ctx->res->shapes.empty_sphere.get();
|
||||
break;
|
||||
case OB_EMPTY_CONE:
|
||||
geom = ctx->shapes->empty_cone.get();
|
||||
geom = ctx->res->shapes.empty_cone.get();
|
||||
break;
|
||||
case OB_ARROWS:
|
||||
geom = ctx->shapes->arrows.get();
|
||||
geom = ctx->res->shapes.arrows.get();
|
||||
break;
|
||||
case OB_EMPTY_IMAGE:
|
||||
/* Not supported. */
|
||||
|
||||
@@ -130,11 +130,8 @@ class Armatures : Overlay {
|
||||
BoneBuffers opaque_ = {selection_type_};
|
||||
BoneBuffers transparent_ = {selection_type_};
|
||||
|
||||
const ShapeCache &shapes_;
|
||||
|
||||
public:
|
||||
Armatures(const SelectionType selection_type, const ShapeCache &shapes)
|
||||
: selection_type_(selection_type), shapes_(shapes){};
|
||||
Armatures(const SelectionType selection_type) : selection_type_(selection_type){};
|
||||
|
||||
void begin_sync(Resources &res, const State &state) final
|
||||
{
|
||||
@@ -447,7 +444,6 @@ class Armatures : Overlay {
|
||||
|
||||
Armatures::BoneBuffers *bone_buf = nullptr;
|
||||
Resources *res = nullptr;
|
||||
const ShapeCache *shapes = nullptr;
|
||||
|
||||
/* TODO: Legacy structures to be removed after overlay next is shipped. */
|
||||
DRWCallBuffer *outline = nullptr;
|
||||
@@ -503,7 +499,6 @@ class Armatures : Overlay {
|
||||
ctx.ob = ob_ref.object;
|
||||
ctx.ob_ref = &ob_ref;
|
||||
ctx.res = &res;
|
||||
ctx.shapes = &shapes_;
|
||||
ctx.draw_mode = draw_mode;
|
||||
ctx.drawtype = eArmature_Drawtype(arm->drawtype);
|
||||
|
||||
@@ -555,38 +550,38 @@ class Armatures : Overlay {
|
||||
draw_armature_pose(&ctx);
|
||||
}
|
||||
|
||||
void end_sync(Resources & /*res*/, const ShapeCache &shapes, const State & /*state*/) final
|
||||
void end_sync(Resources &res, const State & /*state*/) final
|
||||
{
|
||||
if (!enabled_) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto end_sync = [&](BoneBuffers &bb) {
|
||||
bb.sphere_fill_buf.end_sync(*bb.sphere_fill, shapes.bone_sphere.get());
|
||||
bb.sphere_outline_buf.end_sync(*bb.sphere_outline, shapes.bone_sphere_wire.get());
|
||||
bb.sphere_fill_buf.end_sync(*bb.sphere_fill, res.shapes.bone_sphere.get());
|
||||
bb.sphere_outline_buf.end_sync(*bb.sphere_outline, res.shapes.bone_sphere_wire.get());
|
||||
|
||||
bb.octahedral_fill_buf.end_sync(*bb.shape_fill, shapes.bone_octahedron.get());
|
||||
bb.octahedral_fill_buf.end_sync(*bb.shape_fill, res.shapes.bone_octahedron.get());
|
||||
bb.octahedral_outline_buf.end_sync(
|
||||
*bb.shape_outline, shapes.bone_octahedron_wire.get(), GPU_PRIM_LINES, 1);
|
||||
*bb.shape_outline, res.shapes.bone_octahedron_wire.get(), GPU_PRIM_LINES, 1);
|
||||
|
||||
bb.bbones_fill_buf.end_sync(*bb.shape_fill, shapes.bone_box.get());
|
||||
bb.bbones_fill_buf.end_sync(*bb.shape_fill, res.shapes.bone_box.get());
|
||||
bb.bbones_outline_buf.end_sync(
|
||||
*bb.shape_outline, shapes.bone_box_wire.get(), GPU_PRIM_LINES, 1);
|
||||
*bb.shape_outline, res.shapes.bone_box_wire.get(), GPU_PRIM_LINES, 1);
|
||||
|
||||
bb.envelope_fill_buf.end_sync(*bb.envelope_fill, shapes.bone_envelope.get());
|
||||
bb.envelope_outline_buf.end_sync(*bb.envelope_outline, shapes.bone_envelope_wire.get());
|
||||
bb.envelope_distance_buf.end_sync(*bb.envelope_distance, shapes.bone_envelope.get());
|
||||
bb.envelope_fill_buf.end_sync(*bb.envelope_fill, res.shapes.bone_envelope.get());
|
||||
bb.envelope_outline_buf.end_sync(*bb.envelope_outline, res.shapes.bone_envelope_wire.get());
|
||||
bb.envelope_distance_buf.end_sync(*bb.envelope_distance, res.shapes.bone_envelope.get());
|
||||
|
||||
bb.stick_buf.end_sync(*bb.stick, shapes.bone_stick.get());
|
||||
bb.stick_buf.end_sync(*bb.stick, res.shapes.bone_stick.get());
|
||||
|
||||
bb.wire_buf.end_sync(*bb.wire);
|
||||
|
||||
bb.arrows_buf.end_sync(*bb.arrows, shapes.arrows.get());
|
||||
bb.arrows_buf.end_sync(*bb.arrows, res.shapes.arrows.get());
|
||||
|
||||
bb.degrees_of_freedom_fill_buf.end_sync(*bb.degrees_of_freedom_fill,
|
||||
shapes.bone_degrees_of_freedom.get());
|
||||
res.shapes.bone_degrees_of_freedom.get());
|
||||
bb.degrees_of_freedom_wire_buf.end_sync(*bb.degrees_of_freedom_wire,
|
||||
shapes.bone_degrees_of_freedom_wire.get());
|
||||
res.shapes.bone_degrees_of_freedom_wire.get());
|
||||
|
||||
bb.relations_buf.end_sync(*bb.relations);
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ class Axes : Overlay {
|
||||
axes_buf.append(data, res.select_id(ob_ref));
|
||||
}
|
||||
|
||||
void end_sync(Resources &res, const ShapeCache &shapes, const State &state) final
|
||||
void end_sync(Resources &res, const State &state) final
|
||||
{
|
||||
if (!enabled_) {
|
||||
return;
|
||||
@@ -71,7 +71,7 @@ class Axes : Overlay {
|
||||
ps_.shader_set(res.shaders.extra_shape.get());
|
||||
ps_.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
|
||||
res.select_bind(ps_);
|
||||
axes_buf.end_sync(ps_, shapes.arrows.get());
|
||||
axes_buf.end_sync(ps_, res.shapes.arrows.get());
|
||||
}
|
||||
|
||||
void draw_line(Framebuffer &framebuffer, Manager &manager, View &view) final
|
||||
|
||||
@@ -80,9 +80,7 @@ struct Overlay {
|
||||
* Finalize passes or buffers used for object sync.
|
||||
* Runs once at the start of the sync cycle.
|
||||
*/
|
||||
virtual void end_sync(Resources & /*res*/,
|
||||
const ShapeCache & /*shapes*/,
|
||||
const State & /*state*/){};
|
||||
virtual void end_sync(Resources & /*res*/, const State & /*state*/){};
|
||||
|
||||
/**
|
||||
* Warms #PassMain and #PassSortable to avoid overhead of pipeline switching.
|
||||
|
||||
@@ -196,7 +196,7 @@ class Bounds : Overlay {
|
||||
}
|
||||
}
|
||||
|
||||
void end_sync(Resources &res, const ShapeCache &shapes, const State &state) final
|
||||
void end_sync(Resources &res, const State &state) final
|
||||
{
|
||||
ps_.init();
|
||||
ps_.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL,
|
||||
@@ -205,12 +205,12 @@ class Bounds : Overlay {
|
||||
ps_.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
|
||||
res.select_bind(ps_);
|
||||
|
||||
call_buffers_.box.end_sync(ps_, shapes.cube.get());
|
||||
call_buffers_.sphere.end_sync(ps_, shapes.empty_sphere.get());
|
||||
call_buffers_.cylinder.end_sync(ps_, shapes.cylinder.get());
|
||||
call_buffers_.cone.end_sync(ps_, shapes.empty_cone.get());
|
||||
call_buffers_.capsule_body.end_sync(ps_, shapes.capsule_body.get());
|
||||
call_buffers_.capsule_cap.end_sync(ps_, shapes.capsule_cap.get());
|
||||
call_buffers_.box.end_sync(ps_, res.shapes.cube.get());
|
||||
call_buffers_.sphere.end_sync(ps_, res.shapes.empty_sphere.get());
|
||||
call_buffers_.cylinder.end_sync(ps_, res.shapes.cylinder.get());
|
||||
call_buffers_.cone.end_sync(ps_, res.shapes.empty_cone.get());
|
||||
call_buffers_.capsule_body.end_sync(ps_, res.shapes.capsule_body.get());
|
||||
call_buffers_.capsule_cap.end_sync(ps_, res.shapes.capsule_cap.get());
|
||||
}
|
||||
|
||||
void draw_line(Framebuffer &framebuffer, Manager &manager, View &view) final
|
||||
|
||||
@@ -141,8 +141,10 @@ class Cameras : Overlay {
|
||||
}
|
||||
}
|
||||
|
||||
void object_sync_ex(
|
||||
const ObjectRef &ob_ref, ShapeCache &shapes, Manager &manager, Resources &res, State &state)
|
||||
void object_sync(Manager &manager,
|
||||
const ObjectRef &ob_ref,
|
||||
Resources &res,
|
||||
const State &state) final
|
||||
{
|
||||
if (!enabled_) {
|
||||
return;
|
||||
@@ -154,10 +156,10 @@ class Cameras : Overlay {
|
||||
|
||||
object_sync_motion_paths(ob_ref, res, state);
|
||||
|
||||
object_sync_images(ob_ref, select_id, shapes, manager, state, res);
|
||||
object_sync_images(ob_ref, select_id, manager, state, res);
|
||||
}
|
||||
|
||||
void end_sync(Resources &res, const ShapeCache &shapes, const State &state) final
|
||||
void end_sync(Resources &res, const State &state) final
|
||||
{
|
||||
if (!extras_enabled_ && !motion_tracking_enabled_) {
|
||||
return;
|
||||
@@ -173,7 +175,7 @@ class Cameras : Overlay {
|
||||
DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_CULL_BACK,
|
||||
state.clipping_plane_count);
|
||||
sub_pass.shader_set(res.shaders.extra_shape.get());
|
||||
call_buffers_.volume_buf.end_sync(sub_pass, shapes.camera_volume.get());
|
||||
call_buffers_.volume_buf.end_sync(sub_pass, res.shapes.camera_volume.get());
|
||||
}
|
||||
{
|
||||
PassSimple::Sub &sub_pass = ps_.sub("volume_wire");
|
||||
@@ -181,7 +183,7 @@ class Cameras : Overlay {
|
||||
DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_CULL_BACK,
|
||||
state.clipping_plane_count);
|
||||
sub_pass.shader_set(res.shaders.extra_shape.get());
|
||||
call_buffers_.volume_wire_buf.end_sync(sub_pass, shapes.camera_volume_wire.get());
|
||||
call_buffers_.volume_wire_buf.end_sync(sub_pass, res.shapes.camera_volume_wire.get());
|
||||
}
|
||||
|
||||
{
|
||||
@@ -190,11 +192,11 @@ class Cameras : Overlay {
|
||||
DRW_STATE_DEPTH_LESS_EQUAL,
|
||||
state.clipping_plane_count);
|
||||
sub_pass.shader_set(res.shaders.extra_shape.get());
|
||||
call_buffers_.distances_buf.end_sync(sub_pass, shapes.camera_distances.get());
|
||||
call_buffers_.frame_buf.end_sync(sub_pass, shapes.camera_frame.get());
|
||||
call_buffers_.tria_buf.end_sync(sub_pass, shapes.camera_tria.get());
|
||||
call_buffers_.tria_wire_buf.end_sync(sub_pass, shapes.camera_tria_wire.get());
|
||||
call_buffers_.sphere_solid_buf.end_sync(sub_pass, shapes.sphere_low_detail.get());
|
||||
call_buffers_.distances_buf.end_sync(sub_pass, res.shapes.camera_distances.get());
|
||||
call_buffers_.frame_buf.end_sync(sub_pass, res.shapes.camera_frame.get());
|
||||
call_buffers_.tria_buf.end_sync(sub_pass, res.shapes.camera_tria.get());
|
||||
call_buffers_.tria_wire_buf.end_sync(sub_pass, res.shapes.camera_tria_wire.get());
|
||||
call_buffers_.sphere_solid_buf.end_sync(sub_pass, res.shapes.sphere_low_detail.get());
|
||||
}
|
||||
|
||||
{
|
||||
@@ -208,7 +210,7 @@ class Cameras : Overlay {
|
||||
}
|
||||
|
||||
PassSimple::Sub &sub_pass = ps_.sub("empties");
|
||||
Empties::end_sync(res, shapes, state, sub_pass, call_buffers_.empties);
|
||||
Empties::end_sync(res, state, sub_pass, call_buffers_.empties);
|
||||
}
|
||||
|
||||
void pre_draw(Manager &manager, View &view) final
|
||||
@@ -549,7 +551,6 @@ class Cameras : Overlay {
|
||||
|
||||
void object_sync_images(const ObjectRef &ob_ref,
|
||||
select::ID select_id,
|
||||
ShapeCache &shapes,
|
||||
Manager &manager,
|
||||
const State &state,
|
||||
Resources &res)
|
||||
@@ -606,7 +607,7 @@ class Cameras : Overlay {
|
||||
pass.push_constant("depthSet", true);
|
||||
pass.push_constant("ucolor", color_premult_alpha);
|
||||
ResourceHandle res_handle = manager.resource_handle(mat);
|
||||
pass.draw(shapes.quad_solid.get(), res_handle, select_id.get());
|
||||
pass.draw(res.shapes.quad_solid.get(), res_handle, select_id.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ class EditText : Overlay {
|
||||
add_boxes(res, cu, ob_ref.object->object_to_world());
|
||||
}
|
||||
|
||||
void end_sync(Resources &res, const ShapeCache &shapes, const State &state) final
|
||||
void end_sync(Resources &res, const State &state) final
|
||||
{
|
||||
ps_.init();
|
||||
ps_.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
|
||||
@@ -78,7 +78,7 @@ class EditText : Overlay {
|
||||
auto &buf = text_selection_buf;
|
||||
buf.push_update();
|
||||
sub.bind_ssbo("matrix_buf", &buf);
|
||||
sub.draw(shapes.quad_solid.get(), buf.size());
|
||||
sub.draw(res.shapes.quad_solid.get(), buf.size());
|
||||
}
|
||||
|
||||
/* Highlight text within selection boxes. */
|
||||
@@ -95,7 +95,7 @@ class EditText : Overlay {
|
||||
auto &buf = text_selection_buf;
|
||||
buf.push_update();
|
||||
sub.bind_ssbo("matrix_buf", &buf);
|
||||
sub.draw(shapes.quad_solid.get(), buf.size());
|
||||
sub.draw(res.shapes.quad_solid.get(), buf.size());
|
||||
}
|
||||
|
||||
/* Cursor (text caret). */
|
||||
@@ -111,7 +111,7 @@ class EditText : Overlay {
|
||||
auto &buf = text_cursor_buf;
|
||||
buf.push_update();
|
||||
sub.bind_ssbo("matrix_buf", &buf);
|
||||
sub.draw(shapes.quad_solid.get(), buf.size());
|
||||
sub.draw(res.shapes.quad_solid.get(), buf.size());
|
||||
}
|
||||
|
||||
/* Text boxes. */
|
||||
|
||||
@@ -108,12 +108,10 @@ class Empties : Overlay {
|
||||
call_buffers.image_buf.clear();
|
||||
}
|
||||
|
||||
/* TODO(fclem): Remove dependency on shapes. Pass it to the constructor. */
|
||||
void object_sync_ex(const ObjectRef &ob_ref,
|
||||
ShapeCache &shapes,
|
||||
Manager &manager,
|
||||
Resources &res,
|
||||
const State &state)
|
||||
void object_sync(Manager &manager,
|
||||
const ObjectRef &ob_ref,
|
||||
Resources &res,
|
||||
const State &state) final
|
||||
{
|
||||
if (!enabled_) {
|
||||
return;
|
||||
@@ -122,7 +120,7 @@ class Empties : Overlay {
|
||||
const float4 color = res.object_wire_color(ob_ref, state);
|
||||
const select::ID select_id = res.select_id(ob_ref);
|
||||
if (ob_ref.object->empty_drawtype == OB_EMPTY_IMAGE) {
|
||||
image_sync(ob_ref, select_id, shapes, manager, res, state, call_buffers_.image_buf);
|
||||
image_sync(ob_ref, select_id, manager, res, state, call_buffers_.image_buf);
|
||||
return;
|
||||
}
|
||||
object_sync(select_id,
|
||||
@@ -167,7 +165,7 @@ class Empties : Overlay {
|
||||
}
|
||||
}
|
||||
|
||||
void end_sync(Resources &res, const ShapeCache &shapes, const State &state) final
|
||||
void end_sync(Resources &res, const State &state) final
|
||||
{
|
||||
if (!enabled_) {
|
||||
return;
|
||||
@@ -175,11 +173,10 @@ class Empties : Overlay {
|
||||
|
||||
ps_.init();
|
||||
res.select_bind(ps_);
|
||||
end_sync(res, shapes, state, ps_, call_buffers_);
|
||||
end_sync(res, state, ps_, call_buffers_);
|
||||
}
|
||||
|
||||
static void end_sync(Resources &res,
|
||||
const ShapeCache &shapes,
|
||||
const State &state,
|
||||
PassSimple::Sub &ps,
|
||||
CallBuffers &call_buffers)
|
||||
@@ -189,14 +186,14 @@ class Empties : Overlay {
|
||||
ps.shader_set(res.shaders.extra_shape.get());
|
||||
ps.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
|
||||
|
||||
call_buffers.plain_axes_buf.end_sync(ps, shapes.plain_axes.get());
|
||||
call_buffers.single_arrow_buf.end_sync(ps, shapes.single_arrow.get());
|
||||
call_buffers.cube_buf.end_sync(ps, shapes.cube.get());
|
||||
call_buffers.circle_buf.end_sync(ps, shapes.circle.get());
|
||||
call_buffers.sphere_buf.end_sync(ps, shapes.empty_sphere.get());
|
||||
call_buffers.cone_buf.end_sync(ps, shapes.empty_cone.get());
|
||||
call_buffers.arrows_buf.end_sync(ps, shapes.arrows.get());
|
||||
call_buffers.image_buf.end_sync(ps, shapes.quad_wire.get());
|
||||
call_buffers.plain_axes_buf.end_sync(ps, res.shapes.plain_axes.get());
|
||||
call_buffers.single_arrow_buf.end_sync(ps, res.shapes.single_arrow.get());
|
||||
call_buffers.cube_buf.end_sync(ps, res.shapes.cube.get());
|
||||
call_buffers.circle_buf.end_sync(ps, res.shapes.circle.get());
|
||||
call_buffers.sphere_buf.end_sync(ps, res.shapes.empty_sphere.get());
|
||||
call_buffers.cone_buf.end_sync(ps, res.shapes.empty_cone.get());
|
||||
call_buffers.arrows_buf.end_sync(ps, res.shapes.arrows.get());
|
||||
call_buffers.image_buf.end_sync(ps, res.shapes.quad_wire.get());
|
||||
}
|
||||
|
||||
void pre_draw(Manager &manager, View &view) final
|
||||
@@ -260,7 +257,6 @@ class Empties : Overlay {
|
||||
private:
|
||||
void image_sync(const ObjectRef &ob_ref,
|
||||
select::ID select_id,
|
||||
ShapeCache &shapes,
|
||||
Manager &manager,
|
||||
Resources &res,
|
||||
const State &state,
|
||||
@@ -325,7 +321,7 @@ class Empties : Overlay {
|
||||
pass.push_constant("depthSet", depth_mode != OB_EMPTY_IMAGE_DEPTH_DEFAULT);
|
||||
pass.push_constant("ucolor", float4(ob->color));
|
||||
ResourceHandle res_handle = manager.resource_handle(mat);
|
||||
pass.draw(shapes.quad_solid.get(), res_handle, select_id.get());
|
||||
pass.draw(res.shapes.quad_solid.get(), res_handle, select_id.get());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -233,12 +233,12 @@ class Fluids : Overlay {
|
||||
}
|
||||
}
|
||||
|
||||
void end_sync(Resources &res, const ShapeCache &shapes, const State & /*state*/) final
|
||||
void end_sync(Resources &res, const State & /*state*/) final
|
||||
{
|
||||
fluid_ps_.shader_set(res.shaders.extra_shape.get());
|
||||
fluid_ps_.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
|
||||
|
||||
cube_buf_.end_sync(fluid_ps_, shapes.cube.get());
|
||||
cube_buf_.end_sync(fluid_ps_, res.shapes.cube.get());
|
||||
}
|
||||
|
||||
void draw_line(Framebuffer &framebuffer, Manager &manager, View &view) final
|
||||
|
||||
@@ -151,7 +151,7 @@ class ForceFields : Overlay {
|
||||
}
|
||||
}
|
||||
|
||||
void end_sync(Resources &res, const ShapeCache &shapes, const State &state) final
|
||||
void end_sync(Resources &res, const State &state) final
|
||||
{
|
||||
ps_.init();
|
||||
res.select_bind(ps_);
|
||||
@@ -160,13 +160,13 @@ class ForceFields : Overlay {
|
||||
ps_.shader_set(res.shaders.extra_shape.get());
|
||||
ps_.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
|
||||
|
||||
call_buffers_.field_force_buf.end_sync(ps_, shapes.field_force.get());
|
||||
call_buffers_.field_wind_buf.end_sync(ps_, shapes.field_wind.get());
|
||||
call_buffers_.field_vortex_buf.end_sync(ps_, shapes.field_vortex.get());
|
||||
call_buffers_.field_curve_buf.end_sync(ps_, shapes.field_curve.get());
|
||||
call_buffers_.field_sphere_limit_buf.end_sync(ps_, shapes.field_sphere_limit.get());
|
||||
call_buffers_.field_tube_limit_buf.end_sync(ps_, shapes.field_tube_limit.get());
|
||||
call_buffers_.field_cone_limit_buf.end_sync(ps_, shapes.field_cone_limit.get());
|
||||
call_buffers_.field_force_buf.end_sync(ps_, res.shapes.field_force.get());
|
||||
call_buffers_.field_wind_buf.end_sync(ps_, res.shapes.field_wind.get());
|
||||
call_buffers_.field_vortex_buf.end_sync(ps_, res.shapes.field_vortex.get());
|
||||
call_buffers_.field_curve_buf.end_sync(ps_, res.shapes.field_curve.get());
|
||||
call_buffers_.field_sphere_limit_buf.end_sync(ps_, res.shapes.field_sphere_limit.get());
|
||||
call_buffers_.field_tube_limit_buf.end_sync(ps_, res.shapes.field_tube_limit.get());
|
||||
call_buffers_.field_cone_limit_buf.end_sync(ps_, res.shapes.field_cone_limit.get());
|
||||
}
|
||||
|
||||
void draw_line(Framebuffer &framebuffer, Manager &manager, View &view) final
|
||||
|
||||
@@ -45,11 +45,7 @@ class Grid : Overlay {
|
||||
int zneg_flag_ = int(0);
|
||||
int zpos_flag_ = int(0);
|
||||
|
||||
const ShapeCache &shapes_;
|
||||
|
||||
public:
|
||||
Grid(const ShapeCache &shapes) : shapes_(shapes){};
|
||||
|
||||
void begin_sync(Resources &res, const State &state) final
|
||||
{
|
||||
is_space_image_ = state.is_space_image();
|
||||
@@ -75,7 +71,7 @@ class Grid : Overlay {
|
||||
sub.push_constant("ucolor", color_back);
|
||||
sub.push_constant("tile_scale", float3(data_.size));
|
||||
sub.bind_texture("depthBuffer", depth_tx);
|
||||
sub.draw(shapes_.quad_solid.get());
|
||||
sub.draw(res.shapes.quad_solid.get());
|
||||
}
|
||||
{
|
||||
auto &sub = grid_ps_.sub("grid");
|
||||
@@ -86,17 +82,17 @@ class Grid : Overlay {
|
||||
if (zneg_flag_ & SHOW_AXIS_Z) {
|
||||
sub.push_constant("grid_flag", &zneg_flag_);
|
||||
sub.push_constant("plane_axes", &zplane_axes_);
|
||||
sub.draw(shapes_.grid.get());
|
||||
sub.draw(res.shapes.grid.get());
|
||||
}
|
||||
if (grid_flag_) {
|
||||
sub.push_constant("grid_flag", &grid_flag_);
|
||||
sub.push_constant("plane_axes", &grid_axes_);
|
||||
sub.draw(shapes_.grid.get());
|
||||
sub.draw(res.shapes.grid.get());
|
||||
}
|
||||
if (zpos_flag_ & SHOW_AXIS_Z) {
|
||||
sub.push_constant("grid_flag", &zpos_flag_);
|
||||
sub.push_constant("plane_axes", &zplane_axes_);
|
||||
sub.draw(shapes_.grid.get());
|
||||
sub.draw(res.shapes.grid.get());
|
||||
}
|
||||
}
|
||||
if (state.is_space_image()) {
|
||||
@@ -116,7 +112,7 @@ class Grid : Overlay {
|
||||
}
|
||||
tile_pos_buf_.push_update();
|
||||
sub.bind_ssbo("tile_pos_buf", &tile_pos_buf_);
|
||||
sub.draw(shapes_.quad_wire.get(), tile_pos_buf_.size());
|
||||
sub.draw(res.shapes.quad_wire.get(), tile_pos_buf_.size());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -255,10 +255,10 @@ void Instance::object_sync(ObjectRef &ob_ref, Manager &manager)
|
||||
if (!state.hide_overlays) {
|
||||
switch (ob_ref.object->type) {
|
||||
case OB_EMPTY:
|
||||
layer.empties.object_sync_ex(ob_ref, shapes, manager, resources, state);
|
||||
layer.empties.object_sync(manager, ob_ref, resources, state);
|
||||
break;
|
||||
case OB_CAMERA:
|
||||
layer.cameras.object_sync_ex(ob_ref, shapes, manager, resources, state);
|
||||
layer.cameras.object_sync(manager, ob_ref, resources, state);
|
||||
break;
|
||||
case OB_ARMATURE:
|
||||
if (!in_edit_mode) {
|
||||
@@ -311,24 +311,24 @@ void Instance::object_sync(ObjectRef &ob_ref, Manager &manager)
|
||||
|
||||
void Instance::end_sync()
|
||||
{
|
||||
origins.end_sync(resources, shapes, state);
|
||||
origins.end_sync(resources, state);
|
||||
resources.end_sync();
|
||||
|
||||
auto end_sync_layer = [&](OverlayLayer &layer) {
|
||||
layer.armatures.end_sync(resources, shapes, state);
|
||||
layer.axes.end_sync(resources, shapes, state);
|
||||
layer.bounds.end_sync(resources, shapes, state);
|
||||
layer.cameras.end_sync(resources, shapes, state);
|
||||
layer.edit_text.end_sync(resources, shapes, state);
|
||||
layer.empties.end_sync(resources, shapes, state);
|
||||
layer.force_fields.end_sync(resources, shapes, state);
|
||||
layer.lights.end_sync(resources, shapes, state);
|
||||
layer.light_probes.end_sync(resources, shapes, state);
|
||||
layer.mesh_uvs.end_sync(resources, shapes, state);
|
||||
layer.metaballs.end_sync(resources, shapes, state);
|
||||
layer.relations.end_sync(resources, shapes, state);
|
||||
layer.fluids.end_sync(resources, shapes, state);
|
||||
layer.speakers.end_sync(resources, shapes, state);
|
||||
layer.armatures.end_sync(resources, state);
|
||||
layer.axes.end_sync(resources, state);
|
||||
layer.bounds.end_sync(resources, state);
|
||||
layer.cameras.end_sync(resources, state);
|
||||
layer.edit_text.end_sync(resources, state);
|
||||
layer.empties.end_sync(resources, state);
|
||||
layer.force_fields.end_sync(resources, state);
|
||||
layer.lights.end_sync(resources, state);
|
||||
layer.light_probes.end_sync(resources, state);
|
||||
layer.mesh_uvs.end_sync(resources, state);
|
||||
layer.metaballs.end_sync(resources, state);
|
||||
layer.relations.end_sync(resources, state);
|
||||
layer.fluids.end_sync(resources, state);
|
||||
layer.speakers.end_sync(resources, state);
|
||||
};
|
||||
end_sync_layer(regular);
|
||||
end_sync_layer(infront);
|
||||
|
||||
@@ -66,7 +66,8 @@ class Instance {
|
||||
|
||||
/** Global types. */
|
||||
Resources resources = {selection_type_,
|
||||
overlay::ShaderModule::module_get(selection_type_, clipping_enabled_)};
|
||||
overlay::ShaderModule::module_get(selection_type_, clipping_enabled_),
|
||||
shapes};
|
||||
State state;
|
||||
|
||||
/** Overlay types. */
|
||||
@@ -77,9 +78,7 @@ class Instance {
|
||||
|
||||
struct OverlayLayer {
|
||||
const SelectionType selection_type_;
|
||||
ShapeCache &shapes;
|
||||
|
||||
Armatures armatures = {selection_type_, shapes};
|
||||
Armatures armatures = {selection_type_};
|
||||
AttributeViewer attribute_viewer;
|
||||
AttributeTexts attribute_texts;
|
||||
Axes axes = {selection_type_};
|
||||
@@ -108,9 +107,9 @@ class Instance {
|
||||
Sculpts sculpts;
|
||||
Speakers speakers = {selection_type_};
|
||||
Wireframe wireframe;
|
||||
} regular{selection_type_, shapes}, infront{selection_type_, shapes};
|
||||
} regular{selection_type_}, infront{selection_type_};
|
||||
|
||||
Grid grid = {shapes};
|
||||
Grid grid;
|
||||
|
||||
AntiAliasing anti_aliasing;
|
||||
XrayFade xray_fade;
|
||||
|
||||
@@ -153,7 +153,7 @@ class Lights : Overlay {
|
||||
}
|
||||
}
|
||||
|
||||
void end_sync(Resources &res, const ShapeCache &shapes, const State &state) final
|
||||
void end_sync(Resources &res, const State &state) final
|
||||
{
|
||||
if (!enabled_) {
|
||||
return;
|
||||
@@ -171,7 +171,7 @@ class Lights : Overlay {
|
||||
DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_CULL_FRONT,
|
||||
state.clipping_plane_count);
|
||||
sub_pass.shader_set(res.shaders.light_spot_cone.get());
|
||||
call_buffers_.spot_cone_front_buf.end_sync(sub_pass, shapes.light_spot_volume.get());
|
||||
call_buffers_.spot_cone_front_buf.end_sync(sub_pass, res.shapes.light_spot_volume.get());
|
||||
}
|
||||
{
|
||||
PassSimple::Sub &sub_pass = ps_.sub("spot_cone_back");
|
||||
@@ -179,26 +179,26 @@ class Lights : Overlay {
|
||||
DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_CULL_BACK,
|
||||
state.clipping_plane_count);
|
||||
sub_pass.shader_set(res.shaders.light_spot_cone.get());
|
||||
call_buffers_.spot_cone_back_buf.end_sync(sub_pass, shapes.light_spot_volume.get());
|
||||
call_buffers_.spot_cone_back_buf.end_sync(sub_pass, res.shapes.light_spot_volume.get());
|
||||
}
|
||||
{
|
||||
PassSimple::Sub &sub_pass = ps_.sub("light_shapes");
|
||||
sub_pass.state_set(pass_state, state.clipping_plane_count);
|
||||
sub_pass.shader_set(res.shaders.extra_shape.get());
|
||||
call_buffers_.icon_inner_buf.end_sync(sub_pass, shapes.light_icon_outer_lines.get());
|
||||
call_buffers_.icon_outer_buf.end_sync(sub_pass, shapes.light_icon_inner_lines.get());
|
||||
call_buffers_.icon_sun_rays_buf.end_sync(sub_pass, shapes.light_icon_sun_rays.get());
|
||||
call_buffers_.point_buf.end_sync(sub_pass, shapes.light_point_lines.get());
|
||||
call_buffers_.sun_buf.end_sync(sub_pass, shapes.light_sun_lines.get());
|
||||
call_buffers_.spot_buf.end_sync(sub_pass, shapes.light_spot_lines.get());
|
||||
call_buffers_.area_disk_buf.end_sync(sub_pass, shapes.light_area_disk_lines.get());
|
||||
call_buffers_.area_square_buf.end_sync(sub_pass, shapes.light_area_square_lines.get());
|
||||
call_buffers_.icon_inner_buf.end_sync(sub_pass, res.shapes.light_icon_outer_lines.get());
|
||||
call_buffers_.icon_outer_buf.end_sync(sub_pass, res.shapes.light_icon_inner_lines.get());
|
||||
call_buffers_.icon_sun_rays_buf.end_sync(sub_pass, res.shapes.light_icon_sun_rays.get());
|
||||
call_buffers_.point_buf.end_sync(sub_pass, res.shapes.light_point_lines.get());
|
||||
call_buffers_.sun_buf.end_sync(sub_pass, res.shapes.light_sun_lines.get());
|
||||
call_buffers_.spot_buf.end_sync(sub_pass, res.shapes.light_spot_lines.get());
|
||||
call_buffers_.area_disk_buf.end_sync(sub_pass, res.shapes.light_area_disk_lines.get());
|
||||
call_buffers_.area_square_buf.end_sync(sub_pass, res.shapes.light_area_square_lines.get());
|
||||
}
|
||||
{
|
||||
PassSimple::Sub &sub_pass = ps_.sub("ground_line");
|
||||
sub_pass.state_set(pass_state | DRW_STATE_BLEND_ALPHA, state.clipping_plane_count);
|
||||
sub_pass.shader_set(res.shaders.extra_ground_line.get());
|
||||
call_buffers_.ground_line_buf.end_sync(sub_pass, shapes.ground_line.get());
|
||||
call_buffers_.ground_line_buf.end_sync(sub_pass, res.shapes.ground_line.get());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -185,7 +185,7 @@ class LightProbes : Overlay {
|
||||
}
|
||||
}
|
||||
|
||||
void end_sync(Resources &res, const ShapeCache &shapes, const State &state) final
|
||||
void end_sync(Resources &res, const State &state) final
|
||||
{
|
||||
if (!enabled_) {
|
||||
return;
|
||||
@@ -201,19 +201,19 @@ class LightProbes : Overlay {
|
||||
PassSimple::Sub &sub_pass = ps_.sub("empties");
|
||||
sub_pass.state_set(pass_state, state.clipping_plane_count);
|
||||
sub_pass.shader_set(res.shaders.extra_shape.get());
|
||||
call_buffers_.probe_cube_buf.end_sync(sub_pass, shapes.lightprobe_cube.get());
|
||||
call_buffers_.probe_planar_buf.end_sync(sub_pass, shapes.lightprobe_planar.get());
|
||||
call_buffers_.probe_grid_buf.end_sync(sub_pass, shapes.lightprobe_grid.get());
|
||||
call_buffers_.quad_solid_buf.end_sync(sub_pass, shapes.quad_solid.get());
|
||||
call_buffers_.cube_buf.end_sync(sub_pass, shapes.cube.get());
|
||||
call_buffers_.sphere_buf.end_sync(sub_pass, shapes.empty_sphere.get());
|
||||
call_buffers_.single_arrow_buf.end_sync(sub_pass, shapes.single_arrow.get());
|
||||
call_buffers_.probe_cube_buf.end_sync(sub_pass, res.shapes.lightprobe_cube.get());
|
||||
call_buffers_.probe_planar_buf.end_sync(sub_pass, res.shapes.lightprobe_planar.get());
|
||||
call_buffers_.probe_grid_buf.end_sync(sub_pass, res.shapes.lightprobe_grid.get());
|
||||
call_buffers_.quad_solid_buf.end_sync(sub_pass, res.shapes.quad_solid.get());
|
||||
call_buffers_.cube_buf.end_sync(sub_pass, res.shapes.cube.get());
|
||||
call_buffers_.sphere_buf.end_sync(sub_pass, res.shapes.empty_sphere.get());
|
||||
call_buffers_.single_arrow_buf.end_sync(sub_pass, res.shapes.single_arrow.get());
|
||||
}
|
||||
{
|
||||
PassSimple::Sub &sub_pass = ps_.sub("ground_line");
|
||||
sub_pass.state_set(pass_state | DRW_STATE_BLEND_ALPHA, state.clipping_plane_count);
|
||||
sub_pass.shader_set(res.shaders.extra_ground_line.get());
|
||||
call_buffers_.ground_line_buf.end_sync(sub_pass, shapes.ground_line.get());
|
||||
call_buffers_.ground_line_buf.end_sync(sub_pass, res.shapes.ground_line.get());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -788,7 +788,7 @@ class MeshUVs : Overlay {
|
||||
}
|
||||
}
|
||||
|
||||
void end_sync(Resources &res, const ShapeCache &shapes, const State &state) final
|
||||
void end_sync(Resources &res, const State &state) final
|
||||
{
|
||||
if (!enabled_) {
|
||||
return;
|
||||
@@ -833,7 +833,7 @@ class MeshUVs : Overlay {
|
||||
const float3 tile_location(tile_x, tile_y, 0.0f);
|
||||
pass.push_constant("tile_pos", tile_location);
|
||||
pass.push_constant("ucolor", is_active ? selected_color : theme_color);
|
||||
pass.draw(shapes.quad_wire.get());
|
||||
pass.draw(res.shapes.quad_wire.get());
|
||||
|
||||
/* Note: don't draw label twice for active tile. */
|
||||
if (show_tiled_image_label_ && !is_active) {
|
||||
@@ -882,7 +882,7 @@ class MeshUVs : Overlay {
|
||||
pass.push_constant("ucolor", float4(1.0f, 1.0f, 1.0f, brush->clone.alpha));
|
||||
pass.push_constant("brush_offset", float2(brush->clone.offset));
|
||||
pass.push_constant("brush_scale", float2(stencil_texture.size().xy()) / size_image);
|
||||
pass.draw(shapes.quad_solid.get());
|
||||
pass.draw(res.shapes.quad_solid.get());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -902,7 +902,7 @@ class MeshUVs : Overlay {
|
||||
pass.push_constant("opacity", opacity);
|
||||
pass.push_constant("brush_offset", float2(0.0f));
|
||||
pass.push_constant("brush_scale", float2(1.0f));
|
||||
pass.draw(shapes.quad_solid.get());
|
||||
pass.draw(res.shapes.quad_solid.get());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ class Metaballs : Overlay {
|
||||
}
|
||||
}
|
||||
|
||||
void end_sync(Resources &res, const ShapeCache &shapes, const State &state) final
|
||||
void end_sync(Resources &res, const State &state) final
|
||||
{
|
||||
ps_.init();
|
||||
ps_.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL,
|
||||
@@ -97,7 +97,7 @@ class Metaballs : Overlay {
|
||||
ps_.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
|
||||
res.select_bind(ps_);
|
||||
|
||||
circle_buf_.end_sync(ps_, shapes.metaball_wire_circle.get());
|
||||
circle_buf_.end_sync(ps_, res.shapes.metaball_wire_circle.get());
|
||||
}
|
||||
|
||||
void draw_line(Framebuffer &framebuffer, Manager &manager, View &view) final
|
||||
|
||||
@@ -72,7 +72,7 @@ class Origins : Overlay {
|
||||
}
|
||||
}
|
||||
|
||||
void end_sync(Resources &res, const ShapeCache & /*shapes*/, const State &state) final
|
||||
void end_sync(Resources &res, const State &state) final
|
||||
{
|
||||
if (!enabled_) {
|
||||
return;
|
||||
|
||||
@@ -515,8 +515,12 @@ struct Resources : public select::SelectMap {
|
||||
|
||||
Vector<MovieClip *> bg_movie_clips;
|
||||
|
||||
Resources(const SelectionType selection_type_, ShaderModule &shader_module)
|
||||
: select::SelectMap(selection_type_), shaders(shader_module){};
|
||||
const ShapeCache &shapes;
|
||||
|
||||
Resources(const SelectionType selection_type_,
|
||||
ShaderModule &shader_module,
|
||||
const ShapeCache &shapes_)
|
||||
: select::SelectMap(selection_type_), shaders(shader_module), shapes(shapes_){};
|
||||
|
||||
~Resources()
|
||||
{
|
||||
|
||||
@@ -175,7 +175,7 @@ class Relations : Overlay {
|
||||
}
|
||||
}
|
||||
|
||||
void end_sync(Resources &res, const ShapeCache & /*shapes*/, const State &state) final
|
||||
void end_sync(Resources &res, const State &state) final
|
||||
{
|
||||
if (!enabled_) {
|
||||
return;
|
||||
|
||||
@@ -56,7 +56,7 @@ class Speakers : Overlay {
|
||||
speaker_buf_.append({ob_ref.object->object_to_world(), color, 1.0f}, select_id);
|
||||
}
|
||||
|
||||
void end_sync(Resources &res, const ShapeCache &shapes, const State &state) final
|
||||
void end_sync(Resources &res, const State &state) final
|
||||
{
|
||||
if (!enabled_) {
|
||||
return;
|
||||
@@ -69,7 +69,7 @@ class Speakers : Overlay {
|
||||
ps_.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
|
||||
res.select_bind(ps_);
|
||||
|
||||
speaker_buf_.end_sync(ps_, shapes.speaker.get());
|
||||
speaker_buf_.end_sync(ps_, res.shapes.speaker.get());
|
||||
}
|
||||
|
||||
void draw_line(Framebuffer &framebuffer, Manager &manager, View &view) final
|
||||
|
||||
Reference in New Issue
Block a user