26 PassSimple edit_grease_pencil_ps_ = {
"GPencil Edit"};
32 bool show_points_ =
false;
33 bool show_lines_ =
false;
34 bool show_grid_ =
false;
35 bool show_weight_ =
false;
39 View view_edit_cage = {
"view_edit_cage"};
40 float view_dist = 0.0f;
42 bool enabled_ =
false;
53 view_dist =
state.view_dist_get(
view.winmat());
63 show_points_ = show_lines_ = show_weight_ =
false;
65 switch (
state.object_mode) {
74 show_points_ = show_edit_point;
75 show_lines_ = show_lines;
80 show_lines_ = show_lines;
93 edit_points_ =
nullptr;
94 edit_lines_ =
nullptr;
97 auto &pass = edit_grease_pencil_ps_;
101 state.clipping_plane_count);
104 auto &sub = pass.sub(
"Points");
108 sub.push_constant(
"useWeight", show_weight_);
109 sub.push_constant(
"useGreasePencil",
true);
110 sub.push_constant(
"doStrokeEndpoints", show_direction);
115 auto &sub = pass.sub(
"Lines");
119 sub.push_constant(
"useWeight", show_weight_);
120 sub.push_constant(
"useGreasePencil",
true);
133 auto &pass = grid_ps_;
136 state.clipping_plane_count);
138 const float4 col_grid(0.5f, 0.5f, 0.5f,
state.overlay.gpencil_grid_opacity);
141 pass.push_constant(
"color", col_grid);
158 gpu::Batch *geom = show_weight_ ?
200 const int grid_lines = 4;
201 const int line_count = grid_lines * 4 + 2;
204 grid_ps_.push_constant(
"xAxis", grid_mat.
x_axis());
205 grid_ps_.push_constant(
"yAxis", grid_mat.
y_axis());
206 grid_ps_.push_constant(
"origin", grid_mat.
location());
207 grid_ps_.push_constant(
"halfLineCount", line_count / 2);
231 manager.
submit(edit_grease_pencil_ps_, view_edit_cage);
268 depth_plane_get(ob,
view);
276 const float object_scale =
mat4_to_scale(ob->object_to_world().ptr());
285 pass.
push_constant(
"gpThicknessWorldScale", thickness_scale);
299 *ob, info.drawing, memory);
302 const IndexRange points = points_by_curve[stroke_i];
303 const int material_index = stroke_materials[stroke_i];
306 const bool hide_onion = info.onion_id != 0;
309 const int num_stroke_triangles = (points.
size() >= 3) ? (points.
size() - 2) : 0;
310 const int num_stroke_vertices = (points.
size() +
311 int(cyclic[stroke_i] && (points.
size() >= 3)));
313 if (hide_material || hide_onion) {
314 t_offset += num_stroke_triangles;
315 t_offset += num_stroke_vertices * 2;
322 const bool show_fill = (points.
size() >= 3) &&
326 int v_first = t_offset * 3;
327 int v_count = num_stroke_triangles * 3;
328 pass.
draw(geom, 1, v_count, v_first, res_handle, select_id.get());
331 t_offset += num_stroke_triangles;
334 int v_first = t_offset * 3;
335 int v_count = num_stroke_vertices * 2 * 3;
336 pass.
draw(geom, 1, v_count, v_first, res_handle, select_id.get());
338 t_offset += num_stroke_vertices * 2;
363 float4x4 bbox_to_world = ob->object_to_world() * bbox_to_object;
366 float3 view_vector = (
view.is_perspective) ?
view.location - bbox_center :
view.z_axis;
377 return float4(plane_direction, -
dot(plane_direction, bbox_center));
384 const ::GreasePencil &grease_pencil = *
static_cast<::
GreasePencil *
>(
object.data);
387 float4x4 mat =
object.object_to_world();
396 std::swap(mat[0], mat[2]);
399 std::swap(mat[1], mat[2]);
Low-level operations for curves.
Low-level operations for grease pencil.
struct MaterialGPencilStyle * BKE_gpencil_material_settings(struct Object *ob, short act)
General operations, lookup, etc. for blender objects.
std::optional< blender::Bounds< blender::float3 > > BKE_object_boundbox_get(const Object *ob)
float mat4_to_scale(const float mat[4][4])
@ GREASE_PENCIL_STROKE_ORDER_3D
@ GP_MATERIAL_STROKE_SHOW
@ OB_MODE_VERTEX_GREASE_PENCIL
@ OB_MODE_PAINT_GREASE_PENCIL
@ OB_MODE_SCULPT_GREASE_PENCIL
@ OB_MODE_WEIGHT_GREASE_PENCIL
@ GP_PROJECT_DEPTH_STROKE
@ V3D_GP_SHOW_STROKE_DIRECTION
void GPU_framebuffer_bind(GPUFrameBuffer *framebuffer)
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
btMatrix3x3 transpose() const
Return the transpose of the matrix.
SIMD_FORCE_INLINE btVector3 & normalize()
Normalize this vector x^2 + y^2 + z^2 = 1.
constexpr int64_t size() const
GAttributeReader lookup_or_default(StringRef attribute_id, AttrDomain domain, eCustomDataType data_type, const void *default_value=nullptr) const
float4x4 to_world_space(const Object &object) const
ResourceHandle unique_handle(const ObjectRef &ref)
void submit(PassSimple &pass, View &view)
void bind_texture(const char *name, GPUTexture *texture, GPUSamplerState state=sampler_auto)
void draw(gpu::Batch *batch, uint instance_len=-1, uint vertex_len=-1, uint vertex_first=-1, ResourceHandle handle={0}, uint custom_id=0)
void push_constant(const char *name, const float &data)
detail::PassBase< command::DrawCommandBuf > Sub
void object_sync(const ObjectRef &ob_ref, Resources &, State &state)
void sculpt_object_sync(Manager &manager, const ObjectRef &ob_ref, const State &state, Resources &res)
static void draw_grease_pencil(PassMain::Sub &pass, const ViewParameters &view, const Scene *scene, Object *ob, ResourceHandle res_handle, select::ID select_id=select::SelectMap::select_invalid_id())
void paint_object_sync(Manager &manager, const ObjectRef &ob_ref, const State &state, Resources &res)
void draw(Framebuffer &framebuffer, Manager &manager, View &view)
void edit_object_sync(Manager &manager, const ObjectRef &ob_ref, const State &state, Resources &)
void draw_color_only(Framebuffer &framebuffer, Manager &manager, View &view)
void begin_sync(Resources &res, const State &state, const View &view)
ShaderPtr curve_edit_line
ShaderPtr curve_edit_points
ShaderPtr grid_grease_pencil
void foreach_index(Fn &&fn) const
void DRW_view_viewmat_get(const DRWView *view, float mat[4][4], bool inverse)
@ DRW_STATE_DEPTH_LESS_EQUAL
blender::bke::AttrDomain ED_grease_pencil_edit_selection_domain_get(const ToolSettings *tool_settings)
constexpr float LEGACY_RADIUS_CONVERSION_FACTOR
static float4x4 winmat_polygon_offset(float4x4 winmat, float view_dist, float offset)
blender::gpu::Batch * DRW_cache_grease_pencil_get(const Scene *scene, Object *ob)
detail::Pass< command::DrawCommandBuf > PassSimple
gpu::VertBuf * DRW_cache_grease_pencil_position_buffer_get(const Scene *scene, Object *ob)
blender::gpu::Batch * DRW_cache_grease_pencil_edit_lines_get(const Scene *scene, Object *ob)
blender::gpu::Batch * DRW_cache_grease_pencil_weight_lines_get(const Scene *scene, Object *ob)
blender::gpu::Batch * DRW_cache_grease_pencil_edit_points_get(const Scene *scene, Object *ob)
blender::gpu::Batch * DRW_cache_grease_pencil_weight_points_get(const Scene *scene, Object *ob)
gpu::VertBuf * DRW_cache_grease_pencil_color_buffer_get(const Scene *scene, Object *ob)
Vector< DrawingInfo > retrieve_visible_drawings(const Scene &scene, const GreasePencil &grease_pencil, const bool do_onion_skinning)
IndexMask retrieve_visible_strokes(Object &object, const bke::greasepencil::Drawing &drawing, IndexMaskMemory &memory)
MatT from_loc_scale(const typename MatT::loc_type &location, const VecBase< typename MatT::base_type, ScaleDim > &scale)
CartesianBasis invert(const CartesianBasis &basis)
T midpoint(const T &a, const T &b)
VecBase< T, 3 > transform_direction(const MatBase< T, 3, 3 > &mat, const VecBase< T, 3 > &direction)
MatBase< float, 4, 4 > float4x4
VecBase< float, 4 > float4
MatBase< float, 3, 3 > float3x3
VecBase< float, 3 > float3
struct ToolSettings * toolsettings
const c_style_mat & ptr() const
ViewParameters(bool is_perspective, const float4x4 &viewinv)
TextureRef weight_ramp_tx
GPUUniformBuf * globals_buf
static const ID select_invalid_id()