diff options
author | Julian Eisel <eiseljulian@gmail.com> | 2015-06-10 16:27:58 +0300 |
---|---|---|
committer | Julian Eisel <eiseljulian@gmail.com> | 2015-06-10 16:27:58 +0300 |
commit | ab9eee4bfb91e1147333b98516dba0e97c27d4de (patch) | |
tree | 2d8fe44cd75751f35da0bfba6ed57374d9a81bb4 /source/blender/blenkernel | |
parent | e0b92ca72b4004c4da2989a605a76bb9c496ef07 (diff) | |
parent | ab417f31f403d74a76fb51fbd6e2aa3f706e15f1 (diff) |
Merge branch 'master' into UI-graphical-redesign
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_brush.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_idcode.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/brush.c | 13 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/colortools.c | 12 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/idcode.c | 87 |
5 files changed, 76 insertions, 38 deletions
diff --git a/source/blender/blenkernel/BKE_brush.h b/source/blender/blenkernel/BKE_brush.h index 023303fe602..042fba7294c 100644 --- a/source/blender/blenkernel/BKE_brush.h +++ b/source/blender/blenkernel/BKE_brush.h @@ -63,6 +63,7 @@ void BKE_brush_randomize_texture_coords(struct UnifiedPaintSettings *ups, bool m /* brush curve */ void BKE_brush_curve_preset(struct Brush *b, int preset); +float BKE_brush_curve_strength_clamped(struct Brush *br, float p, const float len); float BKE_brush_curve_strength(struct Brush *br, float p, const float len); /* sampling */ diff --git a/source/blender/blenkernel/BKE_idcode.h b/source/blender/blenkernel/BKE_idcode.h index 10a34838662..420df77ff1e 100644 --- a/source/blender/blenkernel/BKE_idcode.h +++ b/source/blender/blenkernel/BKE_idcode.h @@ -34,6 +34,7 @@ const char *BKE_idcode_to_name(int code); const char *BKE_idcode_to_name_plural(int code); +const char *BKE_idcode_to_translation_context(int code); int BKE_idcode_from_name(const char *name); bool BKE_idcode_is_linkable(int code); bool BKE_idcode_is_valid(int code); diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 307f97f1344..2464b3b2668 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -971,7 +971,7 @@ void BKE_brush_randomize_texture_coords(UnifiedPaintSettings *ups, bool mask) } } -/* Uses the brush curve control to find a strength value between 0 and 1 */ +/* Uses the brush curve control to find a strength value */ float BKE_brush_curve_strength(Brush *br, float p, const float len) { float strength; @@ -981,6 +981,15 @@ float BKE_brush_curve_strength(Brush *br, float p, const float len) strength = curvemapping_evaluateF(br->curve, 0, p); + return strength; +} + + +/* Uses the brush curve control to find a strength value between 0 and 1 */ +float BKE_brush_curve_strength_clamped(Brush *br, float p, const float len) +{ + float strength = BKE_brush_curve_strength(br, p, len); + CLAMP(strength, 0.0f, 1.0f); return strength; @@ -1042,7 +1051,7 @@ struct ImBuf *BKE_brush_gen_radial_control_imbuf(Brush *br, bool secondary) for (i = 0; i < side; ++i) { for (j = 0; j < side; ++j) { float magn = sqrtf(pow2f(i - half) + pow2f(j - half)); - im->rect_float[i * side + j] = BKE_brush_curve_strength(br, magn, half); + im->rect_float[i * side + j] = BKE_brush_curve_strength_clamped(br, magn, half); } } diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index c5f7e12c9d0..1120034e217 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -790,7 +790,17 @@ float curvemap_evaluateF(const CurveMap *cuma, float value) float curvemapping_evaluateF(const CurveMapping *cumap, int cur, float value) { const CurveMap *cuma = cumap->cm + cur; - return curvemap_evaluateF(cuma, value); + float val = curvemap_evaluateF(cuma, value); + + /* account for clipping */ + if (cumap->flag & CUMA_DO_CLIP) { + if (val < cumap->curr.ymin) + val = cumap->curr.ymin; + else if (val > cumap->curr.ymax) + val = cumap->curr.ymax; + } + + return val; } /* vector case */ diff --git a/source/blender/blenkernel/intern/idcode.c b/source/blender/blenkernel/intern/idcode.c index 1b7a03ec80e..091d8a6ea17 100644 --- a/source/blender/blenkernel/intern/idcode.c +++ b/source/blender/blenkernel/intern/idcode.c @@ -37,11 +37,15 @@ #include "BLI_utildefines.h" +#include "BLF_translation.h" + #include "BKE_idcode.h" typedef struct { unsigned short code; const char *name, *plural; + + const char *i18n_context; int flags; #define IDTYPE_FLAGS_ISLINKABLE (1 << 0) @@ -50,41 +54,41 @@ typedef struct { /* plural need to match rna_main.c's MainCollectionDef */ /* WARNING! Keep it in sync with i18n contexts in BLF_translation.h */ static IDType idtypes[] = { - { ID_AC, "Action", "actions", IDTYPE_FLAGS_ISLINKABLE }, - { ID_AR, "Armature", "armatures", IDTYPE_FLAGS_ISLINKABLE }, - { ID_BR, "Brush", "brushes", IDTYPE_FLAGS_ISLINKABLE }, - { ID_CA, "Camera", "cameras", IDTYPE_FLAGS_ISLINKABLE }, - { ID_CU, "Curve", "curves", IDTYPE_FLAGS_ISLINKABLE }, - { ID_GD, "GPencil", "grease_pencil", IDTYPE_FLAGS_ISLINKABLE }, /* rename gpencil */ - { ID_GR, "Group", "groups", IDTYPE_FLAGS_ISLINKABLE }, - { ID_ID, "ID", "ids", 0 }, /* plural is fake */ - { ID_IM, "Image", "images", IDTYPE_FLAGS_ISLINKABLE }, - { ID_IP, "Ipo", "ipos", IDTYPE_FLAGS_ISLINKABLE }, /* deprecated */ - { ID_KE, "Key", "shape_keys", 0 }, - { ID_LA, "Lamp", "lamps", IDTYPE_FLAGS_ISLINKABLE }, - { ID_LI, "Library", "libraries", 0 }, - { ID_LS, "FreestyleLineStyle", "linestyles", IDTYPE_FLAGS_ISLINKABLE }, - { ID_LT, "Lattice", "lattices", IDTYPE_FLAGS_ISLINKABLE }, - { ID_MA, "Material", "materials", IDTYPE_FLAGS_ISLINKABLE }, - { ID_MB, "Metaball", "metaballs", IDTYPE_FLAGS_ISLINKABLE }, - { ID_MC, "MovieClip", "movieclips", IDTYPE_FLAGS_ISLINKABLE }, - { ID_ME, "Mesh", "meshes", IDTYPE_FLAGS_ISLINKABLE }, - { ID_MSK, "Mask", "masks", IDTYPE_FLAGS_ISLINKABLE }, - { ID_NT, "NodeTree", "node_groups", IDTYPE_FLAGS_ISLINKABLE }, - { ID_OB, "Object", "objects", IDTYPE_FLAGS_ISLINKABLE }, - { ID_PA, "ParticleSettings", "particles", 0 }, - { ID_PAL, "Palettes", "palettes", IDTYPE_FLAGS_ISLINKABLE }, - { ID_PC, "PaintCurve", "paint_curves", IDTYPE_FLAGS_ISLINKABLE }, - { ID_SCE, "Scene", "scenes", IDTYPE_FLAGS_ISLINKABLE }, - { ID_SCR, "Screen", "screens", 0 }, - { ID_SEQ, "Sequence", "sequences", 0 }, /* not actually ID data */ - { ID_SPK, "Speaker", "speakers", IDTYPE_FLAGS_ISLINKABLE }, - { ID_SO, "Sound", "sounds", IDTYPE_FLAGS_ISLINKABLE }, - { ID_TE, "Texture", "textures", IDTYPE_FLAGS_ISLINKABLE }, - { ID_TXT, "Text", "texts", IDTYPE_FLAGS_ISLINKABLE }, - { ID_VF, "VFont", "fonts", IDTYPE_FLAGS_ISLINKABLE }, - { ID_WO, "World", "worlds", IDTYPE_FLAGS_ISLINKABLE }, - { ID_WM, "WindowManager", "window_managers", 0 }, + { ID_AC, "Action", "actions", BLF_I18NCONTEXT_ID_ACTION, IDTYPE_FLAGS_ISLINKABLE }, + { ID_AR, "Armature", "armatures", BLF_I18NCONTEXT_ID_ARMATURE, IDTYPE_FLAGS_ISLINKABLE }, + { ID_BR, "Brush", "brushes", BLF_I18NCONTEXT_ID_BRUSH, IDTYPE_FLAGS_ISLINKABLE }, + { ID_CA, "Camera", "cameras", BLF_I18NCONTEXT_ID_CAMERA, IDTYPE_FLAGS_ISLINKABLE }, + { ID_CU, "Curve", "curves", BLF_I18NCONTEXT_ID_CURVE, IDTYPE_FLAGS_ISLINKABLE }, + { ID_GD, "GPencil", "grease_pencil", BLF_I18NCONTEXT_ID_GPENCIL, IDTYPE_FLAGS_ISLINKABLE }, /* rename gpencil */ + { ID_GR, "Group", "groups", BLF_I18NCONTEXT_ID_GROUP, IDTYPE_FLAGS_ISLINKABLE }, + { ID_ID, "ID", "ids", BLF_I18NCONTEXT_ID_ID, 0 }, /* plural is fake */ + { ID_IM, "Image", "images", BLF_I18NCONTEXT_ID_IMAGE, IDTYPE_FLAGS_ISLINKABLE }, + { ID_IP, "Ipo", "ipos", "", IDTYPE_FLAGS_ISLINKABLE }, /* deprecated */ + { ID_KE, "Key", "shape_keys", BLF_I18NCONTEXT_ID_SHAPEKEY, 0 }, + { ID_LA, "Lamp", "lamps", BLF_I18NCONTEXT_ID_LAMP, IDTYPE_FLAGS_ISLINKABLE }, + { ID_LI, "Library", "libraries", BLF_I18NCONTEXT_ID_LIBRARY, 0 }, + { ID_LS, "FreestyleLineStyle", "linestyles", BLF_I18NCONTEXT_ID_FREESTYLELINESTYLE, IDTYPE_FLAGS_ISLINKABLE }, + { ID_LT, "Lattice", "lattices", BLF_I18NCONTEXT_ID_LATTICE, IDTYPE_FLAGS_ISLINKABLE }, + { ID_MA, "Material", "materials", BLF_I18NCONTEXT_ID_MATERIAL, IDTYPE_FLAGS_ISLINKABLE }, + { ID_MB, "Metaball", "metaballs", BLF_I18NCONTEXT_ID_METABALL, IDTYPE_FLAGS_ISLINKABLE }, + { ID_MC, "MovieClip", "movieclips", BLF_I18NCONTEXT_ID_MOVIECLIP, IDTYPE_FLAGS_ISLINKABLE }, + { ID_ME, "Mesh", "meshes", BLF_I18NCONTEXT_ID_MESH, IDTYPE_FLAGS_ISLINKABLE }, + { ID_MSK, "Mask", "masks", BLF_I18NCONTEXT_ID_MASK, IDTYPE_FLAGS_ISLINKABLE }, + { ID_NT, "NodeTree", "node_groups", BLF_I18NCONTEXT_ID_NODETREE, IDTYPE_FLAGS_ISLINKABLE }, + { ID_OB, "Object", "objects", BLF_I18NCONTEXT_ID_OBJECT, IDTYPE_FLAGS_ISLINKABLE }, + { ID_PA, "ParticleSettings", "particles", BLF_I18NCONTEXT_ID_PARTICLESETTINGS, 0 }, + { ID_PAL, "Palettes", "palettes", BLF_I18NCONTEXT_ID_PALETTE, IDTYPE_FLAGS_ISLINKABLE }, + { ID_PC, "PaintCurve", "paint_curves", BLF_I18NCONTEXT_ID_PAINTCURVE, IDTYPE_FLAGS_ISLINKABLE }, + { ID_SCE, "Scene", "scenes", BLF_I18NCONTEXT_ID_SCENE, IDTYPE_FLAGS_ISLINKABLE }, + { ID_SCR, "Screen", "screens", BLF_I18NCONTEXT_ID_SCREEN, 0 }, + { ID_SEQ, "Sequence", "sequences", BLF_I18NCONTEXT_ID_SEQUENCE, 0 }, /* not actually ID data */ + { ID_SPK, "Speaker", "speakers", BLF_I18NCONTEXT_ID_SPEAKER, IDTYPE_FLAGS_ISLINKABLE }, + { ID_SO, "Sound", "sounds", BLF_I18NCONTEXT_ID_SOUND, IDTYPE_FLAGS_ISLINKABLE }, + { ID_TE, "Texture", "textures", BLF_I18NCONTEXT_ID_TEXTURE, IDTYPE_FLAGS_ISLINKABLE }, + { ID_TXT, "Text", "texts", BLF_I18NCONTEXT_ID_TEXT, IDTYPE_FLAGS_ISLINKABLE }, + { ID_VF, "VFont", "fonts", BLF_I18NCONTEXT_ID_VFONT, IDTYPE_FLAGS_ISLINKABLE }, + { ID_WO, "World", "worlds", BLF_I18NCONTEXT_ID_WORLD, IDTYPE_FLAGS_ISLINKABLE }, + { ID_WM, "WindowManager", "window_managers", BLF_I18NCONTEXT_ID_WINDOWMANAGER, 0 }, }; static IDType *idtype_from_name(const char *str) @@ -176,6 +180,19 @@ const char *BKE_idcode_to_name_plural(int code) } /** + * Convert an idcode into its translations' context. + * + * \param code The code to convert. + * \return A static string representing the i18n context of the code. + */ +const char *BKE_idcode_to_translation_context(int code) +{ + IDType *idt = idtype_from_code(code); + BLI_assert(idt); + return idt ? idt->i18n_context : BLF_I18NCONTEXT_DEFAULT; +} + +/** * Return an ID code and steps the index forward 1. * * \param index start as 0. |