Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/sculpt_intern.h
| Show All 21 Lines | |||||
| #include "BLI_gsqueue.h" | #include "BLI_gsqueue.h" | ||||
| #include "BLI_threads.h" | #include "BLI_threads.h" | ||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||
| extern "C" { | extern "C" { | ||||
| #endif | #endif | ||||
| struct AutomaskingCache; | struct AutomaskingCache; | ||||
| struct AutomaskingNodeData; | |||||
| struct Image; | struct Image; | ||||
| struct ImageUser; | struct ImageUser; | ||||
| struct KeyBlock; | struct KeyBlock; | ||||
| struct Object; | struct Object; | ||||
| struct SculptUndoNode; | struct SculptUndoNode; | ||||
| struct bContext; | struct bContext; | ||||
| struct PaintModeSettings; | struct PaintModeSettings; | ||||
| struct GPUShader; | |||||
| /* Updates */ | /* Updates */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Sculpt Types | /** \name Sculpt Types | ||||
| * \{ */ | * \{ */ | ||||
| typedef enum SculptUpdateType { | typedef enum SculptUpdateType { | ||||
| ▲ Show 20 Lines • Show All 261 Lines • ▼ Show 20 Lines | typedef struct SculptThreadedTaskData { | ||||
| /* Boundary brush */ | /* Boundary brush */ | ||||
| float boundary_deform_strength; | float boundary_deform_strength; | ||||
| float cloth_time_step; | float cloth_time_step; | ||||
| SculptClothSimulation *cloth_sim; | SculptClothSimulation *cloth_sim; | ||||
| float *cloth_sim_initial_location; | float *cloth_sim_initial_location; | ||||
| float cloth_sim_radius; | float cloth_sim_radius; | ||||
| float dirty_mask_min; | |||||
| float dirty_mask_max; | |||||
| bool dirty_mask_dirty_only; | |||||
| /* Mask By Color Tool */ | /* Mask By Color Tool */ | ||||
| float mask_by_color_threshold; | float mask_by_color_threshold; | ||||
| bool mask_by_color_invert; | bool mask_by_color_invert; | ||||
| bool mask_by_color_preserve_mask; | bool mask_by_color_preserve_mask; | ||||
| /* Index of the vertex that is going to be used as a reference for the colors. */ | /* Index of the vertex that is going to be used as a reference for the colors. */ | ||||
| PBVHVertRef mask_by_color_vertex; | PBVHVertRef mask_by_color_vertex; | ||||
| ▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | |||||
| } SculptTransformDisplacementMode; | } SculptTransformDisplacementMode; | ||||
| #define SCULPT_CLAY_STABILIZER_LEN 10 | #define SCULPT_CLAY_STABILIZER_LEN 10 | ||||
| typedef struct AutomaskingSettings { | typedef struct AutomaskingSettings { | ||||
| /* Flags from eAutomasking_flag. */ | /* Flags from eAutomasking_flag. */ | ||||
| int flags; | int flags; | ||||
| int initial_face_set; | int initial_face_set; | ||||
| float cavity_factor; | |||||
| int cavity_blur_steps; | |||||
| struct CurveMapping *cavity_curve; | |||||
| float start_normal_limit, start_normal_falloff; | |||||
| float view_normal_limit, view_normal_falloff; | |||||
| } AutomaskingSettings; | } AutomaskingSettings; | ||||
| typedef struct AutomaskingCache { | typedef struct AutomaskingCache { | ||||
| AutomaskingSettings settings; | AutomaskingSettings settings; | ||||
| bool can_reuse_mask; | |||||
| uchar current_stroke_id; | |||||
| } AutomaskingCache; | } AutomaskingCache; | ||||
| typedef struct FilterCache { | typedef struct FilterCache { | ||||
| bool enabled_axis[3]; | bool enabled_axis[3]; | ||||
| bool enabled_force_axis[3]; | bool enabled_force_axis[3]; | ||||
| int random_seed; | int random_seed; | ||||
| /* Used for alternating between filter operations in filters that need to apply different ones to | /* Used for alternating between filter operations in filters that need to apply different ones to | ||||
| ▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | typedef struct FilterCache { | ||||
| int *prev_face_set; | int *prev_face_set; | ||||
| int active_face_set; | int active_face_set; | ||||
| SculptTransformDisplacementMode transform_displacement_mode; | SculptTransformDisplacementMode transform_displacement_mode; | ||||
| /* Auto-masking. */ | /* Auto-masking. */ | ||||
| AutomaskingCache *automasking; | AutomaskingCache *automasking; | ||||
| float initial_normal[3]; | |||||
| float view_normal[3]; | |||||
| /* Pre-smoothed colors used by sharpening. Colors are HSL. */ | /* Pre-smoothed colors used by sharpening. Colors are HSL. */ | ||||
| float (*pre_smoothed_color)[4]; | float (*pre_smoothed_color)[4]; | ||||
| } FilterCache; | } FilterCache; | ||||
| /** | /** | ||||
| * This structure contains all the temporary data | * This structure contains all the temporary data | ||||
| * needed for individual brush strokes. | * needed for individual brush strokes. | ||||
| ▲ Show 20 Lines • Show All 156 Lines • ▼ Show 20 Lines | typedef struct StrokeCache { | ||||
| float multiplane_scrape_angle; | float multiplane_scrape_angle; | ||||
| float wet_mix_prev_color[4]; | float wet_mix_prev_color[4]; | ||||
| float density_seed; | float density_seed; | ||||
| rcti previous_r; /* previous redraw rectangle */ | rcti previous_r; /* previous redraw rectangle */ | ||||
| rcti current_r; /* current redraw rectangle */ | rcti current_r; /* current redraw rectangle */ | ||||
| int stroke_id; | |||||
| } StrokeCache; | } StrokeCache; | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Sculpt Expand | /** \name Sculpt Expand | ||||
| * \{ */ | * \{ */ | ||||
| typedef enum eSculptExpandFalloffType { | typedef enum eSculptExpandFalloffType { | ||||
| SCULPT_EXPAND_FALLOFF_GEODESIC, | SCULPT_EXPAND_FALLOFF_GEODESIC, | ||||
| ▲ Show 20 Lines • Show All 261 Lines • ▼ Show 20 Lines | |||||
| /** Get the normal for a given sculpt vertex; do not modify the result */ | /** Get the normal for a given sculpt vertex; do not modify the result */ | ||||
| void SCULPT_vertex_normal_get(SculptSession *ss, PBVHVertRef vertex, float no[3]); | void SCULPT_vertex_normal_get(SculptSession *ss, PBVHVertRef vertex, float no[3]); | ||||
| float SCULPT_vertex_mask_get(struct SculptSession *ss, PBVHVertRef vertex); | float SCULPT_vertex_mask_get(struct SculptSession *ss, PBVHVertRef vertex); | ||||
| void SCULPT_vertex_color_get(const SculptSession *ss, PBVHVertRef vertex, float r_color[4]); | void SCULPT_vertex_color_get(const SculptSession *ss, PBVHVertRef vertex, float r_color[4]); | ||||
| void SCULPT_vertex_color_set(SculptSession *ss, PBVHVertRef vertex, const float color[4]); | void SCULPT_vertex_color_set(SculptSession *ss, PBVHVertRef vertex, const float color[4]); | ||||
| bool SCULPT_vertex_is_occluded(SculptSession *ss, PBVHVertRef vertex, bool original); | |||||
| /** Returns true if a color attribute exists in the current sculpt session. */ | /** Returns true if a color attribute exists in the current sculpt session. */ | ||||
| bool SCULPT_has_colors(const SculptSession *ss); | bool SCULPT_has_colors(const SculptSession *ss); | ||||
| /** Returns true if the active color attribute is on loop (ATTR_DOMAIN_CORNER) domain. */ | /** Returns true if the active color attribute is on loop (ATTR_DOMAIN_CORNER) domain. */ | ||||
| bool SCULPT_has_loop_colors(const struct Object *ob); | bool SCULPT_has_loop_colors(const struct Object *ob); | ||||
| const float *SCULPT_vertex_persistent_co_get(SculptSession *ss, PBVHVertRef vertex); | const float *SCULPT_vertex_persistent_co_get(SculptSession *ss, PBVHVertRef vertex); | ||||
| void SCULPT_vertex_persistent_normal_get(SculptSession *ss, PBVHVertRef vertex, float no[3]); | void SCULPT_vertex_persistent_normal_get(SculptSession *ss, PBVHVertRef vertex, float no[3]); | ||||
| ▲ Show 20 Lines • Show All 265 Lines • ▼ Show 20 Lines | |||||
| float SCULPT_brush_strength_factor(struct SculptSession *ss, | float SCULPT_brush_strength_factor(struct SculptSession *ss, | ||||
| const struct Brush *br, | const struct Brush *br, | ||||
| const float point[3], | const float point[3], | ||||
| float len, | float len, | ||||
| const float vno[3], | const float vno[3], | ||||
| const float fno[3], | const float fno[3], | ||||
| float mask, | float mask, | ||||
| const PBVHVertRef vertex, | const PBVHVertRef vertex, | ||||
| int thread_id); | int thread_id, | ||||
| struct AutomaskingNodeData *automask_data); | |||||
| /** | /** | ||||
| * Tilts a normal by the x and y tilt values using the view axis. | * Tilts a normal by the x and y tilt values using the view axis. | ||||
| */ | */ | ||||
| void SCULPT_tilt_apply_to_normal(float r_normal[3], | void SCULPT_tilt_apply_to_normal(float r_normal[3], | ||||
| struct StrokeCache *cache, | struct StrokeCache *cache, | ||||
| float tilt_strength); | float tilt_strength); | ||||
| ▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | |||||
| enum eDynTopoWarnFlag SCULPT_dynamic_topology_check(Scene *scene, Object *ob); | enum eDynTopoWarnFlag SCULPT_dynamic_topology_check(Scene *scene, Object *ob); | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Auto-masking. | /** \name Auto-masking. | ||||
| * \{ */ | * \{ */ | ||||
| typedef struct AutomaskingNodeData { | |||||
| PBVHNode *node; | |||||
| SculptOrigVertData orig_data; | |||||
| bool have_orig_data; | |||||
| } AutomaskingNodeData; | |||||
| /** Call before PBVH vertex iteration. | |||||
| * \param automask_data: pointer to an uninitialized AutomaskingNodeData struct. | |||||
| */ | |||||
| void SCULPT_automasking_node_begin(struct Object *ob, | |||||
| const SculptSession *ss, | |||||
| struct AutomaskingCache *automasking, | |||||
| AutomaskingNodeData *automask_data, | |||||
| PBVHNode *node); | |||||
| /* Call before SCULPT_automasking_factor_get and SCULPT_brush_strength_factor. */ | |||||
| void SCULPT_automasking_node_update(SculptSession *ss, | |||||
| AutomaskingNodeData *automask_data, | |||||
| PBVHVertexIter *vd); | |||||
| float SCULPT_automasking_factor_get(struct AutomaskingCache *automasking, | float SCULPT_automasking_factor_get(struct AutomaskingCache *automasking, | ||||
| SculptSession *ss, | SculptSession *ss, | ||||
| PBVHVertRef vertex); | PBVHVertRef vertex, | ||||
| AutomaskingNodeData *automask_data); | |||||
| /* Returns the automasking cache depending on the active tool. Used for code that can run both for | /* Returns the automasking cache depending on the active tool. Used for code that can run both for | ||||
| * brushes and filter. */ | * brushes and filter. */ | ||||
| struct AutomaskingCache *SCULPT_automasking_active_cache_get(SculptSession *ss); | struct AutomaskingCache *SCULPT_automasking_active_cache_get(SculptSession *ss); | ||||
| struct AutomaskingCache *SCULPT_automasking_cache_init(Sculpt *sd, Brush *brush, Object *ob); | struct AutomaskingCache *SCULPT_automasking_cache_init(Sculpt *sd, Brush *brush, Object *ob); | ||||
| void SCULPT_automasking_cache_free(struct AutomaskingCache *automasking); | void SCULPT_automasking_cache_free(struct AutomaskingCache *automasking); | ||||
| bool SCULPT_is_automasking_mode_enabled(const Sculpt *sd, const Brush *br, eAutomasking_flag mode); | bool SCULPT_is_automasking_mode_enabled(const Sculpt *sd, const Brush *br, eAutomasking_flag mode); | ||||
| bool SCULPT_is_automasking_enabled(const Sculpt *sd, const SculptSession *ss, const Brush *br); | bool SCULPT_is_automasking_enabled(const Sculpt *sd, const SculptSession *ss, const Brush *br); | ||||
| float *SCULPT_boundary_automasking_init(Object *ob, | float *SCULPT_boundary_automasking_init(Object *ob, | ||||
| eBoundaryAutomaskMode mode, | eBoundaryAutomaskMode mode, | ||||
| int propagation_steps, | int propagation_steps, | ||||
| float *automask_factor); | float *automask_factor); | ||||
| bool SCULPT_automasking_needs_normal(const SculptSession *ss, | |||||
| const Sculpt *sculpt, | |||||
| const Brush *brush); | |||||
| bool SCULPT_automasking_needs_original(const struct Sculpt *sd, const struct Brush *brush); | |||||
| int SCULPT_automasking_settings_hash(Object *ob, AutomaskingCache *automasking); | |||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Geodesic distances. | /** \name Geodesic distances. | ||||
| * \{ */ | * \{ */ | ||||
| /** | /** | ||||
| * Returns an array indexed by vertex index containing the geodesic distance to the closest vertex | * Returns an array indexed by vertex index containing the geodesic distance to the closest vertex | ||||
| Show All 10 Lines | float *SCULPT_geodesic_from_vertex_and_symm(struct Sculpt *sd, | ||||
| float limit_radius); | float limit_radius); | ||||
| float *SCULPT_geodesic_from_vertex(Object *ob, PBVHVertRef vertex, float limit_radius); | float *SCULPT_geodesic_from_vertex(Object *ob, PBVHVertRef vertex, float limit_radius); | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Filter API | /** \name Filter API | ||||
| * \{ */ | * \{ */ | ||||
| void SCULPT_filter_cache_init(struct bContext *C, Object *ob, Sculpt *sd, int undo_type); | void SCULPT_filter_cache_init(struct bContext *C, | ||||
| Object *ob, | |||||
| Sculpt *sd, | |||||
| int undo_type, | |||||
| const int mval[2], | |||||
| float area_normal_radius); | |||||
| void SCULPT_filter_cache_free(SculptSession *ss); | void SCULPT_filter_cache_free(SculptSession *ss); | ||||
| void SCULPT_mesh_filter_properties(struct wmOperatorType *ot); | |||||
| void SCULPT_mask_filter_smooth_apply( | void SCULPT_mask_filter_smooth_apply( | ||||
| Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode, int smooth_iterations); | Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode, int smooth_iterations); | ||||
| /* Filter orientation utils. */ | /* Filter orientation utils. */ | ||||
| void SCULPT_filter_to_orientation_space(float r_v[3], struct FilterCache *filter_cache); | void SCULPT_filter_to_orientation_space(float r_v[3], struct FilterCache *filter_cache); | ||||
| void SCULPT_filter_to_object_space(float r_v[3], struct FilterCache *filter_cache); | void SCULPT_filter_to_object_space(float r_v[3], struct FilterCache *filter_cache); | ||||
| void SCULPT_filter_zero_disabled_axis_components(float r_v[3], struct FilterCache *filter_cache); | void SCULPT_filter_zero_disabled_axis_components(float r_v[3], struct FilterCache *filter_cache); | ||||
| ▲ Show 20 Lines • Show All 246 Lines • ▼ Show 20 Lines | |||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Interactive Mask Operators | /** \name Interactive Mask Operators | ||||
| * \{ */ | * \{ */ | ||||
| /* Mask filter and Dirty Mask. */ | /* Mask filter and Dirty Mask. */ | ||||
| void SCULPT_OT_mask_filter(struct wmOperatorType *ot); | void SCULPT_OT_mask_filter(struct wmOperatorType *ot); | ||||
| void SCULPT_OT_dirty_mask(struct wmOperatorType *ot); | |||||
| /* Mask and Face Sets Expand. */ | /* Mask and Face Sets Expand. */ | ||||
| void SCULPT_OT_mask_expand(struct wmOperatorType *ot); | void SCULPT_OT_mask_expand(struct wmOperatorType *ot); | ||||
| /* Mask Init. */ | /* Mask Init. */ | ||||
| void SCULPT_OT_mask_init(struct wmOperatorType *ot); | void SCULPT_OT_mask_init(struct wmOperatorType *ot); | ||||
| ▲ Show 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | |||||
| void SCULPT_do_draw_face_sets_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode); | void SCULPT_do_draw_face_sets_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode); | ||||
| /* Paint Brush. */ | /* Paint Brush. */ | ||||
| void SCULPT_do_paint_brush(struct PaintModeSettings *paint_mode_settings, | void SCULPT_do_paint_brush(struct PaintModeSettings *paint_mode_settings, | ||||
| Sculpt *sd, | Sculpt *sd, | ||||
| Object *ob, | Object *ob, | ||||
| PBVHNode **nodes, | PBVHNode **nodes, | ||||
| int totnode) ATTR_NONNULL(); | int totnode) ATTR_NONNULL(); | ||||
| void SCULPT_paint_batches_flush(struct PaintModeSettings *paint_mode_settings, | |||||
| struct Sculpt *sd, | |||||
| struct Object *ob); | |||||
| /** | /** | ||||
| * \brief Get the image canvas for painting on the given object. | * \brief Get the image canvas for painting on the given object. | ||||
| * | * | ||||
| * \return #true if an image is found. The #r_image and #r_image_user fields are filled with the | * \return #true if an image is found. The #r_image and #r_image_user fields are filled with | ||||
| * image and image user. Returns false when the image isn't found. In the later case the r_image | * the image and image user. Returns false when the image isn't found. In the later case the | ||||
| * and r_image_user are set to NULL. | * r_image and r_image_user are set to NULL. | ||||
| */ | */ | ||||
| bool SCULPT_paint_image_canvas_get(struct PaintModeSettings *paint_mode_settings, | bool SCULPT_paint_image_canvas_get(struct PaintModeSettings *paint_mode_settings, | ||||
| struct Object *ob, | struct Object *ob, | ||||
| struct Image **r_image, | struct Image **r_image, | ||||
| struct ImageUser **r_image_user) ATTR_NONNULL(); | struct ImageUser **r_image_user) ATTR_NONNULL(); | ||||
| void SCULPT_do_paint_brush_image(struct PaintModeSettings *paint_mode_settings, | void SCULPT_do_paint_brush_image(struct PaintModeSettings *paint_mode_settings, | ||||
| Sculpt *sd, | Sculpt *sd, | ||||
| Object *ob, | Object *ob, | ||||
| PBVHNode **nodes, | PBVHNode **nodes, | ||||
| int totnode) ATTR_NONNULL(); | int totnode) ATTR_NONNULL(); | ||||
| bool SCULPT_use_image_paint_brush(struct PaintModeSettings *settings, Object *ob) ATTR_NONNULL(); | bool SCULPT_use_image_paint_brush(struct PaintModeSettings *settings, Object *ob) ATTR_NONNULL(); | ||||
| void SCULPT_paint_image_batches_flush(struct PaintModeSettings *paint_mode_settings, | |||||
| struct Sculpt *sd, | |||||
| struct Object *ob); | |||||
| /* Smear Brush. */ | /* Smear Brush. */ | ||||
| void SCULPT_do_smear_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode); | void SCULPT_do_smear_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode); | ||||
| float SCULPT_clay_thumb_get_stabilized_pressure(struct StrokeCache *cache); | float SCULPT_clay_thumb_get_stabilized_pressure(struct StrokeCache *cache); | ||||
| void SCULPT_do_draw_brush(struct Sculpt *sd, | void SCULPT_do_draw_brush(struct Sculpt *sd, | ||||
| struct Object *ob, | struct Object *ob, | ||||
| ▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | void SCULPT_do_mask_brush(struct Sculpt *sd, | ||||
| int totnode); | int totnode); | ||||
| /** \} */ | /** \} */ | ||||
| void SCULPT_bmesh_topology_rake( | void SCULPT_bmesh_topology_rake( | ||||
| struct Sculpt *sd, struct Object *ob, struct PBVHNode **nodes, int totnode, float bstrength); | struct Sculpt *sd, struct Object *ob, struct PBVHNode **nodes, int totnode, float bstrength); | ||||
| /* end sculpt_brush_types.c */ | /* end sculpt_brush_types.c */ | ||||
| /* sculpt_shaders.cc */ | |||||
| struct GPUShader *SCULPT_shader_paint_image_get(void); | |||||
| struct GPUShader *SCULPT_shader_paint_image_merge_get(void); | |||||
| void SCULPT_shader_free(void); | |||||
| /* end sculpt_shadders.cc */ | |||||
| /* sculpt_ops.c */ | /* sculpt_ops.c */ | ||||
| void SCULPT_OT_brush_stroke(struct wmOperatorType *ot); | void SCULPT_OT_brush_stroke(struct wmOperatorType *ot); | ||||
| /* end sculpt_ops.c */ | /* end sculpt_ops.c */ | ||||
| BLI_INLINE bool SCULPT_tool_is_paint(int tool) | BLI_INLINE bool SCULPT_tool_is_paint(int tool) | ||||
| { | { | ||||
| return ELEM(tool, SCULPT_TOOL_PAINT, SCULPT_TOOL_SMEAR); | return ELEM(tool, SCULPT_TOOL_PAINT, SCULPT_TOOL_SMEAR); | ||||
| } | } | ||||
| BLI_INLINE bool SCULPT_tool_is_mask(int tool) | BLI_INLINE bool SCULPT_tool_is_mask(int tool) | ||||
| { | { | ||||
| return ELEM(tool, SCULPT_TOOL_MASK); | return ELEM(tool, SCULPT_TOOL_MASK); | ||||
| } | } | ||||
| BLI_INLINE bool SCULPT_tool_is_face_sets(int tool) | BLI_INLINE bool SCULPT_tool_is_face_sets(int tool) | ||||
| { | { | ||||
| return ELEM(tool, SCULPT_TOOL_DRAW_FACE_SETS); | return ELEM(tool, SCULPT_TOOL_DRAW_FACE_SETS); | ||||
| } | } | ||||
| void SCULPT_stroke_id_ensure(struct Object *ob); | |||||
| void SCULPT_stroke_id_next(struct Object *ob); | |||||
| bool SCULPT_tool_can_reuse_automask(int sculpt_tool); | |||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||
| } | } | ||||
| #endif | #endif | ||||
| /* Make SCULPT_ alias to a few blenkernel sculpt methods. */ | /* Make SCULPT_ alias to a few blenkernel sculpt methods. */ | ||||
| #define SCULPT_vertex_attr_get BKE_sculpt_vertex_attr_get | #define SCULPT_vertex_attr_get BKE_sculpt_vertex_attr_get | ||||
| #define SCULPT_face_attr_get BKE_sculpt_face_attr_get | #define SCULPT_face_attr_get BKE_sculpt_face_attr_get | ||||