Cleanup: Reduce use and scope of templates in vertex paint #2

Closed
Hans Goudey wants to merge 10 commits from paint-vertex-fewer-templates into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
5 changed files with 547 additions and 642 deletions

View File

@ -87,6 +87,17 @@ struct FloatTraits {
}
};
template<typename T> struct TraitsType {
using type = void;
};
template<> struct TraitsType<ColorPaint4f> {
using type = FloatTraits;
};
template<> struct TraitsType<ColorPaint4b> {
using type = ByteTraits;
};
template<typename T> using Traits = typename TraitsType<T>::type;
static float get_luminance(ColorPaint4f c)
{
return IMB_colormanagement_get_luminance(&c.r);

View File

@ -136,8 +136,6 @@ void PAINT_OT_weight_gradient(wmOperatorType *ot);
void PAINT_OT_vertex_paint_toggle(wmOperatorType *ot);
void PAINT_OT_vertex_paint(wmOperatorType *ot);
unsigned int vpaint_get_current_color(Scene *scene, VPaint *vp, bool secondary);
/**
* \note weight-paint has an equivalent function: #ED_wpaint_blend_tool
*/

File diff suppressed because it is too large Load Diff

View File

@ -4334,7 +4334,6 @@ void SCULPT_cache_free(StrokeCache *cache)
MEM_SAFE_FREE(cache->detail_directions);
MEM_SAFE_FREE(cache->prev_displacement);
MEM_SAFE_FREE(cache->limit_surface_co);
MEM_SAFE_FREE(cache->prev_colors_vpaint);
if (cache->pose_ik_chain) {
SCULPT_pose_ik_chain_free(cache->pose_ik_chain);
@ -4350,7 +4349,7 @@ void SCULPT_cache_free(StrokeCache *cache)
SCULPT_cloth_simulation_free(cache->cloth_sim);
}
MEM_freeN(cache);
MEM_delete(cache);
}
/* Initialize mirror modifier clipping. */
@ -4454,8 +4453,7 @@ static void smooth_brush_toggle_off(const bContext *C, Paint *paint, StrokeCache
static void sculpt_update_cache_invariants(
bContext *C, Sculpt *sd, SculptSession *ss, wmOperator *op, const float mval[2])
{
StrokeCache *cache = static_cast<StrokeCache *>(
MEM_callocN(sizeof(StrokeCache), "stroke cache"));
StrokeCache *cache = MEM_new<StrokeCache>(__func__);
ToolSettings *tool_settings = CTX_data_tool_settings(C);
UnifiedPaintSettings *ups = &tool_settings->unified_paint_settings;
Brush *brush = BKE_paint_brush(&sd->paint);

View File

@ -21,6 +21,7 @@
#include "BLI_bitmap.h"
#include "BLI_compiler_attrs.h"
#include "BLI_compiler_compat.h"
#include "BLI_generic_array.hh"
#include "BLI_gsqueue.h"
#include "BLI_implicit_sharing.hh"
#include "BLI_span.hh"
@ -555,7 +556,7 @@ struct StrokeCache {
float mouse_event[2];
float (*prev_colors)[4];
void *prev_colors_vpaint;
blender::GArray<> prev_colors_vpaint;
/* Multires Displacement Smear. */
float (*prev_displacement)[3];