36 int aa_samples = 1.0f / (radius * 0.20f);
52 const float cursor_position[2])
56 int clamped_radius =
max_ff(radius, 1.0);
58 unsigned short *m = curve_mask_cache->
curve_mask;
61 const float aa_offset = 1.0f / (2.0f * (
float)aa_samples);
62 const float aa_step = 1.0f / (
float)aa_samples;
65 bpos[0] = cursor_position[0] -
floorf(cursor_position[0]) +
offset;
66 bpos[1] = cursor_position[1] -
floorf(cursor_position[1]) +
offset;
68 float weight_factor = 65535.0f / (
float)(aa_samples * aa_samples);
70 for (
int y = 0;
y < diameter;
y++) {
71 for (
int x = 0;
x < diameter;
x++, m++) {
73 pixel_xy[0] =
static_cast<float>(
x) + aa_offset;
74 float total_weight = 0;
76 for (
int i = 0; i < aa_samples; i++) {
77 pixel_xy[1] =
static_cast<float>(
y) + aa_offset;
78 for (
int j = 0; j < aa_samples; j++) {
82 const float sample_weight = curve_mask_cache->
sampled_curve[sample_index];
84 total_weight += sample_weight;
86 pixel_xy[1] += aa_step;
88 pixel_xy[0] += aa_step;
90 *m = (
unsigned short)(total_weight * weight_factor);
126 return diameter * diameter *
sizeof(
ushort);
143 curve_mask_cache->
curve_mask =
static_cast<unsigned short *
>(
162 const float cursor_position[2])
typedef float(TangentPoint)[2]
float BKE_brush_curve_strength_clamped(const struct Brush *br, float p, float len)
MINLINE float max_ff(float a, float b)
MINLINE int min_ii(int a, int b)
MINLINE int clamp_i(int value, int min, int max)
MINLINE float len_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
@ BRUSH_PAINT_ANTIALIASING
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
Read Guarded memory(de)allocation.
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
void *(* MEM_mallocN)(size_t len, const char *str)
constexpr int CurveSamplesBaseLen
Number of samples to use between 0..1.
static void sampled_curve_free(CurveMaskCache *curve_mask_cache)
constexpr int AntiAliasingSamplesPerTexelAxisMin
static int aa_samples_per_texel_axis(const Brush *brush, const float radius)
static void update_curve_mask(CurveMaskCache *curve_mask_cache, const Brush *brush, const int diameter, const float radius, const float cursor_position[2])
static size_t diameter_to_curve_mask_size(const int diameter)
static void curve_mask_free(CurveMaskCache *curve_mask_cache)
constexpr int AntiAliasingSamplesPerTexelAxisMax
static bool is_sampled_curve_valid(const CurveMaskCache *curve_mask_cache, const Brush *brush)
static void curve_mask_allocate(CurveMaskCache *curve_mask_cache, const int diameter)
static bool is_curve_mask_size_valid(const CurveMaskCache *curve_mask_cache, const int diameter)
static void update_sampled_curve(CurveMaskCache *curve_mask_cache, const Brush *brush)
constexpr int CurveSamplesLen
Number of samples to store in the cache.
void paint_curve_mask_cache_free_data(CurveMaskCache *curve_mask_cache)
void paint_curve_mask_cache_update(CurveMaskCache *curve_mask_cache, const Brush *brush, const int diameter, const float radius, const float cursor_position[2])
struct CurveMapping * curve
Caching structure for curve mask.
ushort * curve_mask
Curve mask that can be passed as curve_mask parameter when.
float * sampled_curve
sampled version of the brush curve-mapping.
int last_curve_timestamp
Last CurveMapping.changed_timestamp being read.
size_t curve_mask_size
Size in bytes of the curve_mask field.