Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2020-10-21 12:11:16 +0300
committerJacques Lucke <jacques@blender.org>2020-10-21 12:11:16 +0300
commita0ce0154e792bf5425e21b301d0b4a9f452d1c01 (patch)
tree956837473fa94528690fdc552a0a6479c05e1a98 /source
parent0cd7f7ddd12a682dc9b03495e13d1b19c3ee8307 (diff)
parent22ceb4a752e8f29d95793fdc81226f7f2dc0c92e (diff)
Merge branch 'master' into geometry-nodes
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenfont/BLF_api.h5
-rw-r--r--source/blender/blenfont/intern/blf.c10
-rw-r--r--source/blender/blenkernel/BKE_ocean.h5
-rw-r--r--source/blender/blenkernel/intern/fluid.c1
-rw-r--r--source/blender/blenkernel/intern/ocean.c86
-rw-r--r--source/blender/blenkernel/intern/ocean_intern.h1
-rw-r--r--source/blender/blenkernel/intern/particle.c2
-rw-r--r--source/blender/blenkernel/intern/scene.c36
-rw-r--r--source/blender/blenlib/intern/sort.c4
-rw-r--r--source/blender/blenlib/intern/storage_apple.mm2
-rw-r--r--source/blender/blenloader/intern/versioning_290.c28
-rw-r--r--source/blender/bmesh/intern/bmesh_construct.c3
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_ssr_frag.glsl36
-rw-r--r--source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl1
-rw-r--r--source/blender/draw/intern/draw_manager.c19
-rw-r--r--source/blender/editors/datafiles/CMakeLists.txt4
-rw-r--r--source/blender/editors/include/ED_uvedit.h6
-rw-r--r--source/blender/editors/object/object_modes.c57
-rw-r--r--source/blender/editors/screen/screen_ops.c306
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c16
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_intern.h3
-rw-r--r--source/blender/editors/space_image/space_image.c110
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c4
-rw-r--r--source/blender/editors/uvedit/uvedit_draw.c497
-rw-r--r--source/blender/io/alembic/intern/abc_reader_object.cc5
-rw-r--r--source/blender/makesdna/DNA_fluid_defaults.h1
-rw-r--r--source/blender/makesdna/DNA_fluid_types.h3
-rw-r--r--source/blender/makesdna/DNA_space_types.h2
-rw-r--r--source/blender/makesdna/DNA_userdef_types.h3
-rw-r--r--source/blender/makesrna/RNA_access.h8
-rw-r--r--source/blender/makesrna/RNA_define.h2
-rw-r--r--source/blender/makesrna/intern/makesrna.c24
-rw-r--r--source/blender/makesrna/intern/rna_access.c486
-rw-r--r--source/blender/makesrna/intern/rna_access_compare_override.c22
-rw-r--r--source/blender/makesrna/intern/rna_define.c12
-rw-r--r--source/blender/makesrna/intern/rna_fluid.c12
-rw-r--r--source/blender/makesrna/intern/rna_space.c5
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c5
-rw-r--r--source/blender/modifiers/intern/MOD_mesh_to_volume.cc3
-rw-r--r--source/blender/render/intern/source/render_result.c9
-rw-r--r--source/blender/windowmanager/WM_types.h5
-rw-r--r--source/blender/windowmanager/intern/wm_gesture.c1
-rw-r--r--source/blender/windowmanager/intern/wm_gesture_ops.c302
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c40
-rw-r--r--source/blender/windowmanager/wm_event_types.h6
46 files changed, 911 insertions, 1289 deletions
diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h
index 17a650e28f5..bf84f5c57b3 100644
--- a/source/blender/blenfont/BLF_api.h
+++ b/source/blender/blenfont/BLF_api.h
@@ -163,13 +163,8 @@ float BLF_height_ex(int fontid, const char *str, size_t len, struct ResultBLF *r
float BLF_height(int fontid, const char *str, size_t len) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
/* Return dimensions of the font without any sample text. */
-
int BLF_height_max(int fontid) ATTR_WARN_UNUSED_RESULT;
-int BLF_default_height_max(void) ATTR_WARN_UNUSED_RESULT;
-
float BLF_width_max(int fontid) ATTR_WARN_UNUSED_RESULT;
-float BLF_default_width_max(void) ATTR_WARN_UNUSED_RESULT;
-
float BLF_descender(int fontid) ATTR_WARN_UNUSED_RESULT;
float BLF_ascender(int fontid) ATTR_WARN_UNUSED_RESULT;
diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c
index 76ff498f5c2..c8940add738 100644
--- a/source/blender/blenfont/intern/blf.c
+++ b/source/blender/blenfont/intern/blf.c
@@ -824,11 +824,6 @@ int BLF_height_max(int fontid)
return 0;
}
-int BLF_default_height_max(void)
-{
- return BLF_height_max(global_font_default);
-}
-
float BLF_width_max(int fontid)
{
FontBLF *font = blf_get(fontid);
@@ -840,11 +835,6 @@ float BLF_width_max(int fontid)
return 0.0f;
}
-float BLF_default_width_max(void)
-{
- return BLF_width_max(global_font_default);
-}
-
float BLF_descender(int fontid)
{
FontBLF *font = blf_get(fontid);
diff --git a/source/blender/blenkernel/BKE_ocean.h b/source/blender/blenkernel/BKE_ocean.h
index 1f8cdf27eb1..2c0c6989acf 100644
--- a/source/blender/blenkernel/BKE_ocean.h
+++ b/source/blender/blenkernel/BKE_ocean.h
@@ -44,6 +44,10 @@ typedef struct OceanCache {
struct ImBuf **ibufs_disp;
struct ImBuf **ibufs_foam;
struct ImBuf **ibufs_norm;
+ /* spray is Eplus */
+ struct ImBuf **ibufs_spray;
+ /* spray_inverse is Eminus */
+ struct ImBuf **ibufs_spray_inverse;
const char *bakepath;
const char *relbase;
@@ -92,6 +96,7 @@ void BKE_ocean_init(struct Ocean *o,
float sharpen_peak_jonswap,
short do_height_field,
short do_chop,
+ short do_spray,
short do_normals,
short do_jacobian,
int seed);
diff --git a/source/blender/blenkernel/intern/fluid.c b/source/blender/blenkernel/intern/fluid.c
index f66ba428611..9ad352c8455 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -4985,6 +4985,7 @@ void BKE_fluid_modifier_copy(const struct FluidModifierData *fmd,
tfds->particle_radius = fds->particle_radius;
tfds->particle_band_width = fds->particle_band_width;
tfds->fractions_threshold = fds->fractions_threshold;
+ tfds->fractions_distance = fds->fractions_distance;
tfds->sys_particle_maximum = fds->sys_particle_maximum;
/* diffusion options*/
diff --git a/source/blender/blenkernel/intern/ocean.c b/source/blender/blenkernel/intern/ocean.c
index ff7cbff06bf..6c770e53000 100644
--- a/source/blender/blenkernel/intern/ocean.c
+++ b/source/blender/blenkernel/intern/ocean.c
@@ -773,12 +773,13 @@ void BKE_ocean_init_from_modifier(struct Ocean *ocean,
struct OceanModifierData const *omd,
const int resolution)
{
- short do_heightfield, do_chop, do_normals, do_jacobian;
+ short do_heightfield, do_chop, do_normals, do_jacobian, do_spray;
do_heightfield = true;
do_chop = (omd->chop_amount > 0);
do_normals = (omd->flag & MOD_OCEAN_GENERATE_NORMALS);
do_jacobian = (omd->flag & MOD_OCEAN_GENERATE_FOAM);
+ do_spray = do_jacobian && (omd->flag & MOD_OCEAN_GENERATE_SPRAY);
BKE_ocean_free_data(ocean);
@@ -800,6 +801,7 @@ void BKE_ocean_init_from_modifier(struct Ocean *ocean,
omd->sharpen_peak_jonswap,
do_heightfield,
do_chop,
+ do_spray,
do_normals,
do_jacobian,
omd->seed);
@@ -823,6 +825,7 @@ void BKE_ocean_init(struct Ocean *o,
float sharpen_peak_jonswap,
short do_height_field,
short do_chop,
+ short do_spray,
short do_normals,
short do_jacobian,
int seed)
@@ -857,6 +860,7 @@ void BKE_ocean_init(struct Ocean *o,
o->_do_disp_y = do_height_field;
o->_do_normals = do_normals;
+ o->_do_spray = do_spray;
o->_do_chop = do_chop;
o->_do_jacobian = do_jacobian;
@@ -1107,6 +1111,8 @@ void BKE_ocean_free(struct Ocean *oc)
# define CACHE_TYPE_DISPLACE 1
# define CACHE_TYPE_FOAM 2
# define CACHE_TYPE_NORMAL 3
+# define CACHE_TYPE_SPRAY 4
+# define CACHE_TYPE_SPRAY_INVERSE 5
static void cache_filename(
char *string, const char *path, const char *relbase, int frame, int type)
@@ -1121,6 +1127,12 @@ static void cache_filename(
case CACHE_TYPE_NORMAL:
fname = "normal_";
break;
+ case CACHE_TYPE_SPRAY:
+ fname = "spray_";
+ break;
+ case CACHE_TYPE_SPRAY_INVERSE:
+ fname = "spray_inverse_";
+ break;
case CACHE_TYPE_DISPLACE:
default:
fname = "disp_";
@@ -1175,6 +1187,24 @@ void BKE_ocean_free_cache(struct OceanCache *och)
MEM_freeN(och->ibufs_foam);
}
+ if (och->ibufs_spray) {
+ for (i = och->start, f = 0; i <= och->end; i++, f++) {
+ if (och->ibufs_spray[f]) {
+ IMB_freeImBuf(och->ibufs_spray[f]);
+ }
+ }
+ MEM_freeN(och->ibufs_spray);
+ }
+
+ if (och->ibufs_spray_inverse) {
+ for (i = och->start, f = 0; i <= och->end; i++, f++) {
+ if (och->ibufs_spray_inverse[f]) {
+ IMB_freeImBuf(och->ibufs_spray_inverse[f]);
+ }
+ }
+ MEM_freeN(och->ibufs_spray_inverse);
+ }
+
if (och->ibufs_norm) {
for (i = och->start, f = 0; i <= och->end; i++, f++) {
if (och->ibufs_norm[f]) {
@@ -1217,6 +1247,17 @@ void BKE_ocean_cache_eval_uv(
ocr->foam = result[0];
}
+ if (och->ibufs_spray[f]) {
+ ibuf_sample(och->ibufs_spray[f], u, v, (1.0f / (float)res_x), (1.0f / (float)res_y), result);
+ copy_v3_v3(ocr->Eplus, result);
+ }
+
+ if (och->ibufs_spray_inverse[f]) {
+ ibuf_sample(
+ och->ibufs_spray_inverse[f], u, v, (1.0f / (float)res_x), (1.0f / (float)res_y), result);
+ copy_v3_v3(ocr->Eminus, result);
+ }
+
if (och->ibufs_norm[f]) {
ibuf_sample(och->ibufs_norm[f], u, v, (1.0f / (float)res_x), (1.0f / (float)res_y), result);
copy_v3_v3(ocr->normal, result);
@@ -1246,6 +1287,14 @@ void BKE_ocean_cache_eval_ij(struct OceanCache *och, struct OceanResult *ocr, in
ocr->foam = och->ibufs_foam[f]->rect_float[4 * (res_x * j + i)];
}
+ if (och->ibufs_spray[f]) {
+ copy_v3_v3(ocr->Eplus, &och->ibufs_spray[f]->rect_float[4 * (res_x * j + i)]);
+ }
+
+ if (och->ibufs_spray_inverse[f]) {
+ copy_v3_v3(ocr->Eminus, &och->ibufs_spray_inverse[f]->rect_float[4 * (res_x * j + i)]);
+ }
+
if (och->ibufs_norm[f]) {
copy_v3_v3(ocr->normal, &och->ibufs_norm[f]->rect_float[4 * (res_x * j + i)]);
}
@@ -1279,6 +1328,9 @@ struct OceanCache *BKE_ocean_init_cache(const char *bakepath,
och->ibufs_disp = MEM_callocN(sizeof(ImBuf *) * och->duration,
"displacement imbuf pointer array");
och->ibufs_foam = MEM_callocN(sizeof(ImBuf *) * och->duration, "foam imbuf pointer array");
+ och->ibufs_spray = MEM_callocN(sizeof(ImBuf *) * och->duration, "spray imbuf pointer array");
+ och->ibufs_spray_inverse = MEM_callocN(sizeof(ImBuf *) * och->duration,
+ "spray_inverse imbuf pointer array");
och->ibufs_norm = MEM_callocN(sizeof(ImBuf *) * och->duration, "normal imbuf pointer array");
och->time = NULL;
@@ -1310,6 +1362,12 @@ void BKE_ocean_simulate_cache(struct OceanCache *och, int frame)
cache_filename(string, och->bakepath, och->relbase, frame, CACHE_TYPE_FOAM);
och->ibufs_foam[f] = IMB_loadiffname(string, 0, NULL);
+ cache_filename(string, och->bakepath, och->relbase, frame, CACHE_TYPE_SPRAY);
+ och->ibufs_spray[f] = IMB_loadiffname(string, 0, NULL);
+
+ cache_filename(string, och->bakepath, och->relbase, frame, CACHE_TYPE_SPRAY_INVERSE);
+ och->ibufs_spray_inverse[f] = IMB_loadiffname(string, 0, NULL);
+
cache_filename(string, och->bakepath, och->relbase, frame, CACHE_TYPE_NORMAL);
och->ibufs_norm[f] = IMB_loadiffname(string, 0, NULL);
}
@@ -1329,7 +1387,7 @@ void BKE_ocean_bake(struct Ocean *o,
int f, i = 0, x, y, cancel = 0;
float progress;
- ImBuf *ibuf_foam, *ibuf_disp, *ibuf_normal;
+ ImBuf *ibuf_foam, *ibuf_disp, *ibuf_normal, *ibuf_spray, *ibuf_spray_inverse;
float *prev_foam;
int res_x = och->resolution_x;
int res_y = och->resolution_y;
@@ -1360,6 +1418,8 @@ void BKE_ocean_bake(struct Ocean *o,
ibuf_foam = IMB_allocImBuf(res_x, res_y, 32, IB_rectfloat);
ibuf_disp = IMB_allocImBuf(res_x, res_y, 32, IB_rectfloat);
ibuf_normal = IMB_allocImBuf(res_x, res_y, 32, IB_rectfloat);
+ ibuf_spray = IMB_allocImBuf(res_x, res_y, 32, IB_rectfloat);
+ ibuf_spray_inverse = IMB_allocImBuf(res_x, res_y, 32, IB_rectfloat);
BKE_ocean_simulate(o, och->time[i], och->wave_scale, och->chop_amount);
@@ -1414,6 +1474,13 @@ void BKE_ocean_bake(struct Ocean *o,
/*foam_result = min_ff(foam_result, 1.0f); */
value_to_rgba_unit_alpha(&ibuf_foam->rect_float[4 * (res_x * y + x)], foam_result);
+
+ /* spray map baking */
+ if (o->_do_spray) {
+ rgb_to_rgba_unit_alpha(&ibuf_spray->rect_float[4 * (res_x * y + x)], ocr.Eplus);
+ rgb_to_rgba_unit_alpha(&ibuf_spray_inverse->rect_float[4 * (res_x * y + x)],
+ ocr.Eminus);
+ }
}
if (o->_do_normals) {
@@ -1433,6 +1500,18 @@ void BKE_ocean_bake(struct Ocean *o,
if (0 == BKE_imbuf_write(ibuf_foam, string, &imf)) {
printf("Cannot save Foam File Output to %s\n", string);
}
+
+ if (o->_do_spray) {
+ cache_filename(string, och->bakepath, och->relbase, f, CACHE_TYPE_SPRAY);
+ if (0 == BKE_imbuf_write(ibuf_spray, string, &imf)) {
+ printf("Cannot save Spray File Output to %s\n", string);
+ }
+
+ cache_filename(string, och->bakepath, och->relbase, f, CACHE_TYPE_SPRAY_INVERSE);
+ if (0 == BKE_imbuf_write(ibuf_spray_inverse, string, &imf)) {
+ printf("Cannot save Spray Inverse File Output to %s\n", string);
+ }
+ }
}
if (o->_do_normals) {
@@ -1445,6 +1524,8 @@ void BKE_ocean_bake(struct Ocean *o,
IMB_freeImBuf(ibuf_disp);
IMB_freeImBuf(ibuf_foam);
IMB_freeImBuf(ibuf_normal);
+ IMB_freeImBuf(ibuf_spray);
+ IMB_freeImBuf(ibuf_spray_inverse);
progress = (f - och->start) / (float)och->duration;
@@ -1541,6 +1622,7 @@ void BKE_ocean_init(struct Ocean *UNUSED(o),
float UNUSED(sharpen_peak_jonswap),
short UNUSED(do_height_field),
short UNUSED(do_chop),
+ short UNUSED(do_spray),
short UNUSED(do_normals),
short UNUSED(do_jacobian),
int UNUSED(seed))
diff --git a/source/blender/blenkernel/intern/ocean_intern.h b/source/blender/blenkernel/intern/ocean_intern.h
index 39ce0db09d6..b55b211fa33 100644
--- a/source/blender/blenkernel/intern/ocean_intern.h
+++ b/source/blender/blenkernel/intern/ocean_intern.h
@@ -57,6 +57,7 @@ typedef struct Ocean {
short _do_disp_y;
short _do_normals;
+ short _do_spray;
short _do_chop;
short _do_jacobian;
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index b978236da06..7b8ee7343ee 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -4384,7 +4384,7 @@ void psys_get_particle_on_path(ParticleSimulationData *sim,
t = psys_get_child_time(psys, cpa, -state->time, NULL, NULL);
}
- if (totchild && part->childtype == PART_CHILD_FACES) {
+ if (part->childtype == PART_CHILD_FACES) {
/* part->parents could still be 0 so we can't test with totparent */
between = 1;
}
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index d0e731fec1b..2475cbeabba 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -445,16 +445,16 @@ static void scene_free_data(ID *id)
BLI_assert(scene->layer_properties == NULL);
}
-static void library_foreach_rigidbodyworldSceneLooper(struct RigidBodyWorld *UNUSED(rbw),
- ID **id_pointer,
- void *user_data,
- int cb_flag)
+static void scene_foreach_rigidbodyworldSceneLooper(struct RigidBodyWorld *UNUSED(rbw),
+ ID **id_pointer,
+ void *user_data,
+ int cb_flag)
{
LibraryForeachIDData *data = (LibraryForeachIDData *)user_data;
BKE_lib_query_foreachid_process(data, id_pointer, cb_flag);
}
-static void library_foreach_paint(LibraryForeachIDData *data, Paint *paint)
+static void scene_foreach_paint(LibraryForeachIDData *data, Paint *paint)
{
BKE_LIB_FOREACHID_PROCESS(data, paint->brush, IDWALK_CB_USER);
for (int i = 0; i < paint->tool_slots_len; i++) {
@@ -463,7 +463,7 @@ static void library_foreach_paint(LibraryForeachIDData *data, Paint *paint)
BKE_LIB_FOREACHID_PROCESS(data, paint->palette, IDWALK_CB_USER);
}
-static void library_foreach_layer_collection(LibraryForeachIDData *data, ListBase *lb)
+static void scene_foreach_layer_collection(LibraryForeachIDData *data, ListBase *lb)
{
LISTBASE_FOREACH (LayerCollection *, lc, lb) {
/* XXX This is very weak. The whole idea of keeping pointers to private IDs is very bad
@@ -473,7 +473,7 @@ static void library_foreach_layer_collection(LibraryForeachIDData *data, ListBas
IDWALK_CB_EMBEDDED :
IDWALK_CB_NOP;
BKE_LIB_FOREACHID_PROCESS(data, lc->collection, cb_flag);
- library_foreach_layer_collection(data, &lc->layer_collections);
+ scene_foreach_layer_collection(data, &lc->layer_collections);
}
}
@@ -525,7 +525,7 @@ static void scene_foreach_id(ID *id, LibraryForeachIDData *data)
BKE_LIB_FOREACHID_PROCESS(data, base->object, IDWALK_CB_NOP);
}
- library_foreach_layer_collection(data, &view_layer->layer_collections);
+ scene_foreach_layer_collection(data, &view_layer->layer_collections);
LISTBASE_FOREACH (FreestyleModuleConfig *, fmc, &view_layer->freestyle_config.modules) {
if (fmc->script) {
@@ -556,35 +556,35 @@ static void scene_foreach_id(ID *id, LibraryForeachIDData *data)
BKE_LIB_FOREACHID_PROCESS(data, toolsett->particle.object, IDWALK_CB_NOP);
BKE_LIB_FOREACHID_PROCESS(data, toolsett->particle.shape_object, IDWALK_CB_NOP);
- library_foreach_paint(data, &toolsett->imapaint.paint);
+ scene_foreach_paint(data, &toolsett->imapaint.paint);
BKE_LIB_FOREACHID_PROCESS(data, toolsett->imapaint.stencil, IDWALK_CB_USER);
BKE_LIB_FOREACHID_PROCESS(data, toolsett->imapaint.clone, IDWALK_CB_USER);
BKE_LIB_FOREACHID_PROCESS(data, toolsett->imapaint.canvas, IDWALK_CB_USER);
if (toolsett->vpaint) {
- library_foreach_paint(data, &toolsett->vpaint->paint);
+ scene_foreach_paint(data, &toolsett->vpaint->paint);
}
if (toolsett->wpaint) {
- library_foreach_paint(data, &toolsett->wpaint->paint);
+ scene_foreach_paint(data, &toolsett->wpaint->paint);
}
if (toolsett->sculpt) {
- library_foreach_paint(data, &toolsett->sculpt->paint);
+ scene_foreach_paint(data, &toolsett->sculpt->paint);
BKE_LIB_FOREACHID_PROCESS(data, toolsett->sculpt->gravity_object, IDWALK_CB_NOP);
}
if (toolsett->uvsculpt) {
- library_foreach_paint(data, &toolsett->uvsculpt->paint);
+ scene_foreach_paint(data, &toolsett->uvsculpt->paint);
}
if (toolsett->gp_paint) {
- library_foreach_paint(data, &toolsett->gp_paint->paint);
+ scene_foreach_paint(data, &toolsett->gp_paint->paint);
}
if (toolsett->gp_vertexpaint) {
- library_foreach_paint(data, &toolsett->gp_vertexpaint->paint);
+ scene_foreach_paint(data, &toolsett->gp_vertexpaint->paint);
}
if (toolsett->gp_sculptpaint) {
- library_foreach_paint(data, &toolsett->gp_sculptpaint->paint);
+ scene_foreach_paint(data, &toolsett->gp_sculptpaint->paint);
}
if (toolsett->gp_weightpaint) {
- library_foreach_paint(data, &toolsett->gp_weightpaint->paint);
+ scene_foreach_paint(data, &toolsett->gp_weightpaint->paint);
}
BKE_LIB_FOREACHID_PROCESS(data, toolsett->gp_sculpt.guide.reference_object, IDWALK_CB_NOP);
@@ -592,7 +592,7 @@ static void scene_foreach_id(ID *id, LibraryForeachIDData *data)
if (scene->rigidbody_world) {
BKE_rigidbody_world_id_loop(
- scene->rigidbody_world, library_foreach_rigidbodyworldSceneLooper, data);
+ scene->rigidbody_world, scene_foreach_rigidbodyworldSceneLooper, data);
}
}
diff --git a/source/blender/blenlib/intern/sort.c b/source/blender/blenlib/intern/sort.c
index 4ae87fff535..e65be760a2c 100644
--- a/source/blender/blenlib/intern/sort.c
+++ b/source/blender/blenlib/intern/sort.c
@@ -45,8 +45,8 @@
*
* \note modified to use glibc arg order for callbacks.
*/
-BLI_INLINE char *med3(char *, char *, char *, BLI_sort_cmp_t, void *);
-BLI_INLINE void swapfunc(char *, char *, int, int);
+BLI_INLINE char *med3(char */*a*/, char */*b*/, char */*c*/, BLI_sort_cmp_t /*cmp*/, void */*thunk*/);
+BLI_INLINE void swapfunc(char */*a*/, char */*b*/, int /*n*/, int /*swaptype*/);
#define min(a, b) (a) < (b) ? (a) : (b)
#define swapcode(TYPE, parmi, parmj, n) \
diff --git a/source/blender/blenlib/intern/storage_apple.mm b/source/blender/blenlib/intern/storage_apple.mm
index 16a2fd338fa..564ef5a199a 100644
--- a/source/blender/blenlib/intern/storage_apple.mm
+++ b/source/blender/blenlib/intern/storage_apple.mm
@@ -32,6 +32,8 @@
* \param r_targetpath Buffer for the target path an alias points to.
* \return Whether the file at the input path is an alias.
*/
+/* False alarm by clang-tidy: #getFileSystemRepresentation changes the return value argument. */
+/* NOLINTNEXTLINE: readability-non-const-parameter. */
bool BLI_file_alias_target(const char *filepath, char r_targetpath[FILE_MAXDIR])
{
/* clang-format off */
diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c
index d93a6d57565..8622264188a 100644
--- a/source/blender/blenloader/intern/versioning_290.c
+++ b/source/blender/blenloader/intern/versioning_290.c
@@ -897,4 +897,32 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
{
/* Keep this block, even when empty. */
}
+
+ /* Remove options of legacy UV/Image editor */
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+ LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
+ switch (sl->spacetype) {
+ case SPACE_IMAGE: {
+ SpaceImage *sima = (SpaceImage *)sl;
+ sima->flag &= ~(SI_FLAG_UNUSED_20);
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "FluidModifierData", "float", "fractions_distance")) {
+ LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
+ LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
+ if (md->type == eModifierType_Fluid) {
+ FluidModifierData *fmd = (FluidModifierData *)md;
+ if (fmd->domain) {
+ fmd->domain->fractions_distance = 0.5;
+ }
+ }
+ }
+ }
+ }
}
diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c
index 2e69c48708c..ca5693aa5ba 100644
--- a/source/blender/bmesh/intern/bmesh_construct.c
+++ b/source/blender/bmesh/intern/bmesh_construct.c
@@ -641,7 +641,8 @@ void BM_mesh_copy_init_customdata_all_layers(BMesh *bm_dst,
const int size = *(&allocsize->totvert + i);
for (int l = 0; l < src->totlayer; l++) {
- CustomData_add_layer(dst, src->layers[l].type, CD_CALLOC, NULL, 0);
+ CustomData_add_layer_named(
+ dst, src->layers[l].type, CD_CALLOC, NULL, 0, src->layers[l].name);
}
CustomData_bmesh_init_pool(dst, size, htypes[i]);
}
diff --git a/source/blender/draw/engines/eevee/shaders/effect_ssr_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_ssr_frag.glsl
index f8dccb7511a..d50a4eaea3c 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_ssr_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_ssr_frag.glsl
@@ -81,11 +81,34 @@ void do_planar_ssr(int index,
void do_ssr(vec3 V, vec3 N, vec3 T, vec3 B, vec3 viewPosition, float a2, vec4 rand)
{
float NH;
- vec3 H = sample_ggx(rand.xzw, a2, N, T, B, NH); /* Microfacet normal */
- float pdf = pdf_ggx_reflect(NH, a2);
-
+ /* Microfacet normal */
+ vec3 H = sample_ggx(rand.xzw, a2, N, T, B, NH);
vec3 R = reflect(-V, H);
- pdfData = min(1024e32, pdf); /* Theoretical limit of 16bit float */
+
+ /* If ray is bad (i.e. going below the surface) regenerate. */
+ /* This threshold is a bit higher than 0 to improve self intersection cases. */
+ const float bad_ray_threshold = 0.085;
+ if (dot(R, N) <= bad_ray_threshold) {
+ H = sample_ggx(rand.xzw * vec3(1.0, -1.0, -1.0), a2, N, T, B, NH);
+ R = reflect(-V, H);
+ }
+
+ if (dot(R, N) <= bad_ray_threshold) {
+ H = sample_ggx(rand.xzw * vec3(1.0, 1.0, -1.0), a2, N, T, B, NH);
+ R = reflect(-V, H);
+ }
+
+ if (dot(R, N) <= bad_ray_threshold) {
+ H = sample_ggx(rand.xzw * vec3(1.0, -1.0, 1.0), a2, N, T, B, NH);
+ R = reflect(-V, H);
+ }
+
+ if (dot(R, N) <= bad_ray_threshold) {
+ /* Not worth tracing. */
+ return;
+ }
+
+ pdfData = min(1024e32, pdf_ggx_reflect(NH, a2)); /* Theoretical limit of 16bit float */
vec3 hit_pos = raycast(-1, viewPosition, R * 1e16, ssrThickness, rand.y, ssrQuality, a2, true);
@@ -171,6 +194,11 @@ void main()
}
}
+ /* Constant bias (due to depth buffer precision). Helps with self intersection. */
+ /* Magic numbers for 24bits of precision.
+ * From http://terathon.com/gdc07_lengyel.pdf (slide 26) */
+ viewPosition.z = get_view_z_from_depth(depth - mix(2.4e-7, 4.8e-7, depth));
+
do_ssr(V, N, T, B, viewPosition, a2, rand);
}
diff --git a/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl b/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl
index 22c306bb0fd..cad1346609a 100644
--- a/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl
@@ -16,6 +16,7 @@ float sample_depth(vec2 uv, int index, float lod)
}
else {
#endif
+ lod = clamp(floor(lod), 0.0, 8.0);
/* Correct UVs for mipmaping mis-alignment */
uv *= mipRatio[int(lod) + hizMipOffset];
return textureLod(maxzBuffer, uv, lod).r;
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index ff12a055361..f995582149a 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -1803,6 +1803,20 @@ void DRW_render_gpencil(struct RenderEngine *engine, struct Depsgraph *depsgraph
DST.buffer_finish_called = false;
}
+/* Callback function for RE_engine_update_render_passes to ensure all
+ * render passes are registered. */
+static void draw_render_result_ensure_pass_cb(void *user_data,
+ struct Scene *UNUSED(scene),
+ struct ViewLayer *view_layer,
+ const char *name,
+ int channels,
+ const char *chanid,
+ eNodeSocketDatatype UNUSED(type))
+{
+ RenderEngine *engine = user_data;
+ RE_engine_add_pass(engine, name, channels, chanid, view_layer->name);
+}
+
void DRW_render_to_image(RenderEngine *engine, struct Depsgraph *depsgraph)
{
Scene *scene = DEG_get_evaluated_scene(depsgraph);
@@ -1851,6 +1865,10 @@ void DRW_render_to_image(RenderEngine *engine, struct Depsgraph *depsgraph)
/* set default viewport */
GPU_viewport(0, 0, size[0], size[1]);
+ /* Update the render passes. This needs to be done before acquiring the render result. */
+ RE_engine_update_render_passes(
+ engine, scene, view_layer, draw_render_result_ensure_pass_cb, engine);
+
/* Init render result. */
RenderResult *render_result = RE_engine_begin_result(engine,
0,
@@ -1859,7 +1877,6 @@ void DRW_render_to_image(RenderEngine *engine, struct Depsgraph *depsgraph)
size[1],
view_layer->name,
/* RR_ALL_VIEWS */ NULL);
-
RenderLayer *render_layer = render_result->layers.first;
for (RenderView *render_view = render_result->views.first; render_view != NULL;
render_view = render_view->next) {
diff --git a/source/blender/editors/datafiles/CMakeLists.txt b/source/blender/editors/datafiles/CMakeLists.txt
index fff8949cf7a..e374010cf44 100644
--- a/source/blender/editors/datafiles/CMakeLists.txt
+++ b/source/blender/editors/datafiles/CMakeLists.txt
@@ -638,11 +638,13 @@ set_property(GLOBAL PROPERTY ICON_GEOM_NAMES
brush.particle.smooth
brush.particle.weight
brush.sculpt.blob
+ brush.sculpt.boundary
brush.sculpt.clay
brush.sculpt.clay_strips
brush.sculpt.clay_thumb
brush.sculpt.cloth
brush.sculpt.crease
+ brush.sculpt.displacement_eraser
brush.sculpt.draw
brush.sculpt.draw_face_sets
brush.sculpt.draw_sharp
@@ -751,6 +753,8 @@ set_property(GLOBAL PROPERTY ICON_GEOM_NAMES
ops.sculpt.lasso_face_set
ops.sculpt.lasso_mask
ops.sculpt.lasso_trim
+ ops.sculpt.line_mask
+ ops.sculpt.line_project
ops.sculpt.mesh_filter
ops.sequencer.blade
ops.transform.bone_envelope
diff --git a/source/blender/editors/include/ED_uvedit.h b/source/blender/editors/include/ED_uvedit.h
index 53fb79bb012..629e77bd4f2 100644
--- a/source/blender/editors/include/ED_uvedit.h
+++ b/source/blender/editors/include/ED_uvedit.h
@@ -229,12 +229,6 @@ void ED_uvedit_add_simple_uvs(struct Main *bmain, const struct Scene *scene, str
/* uvedit_draw.c */
void ED_image_draw_cursor(struct ARegion *region, const float cursor[2]);
-void ED_uvedit_draw_main(struct SpaceImage *sima,
- const struct Scene *scene,
- struct ViewLayer *view_layer,
- struct Object *obedit,
- struct Object *obact,
- struct Depsgraph *depsgraph);
/* uvedit_buttons.c */
void ED_uvedit_buttons_register(struct ARegionType *art);
diff --git a/source/blender/editors/object/object_modes.c b/source/blender/editors/object/object_modes.c
index a52ab523b04..089bd5567a7 100644
--- a/source/blender/editors/object/object_modes.c
+++ b/source/blender/editors/object/object_modes.c
@@ -423,53 +423,24 @@ static bool object_switch_object_poll(bContext *C)
static int object_switch_object_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
-
- Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
ARegion *ar = CTX_wm_region(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
- struct SnapObjectContext *sctx = ED_transform_snap_object_context_create(scene, 0);
-
- float global_normal[3], global_loc[3];
- float r_obmat[4][4];
-
- float mouse[2];
- mouse[0] = event->mval[0];
- mouse[1] = event->mval[1];
-
- float ray_co[3], ray_no[3];
- float ray_dist = BVH_RAYCAST_DIST_MAX;
- int index_dummy;
- ED_view3d_win_to_origin(ar, mouse, ray_co);
- ED_view3d_win_to_vector(ar, mouse, ray_no);
-
- Object *ob_dst = NULL;
-
- bool ret = ED_transform_snap_object_project_ray_ex(sctx,
- depsgraph,
- &(const struct SnapObjectParams){
- .snap_select = SNAP_NOT_ACTIVE,
- },
- ray_co,
- ray_no,
- &ray_dist,
- global_loc,
- global_normal,
- &index_dummy,
- &ob_dst,
- (float(*)[4])r_obmat);
- ED_transform_snap_object_context_destroy(sctx);
-
- if (!ret || ob_dst == NULL) {
+
+ Base *base_dst = ED_view3d_give_base_under_cursor(C, event->mval);
+
+ if (base_dst == NULL) {
return OPERATOR_CANCELLED;
}
+ Object *ob_dst = base_dst->object;
Object *ob_src = CTX_data_active_object(C);
+
if (ob_dst == ob_src) {
return OPERATOR_CANCELLED;
}
- eObjectMode last_mode = (eObjectMode)ob_src->mode;
+ const eObjectMode last_mode = (eObjectMode)ob_src->mode;
if (!ED_object_mode_compat_test(ob_dst, last_mode)) {
return OPERATOR_CANCELLED;
}
@@ -487,15 +458,19 @@ static int object_switch_object_invoke(bContext *C, wmOperator *op, const wmEven
/* FIXME: Do a single undo push. */
ED_undo_push(C, "Change Active");
- depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
ob_dst_orig = DEG_get_original_object(ob_dst);
ED_object_mode_set_ex(C, last_mode, true, op->reports);
/* Update the viewport rotation origin to the mouse cursor. */
- UnifiedPaintSettings *ups = &CTX_data_tool_settings(C)->unified_paint_settings;
- copy_v3_v3(ups->average_stroke_accum, global_loc);
- ups->average_stroke_counter = 1;
- ups->last_stroke_valid = true;
+ if (last_mode & OB_MODE_ALL_PAINT) {
+ float global_loc[3];
+ if (ED_view3d_autodist_simple(ar, event->mval, global_loc, 0, NULL)) {
+ UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
+ copy_v3_v3(ups->average_stroke_accum, global_loc);
+ ups->average_stroke_counter = 1;
+ ups->last_stroke_valid = true;
+ }
+ }
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
WM_toolsystem_update_from_context_view3d(C);
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index 8fc2bf96639..0d24992671f 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -4375,9 +4375,15 @@ static void screen_animation_region_tag_redraw(ScrArea *area,
//#define PROFILE_AUDIO_SYNCH
-static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
+static int screen_animation_step_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
{
bScreen *screen = CTX_wm_screen(C);
+ wmTimer *wt = screen->animtimer;
+
+ if (!(wt && wt == event->customdata)) {
+ return OPERATOR_PASS_THROUGH;
+ }
+
wmWindow *win = CTX_wm_window(C);
#ifdef PROFILE_AUDIO_SYNCH
@@ -4385,197 +4391,191 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEv
int newfra_int;
#endif
- if (screen->animtimer && screen->animtimer == event->customdata) {
- Main *bmain = CTX_data_main(C);
- Scene *scene = CTX_data_scene(C);
- ViewLayer *view_layer = WM_window_get_active_view_layer(win);
- Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer);
- Scene *scene_eval = (depsgraph != NULL) ? DEG_get_evaluated_scene(depsgraph) : NULL;
- wmTimer *wt = screen->animtimer;
- ScreenAnimData *sad = wt->customdata;
- wmWindowManager *wm = CTX_wm_manager(C);
- int sync;
- double time;
-
- /* sync, don't sync, or follow scene setting */
- if (sad->flag & ANIMPLAY_FLAG_SYNC) {
- sync = 1;
- }
- else if (sad->flag & ANIMPLAY_FLAG_NO_SYNC) {
- sync = 0;
+ Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
+ ViewLayer *view_layer = WM_window_get_active_view_layer(win);
+ Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer);
+ Scene *scene_eval = (depsgraph != NULL) ? DEG_get_evaluated_scene(depsgraph) : NULL;
+ ScreenAnimData *sad = wt->customdata;
+ wmWindowManager *wm = CTX_wm_manager(C);
+ int sync;
+ double time;
+
+ /* sync, don't sync, or follow scene setting */
+ if (sad->flag & ANIMPLAY_FLAG_SYNC) {
+ sync = 1;
+ }
+ else if (sad->flag & ANIMPLAY_FLAG_NO_SYNC) {
+ sync = 0;
+ }
+ else {
+ sync = (scene->flag & SCE_FRAME_DROP);
+ }
+
+ if (scene_eval == NULL) {
+ /* Happens when undo/redo system is used during playback, nothing meaningful we can do here. */
+ }
+ else if (scene_eval->id.recalc & ID_RECALC_AUDIO_SEEK) {
+ /* Ignore seek here, the audio will be updated to the scene frame after jump during next
+ * dependency graph update. */
+ }
+ else if ((scene->audio.flag & AUDIO_SYNC) && (sad->flag & ANIMPLAY_FLAG_REVERSE) == false &&
+ isfinite(time = BKE_sound_sync_scene(scene_eval))) {
+ double newfra = time * FPS;
+
+ /* give some space here to avoid jumps */
+ if (newfra + 0.5 > scene->r.cfra && newfra - 0.5 < scene->r.cfra) {
+ scene->r.cfra++;
}
else {
- sync = (scene->flag & SCE_FRAME_DROP);
+ scene->r.cfra = max_ii(scene->r.cfra, round(newfra));
}
- if (scene_eval == NULL) {
- /* Happens when undo/redo system is used during playback, nothing meaningful we can do
- * here.
- */
+#ifdef PROFILE_AUDIO_SYNCH
+ newfra_int = scene->r.cfra;
+ if (newfra_int < old_frame) {
+ printf("back jump detected, frame %d!\n", newfra_int);
}
- else if (scene_eval->id.recalc & ID_RECALC_AUDIO_SEEK) {
- /* Ignore seek here, the audio will be updated to the scene frame after jump during next
- * dependency graph update. */
+ else if (newfra_int > old_frame + 1) {
+ printf("forward jump detected, frame %d!\n", newfra_int);
}
- else if ((scene->audio.flag & AUDIO_SYNC) && (sad->flag & ANIMPLAY_FLAG_REVERSE) == false &&
- isfinite(time = BKE_sound_sync_scene(scene_eval))) {
- double newfra = time * FPS;
-
- /* give some space here to avoid jumps */
- if (newfra + 0.5 > scene->r.cfra && newfra - 0.5 < scene->r.cfra) {
- scene->r.cfra++;
+ fflush(stdout);
+ old_frame = newfra_int;
+#endif
+ }
+ else {
+ if (sync) {
+ /* Try to keep the playback in realtime by dropping frames. */
+
+ /* How much time (in frames) has passed since the last frame was drawn? */
+ double delta_frames = wt->delta * FPS;
+
+ /* Add the remaining fraction from the last time step. */
+ delta_frames += sad->lagging_frame_count;
+
+ if (delta_frames < 1.0) {
+ /* We can render faster than the scene frame rate. However skipping or delaying frames
+ * here seems to in practice lead to jittery playback so just step forward a minimum of
+ * one frame. (Even though this can lead to too fast playback, the jitteryness is more
+ * annoying)
+ */
+ delta_frames = 1.0f;
+ sad->lagging_frame_count = 0;
}
else {
- scene->r.cfra = max_ii(scene->r.cfra, round(newfra));
+ /* Extract the delta frame fractions that will be skipped when converting to int. */
+ sad->lagging_frame_count = delta_frames - (int)delta_frames;
}
-#ifdef PROFILE_AUDIO_SYNCH
- newfra_int = scene->r.cfra;
- if (newfra_int < old_frame) {
- printf("back jump detected, frame %d!\n", newfra_int);
+ const int step = delta_frames;
+
+ /* skip frames */
+ if (sad->flag & ANIMPLAY_FLAG_REVERSE) {
+ scene->r.cfra -= step;
}
- else if (newfra_int > old_frame + 1) {
- printf("forward jump detected, frame %d!\n", newfra_int);
+ else {
+ scene->r.cfra += step;
}
- fflush(stdout);
- old_frame = newfra_int;
-#endif
}
else {
- if (sync) {
- /* Try to keep the playback in realtime by dropping frames. */
-
- /* How much time (in frames) has passed since the last frame was drawn? */
- double delta_frames = wt->delta * FPS;
-
- /* Add the remaining fraction from the last time step. */
- delta_frames += sad->lagging_frame_count;
-
- if (delta_frames < 1.0) {
- /* We can render faster than the scene frame rate. However skipping or delaying frames
- * here seems to in practice lead to jittery playback so just step forward a minimum of
- * one frame. (Even though this can lead to too fast playback, the jitteryness is more
- * annoying)
- */
- delta_frames = 1.0f;
- sad->lagging_frame_count = 0;
- }
- else {
- /* Extract the delta frame fractions that will be skipped when converting to int. */
- sad->lagging_frame_count = delta_frames - (int)delta_frames;
- }
-
- const int step = delta_frames;
-
- /* skip frames */
- if (sad->flag & ANIMPLAY_FLAG_REVERSE) {
- scene->r.cfra -= step;
- }
- else {
- scene->r.cfra += step;
- }
+ /* one frame +/- */
+ if (sad->flag & ANIMPLAY_FLAG_REVERSE) {
+ scene->r.cfra--;
}
else {
- /* one frame +/- */
- if (sad->flag & ANIMPLAY_FLAG_REVERSE) {
- scene->r.cfra--;
- }
- else {
- scene->r.cfra++;
- }
+ scene->r.cfra++;
}
}
+ }
- /* reset 'jumped' flag before checking if we need to jump... */
- sad->flag &= ~ANIMPLAY_FLAG_JUMPED;
+ /* reset 'jumped' flag before checking if we need to jump... */
+ sad->flag &= ~ANIMPLAY_FLAG_JUMPED;
- if (sad->flag & ANIMPLAY_FLAG_REVERSE) {
- /* jump back to end? */
- if (PRVRANGEON) {
- if (scene->r.cfra < scene->r.psfra) {
- scene->r.cfra = scene->r.pefra;
- sad->flag |= ANIMPLAY_FLAG_JUMPED;
- }
- }
- else {
- if (scene->r.cfra < scene->r.sfra) {
- scene->r.cfra = scene->r.efra;
- sad->flag |= ANIMPLAY_FLAG_JUMPED;
- }
+ if (sad->flag & ANIMPLAY_FLAG_REVERSE) {
+ /* jump back to end? */
+ if (PRVRANGEON) {
+ if (scene->r.cfra < scene->r.psfra) {
+ scene->r.cfra = scene->r.pefra;
+ sad->flag |= ANIMPLAY_FLAG_JUMPED;
}
}
else {
- /* jump back to start? */
- if (PRVRANGEON) {
- if (scene->r.cfra > scene->r.pefra) {
- scene->r.cfra = scene->r.psfra;
- sad->flag |= ANIMPLAY_FLAG_JUMPED;
- }
+ if (scene->r.cfra < scene->r.sfra) {
+ scene->r.cfra = scene->r.efra;
+ sad->flag |= ANIMPLAY_FLAG_JUMPED;
}
- else {
- if (scene->r.cfra > scene->r.efra) {
- scene->r.cfra = scene->r.sfra;
- sad->flag |= ANIMPLAY_FLAG_JUMPED;
- }
+ }
+ }
+ else {
+ /* jump back to start? */
+ if (PRVRANGEON) {
+ if (scene->r.cfra > scene->r.pefra) {
+ scene->r.cfra = scene->r.psfra;
+ sad->flag |= ANIMPLAY_FLAG_JUMPED;
}
}
-
- /* next frame overridden by user action (pressed jump to first/last frame) */
- if (sad->flag & ANIMPLAY_FLAG_USE_NEXT_FRAME) {
- scene->r.cfra = sad->nextfra;
- sad->flag &= ~ANIMPLAY_FLAG_USE_NEXT_FRAME;
- sad->flag |= ANIMPLAY_FLAG_JUMPED;
+ else {
+ if (scene->r.cfra > scene->r.efra) {
+ scene->r.cfra = scene->r.sfra;
+ sad->flag |= ANIMPLAY_FLAG_JUMPED;
+ }
}
+ }
- if (sad->flag & ANIMPLAY_FLAG_JUMPED) {
- DEG_id_tag_update(&scene->id, ID_RECALC_AUDIO_SEEK);
+ /* next frame overridden by user action (pressed jump to first/last frame) */
+ if (sad->flag & ANIMPLAY_FLAG_USE_NEXT_FRAME) {
+ scene->r.cfra = sad->nextfra;
+ sad->flag &= ~ANIMPLAY_FLAG_USE_NEXT_FRAME;
+ sad->flag |= ANIMPLAY_FLAG_JUMPED;
+ }
+
+ if (sad->flag & ANIMPLAY_FLAG_JUMPED) {
+ DEG_id_tag_update(&scene->id, ID_RECALC_AUDIO_SEEK);
#ifdef PROFILE_AUDIO_SYNCH
- old_frame = CFRA;
+ old_frame = CFRA;
#endif
- }
+ }
- /* since we follow drawflags, we can't send notifier but tag regions ourselves */
- if (depsgraph != NULL) {
- ED_update_for_newframe(bmain, depsgraph);
- }
+ /* since we follow drawflags, we can't send notifier but tag regions ourselves */
+ if (depsgraph != NULL) {
+ ED_update_for_newframe(bmain, depsgraph);
+ }
- LISTBASE_FOREACH (wmWindow *, window, &wm->windows) {
- const bScreen *win_screen = WM_window_get_active_screen(window);
+ LISTBASE_FOREACH (wmWindow *, window, &wm->windows) {
+ const bScreen *win_screen = WM_window_get_active_screen(window);
- LISTBASE_FOREACH (ScrArea *, area, &win_screen->areabase) {
- LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
- bool redraw = false;
- if (region == sad->region) {
- redraw = true;
- }
- else if (match_region_with_redraws(
- area, region->regiontype, sad->redraws, sad->from_anim_edit)) {
- redraw = true;
- }
+ LISTBASE_FOREACH (ScrArea *, area, &win_screen->areabase) {
+ LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
+ bool redraw = false;
+ if (region == sad->region) {
+ redraw = true;
+ }
+ else if (match_region_with_redraws(
+ area, region->regiontype, sad->redraws, sad->from_anim_edit)) {
+ redraw = true;
+ }
- if (redraw) {
- screen_animation_region_tag_redraw(area, region, scene, sad->redraws);
- }
+ if (redraw) {
+ screen_animation_region_tag_redraw(area, region, scene, sad->redraws);
}
}
}
+ }
- /* update frame rate info too
- * NOTE: this may not be accurate enough, since we might need this after modifiers/etc.
- * have been calculated instead of just before updates have been done?
- */
- ED_refresh_viewport_fps(C);
+ /* update frame rate info too
+ * NOTE: this may not be accurate enough, since we might need this after modifiers/etc.
+ * have been calculated instead of just before updates have been done?
+ */
+ ED_refresh_viewport_fps(C);
- /* Recalculate the time-step for the timer now that we've finished calculating this,
- * since the frames-per-second value may have been changed.
- */
- /* TODO: this may make evaluation a bit slower if the value doesn't change...
- * any way to avoid this? */
- wt->timestep = (1.0 / FPS);
+ /* Recalculate the time-step for the timer now that we've finished calculating this,
+ * since the frames-per-second value may have been changed.
+ */
+ /* TODO: this may make evaluation a bit slower if the value doesn't change...
+ * any way to avoid this? */
+ wt->timestep = (1.0 / FPS);
- return OPERATOR_FINISHED;
- }
- return OPERATOR_PASS_THROUGH;
+ return OPERATOR_FINISHED;
}
static void SCREEN_OT_animation_step(wmOperatorType *ot)
@@ -4586,7 +4586,7 @@ static void SCREEN_OT_animation_step(wmOperatorType *ot)
ot->idname = "SCREEN_OT_animation_step";
/* api callbacks */
- ot->invoke = screen_animation_step;
+ ot->invoke = screen_animation_step_invoke;
ot->poll = ED_operator_screenactive_norender;
}
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 3ded57d938f..adc62b23559 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -2810,6 +2810,12 @@ void SCULPT_tilt_apply_to_normal(float r_normal[3], StrokeCache *cache, const fl
normalize_v3(r_normal);
}
+void SCULPT_tilt_effective_normal_get(const SculptSession *ss, const Brush *brush, float r_no[3])
+{
+ copy_v3_v3(r_no, ss->cache->sculpt_normal_symm);
+ SCULPT_tilt_apply_to_normal(r_no, ss->cache, brush->tilt_strength_factor);
+}
+
static void update_brush_local_mat(Sculpt *sd, Object *ob)
{
StrokeCache *cache = ob->sculpt->cache;
@@ -3119,8 +3125,9 @@ static void do_draw_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
const float bstrength = ss->cache->bstrength;
/* Offset with as much as possible factored in already. */
- mul_v3_v3fl(offset, ss->cache->sculpt_normal_symm, ss->cache->radius);
- SCULPT_tilt_apply_to_normal(offset, ss->cache, brush->tilt_strength_factor);
+ float effective_normal[3];
+ SCULPT_tilt_effective_normal_get(ss, brush, effective_normal);
+ mul_v3_v3fl(offset, effective_normal, ss->cache->radius);
mul_v3_v3(offset, ss->cache->scale);
mul_v3_fl(offset, bstrength);
@@ -3197,8 +3204,9 @@ static void do_draw_sharp_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int to
const float bstrength = ss->cache->bstrength;
/* Offset with as much as possible factored in already. */
- mul_v3_v3fl(offset, ss->cache->sculpt_normal_symm, ss->cache->radius);
- SCULPT_tilt_apply_to_normal(offset, ss->cache, brush->tilt_strength_factor);
+ float effective_normal[3];
+ SCULPT_tilt_effective_normal_get(ss, brush, effective_normal);
+ mul_v3_v3fl(offset, effective_normal, ss->cache->radius);
mul_v3_v3(offset, ss->cache->scale);
mul_v3_fl(offset, bstrength);
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index 4216f23bea4..6313c934774 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -814,6 +814,9 @@ void SCULPT_tilt_apply_to_normal(float r_normal[3],
struct StrokeCache *cache,
const float tilt_strength);
+/* Get effective surface normal with pen tilt and tilt strength applied to it. */
+void SCULPT_tilt_effective_normal_get(const SculptSession *ss, const Brush *brush, float r_no[3]);
+
/* just for vertex paint. */
bool SCULPT_pbvh_calc_area_normal(const struct Brush *brush,
Object *ob,
diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c
index 7a066adae77..749e61955d9 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -634,22 +634,12 @@ static void image_main_region_draw(const bContext *C, ARegion *region)
{
/* draw entirely, view changes should be handled here */
SpaceImage *sima = CTX_wm_space_image(C);
- Object *obact = CTX_data_active_object(C);
Object *obedit = CTX_data_edit_object(C);
Depsgraph *depsgraph = CTX_data_expect_evaluated_depsgraph(C);
Mask *mask = NULL;
- bool show_uvedit = false;
- bool show_curve = false;
Scene *scene = CTX_data_scene(C);
- ViewLayer *view_layer = CTX_data_view_layer(C);
View2D *v2d = &region->v2d;
- GPUViewport *viewport = WM_draw_region_get_viewport(region);
- GPUFrameBuffer *framebuffer_default, *framebuffer_overlay;
-
- framebuffer_default = GPU_viewport_framebuffer_default_get(viewport);
- framebuffer_overlay = GPU_viewport_framebuffer_overlay_get(viewport);
-
/* XXX not supported yet, disabling for now */
scene->r.scemode &= ~R_COMP_CROP;
@@ -659,82 +649,37 @@ static void image_main_region_draw(const bContext *C, ARegion *region)
image_main_region_set_view2d(sima, region);
/* check for mask (delay draw) */
- if (ED_space_image_show_uvedit(sima, obedit)) {
- show_uvedit = true;
- }
- else if (sima->mode == SI_MODE_MASK) {
+ if (!ED_space_image_show_uvedit(sima, obedit) && sima->mode == SI_MODE_MASK) {
mask = ED_space_image_get_mask(sima);
}
- else if (ED_space_image_paint_curve(C)) {
- show_curve = true;
- }
/* we draw image in pixelspace */
- if (!U.experimental.use_image_editor_legacy_drawing) {
- DRW_draw_view(C);
- draw_image_main_helpers(C, region);
-
- /* Draw Meta data of the image isn't added to the DrawManager as it is
- * used in other areas as well. */
- if (sima->flag & SI_DRAW_METADATA) {
- void *lock;
- /* `ED_space_image_get_zoom` temporarily locks the image, so this needs to be done before
- * the image is locked when calling `ED_space_image_acquire_buffer`. */
- float zoomx, zoomy;
- ED_space_image_get_zoom(sima, region, &zoomx, &zoomy);
- ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock, 0);
- if (ibuf) {
- int x, y;
- rctf frame;
- BLI_rctf_init(&frame, 0.0f, ibuf->x, 0.0f, ibuf->y);
- UI_view2d_view_to_region(&region->v2d, 0.0f, 0.0f, &x, &y);
- ED_region_image_metadata_draw(x, y, ibuf, &frame, zoomx, zoomy);
- ED_space_image_release_buffer(sima, ibuf, lock);
- }
+ DRW_draw_view(C);
+ draw_image_main_helpers(C, region);
+
+ /* Draw Meta data of the image isn't added to the DrawManager as it is
+ * used in other areas as well. */
+ if (sima->flag & SI_DRAW_METADATA) {
+ void *lock;
+ /* `ED_space_image_get_zoom` temporarily locks the image, so this needs to be done before
+ * the image is locked when calling `ED_space_image_acquire_buffer`. */
+ float zoomx, zoomy;
+ ED_space_image_get_zoom(sima, region, &zoomx, &zoomy);
+ ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock, 0);
+ if (ibuf) {
+ int x, y;
+ rctf frame;
+ BLI_rctf_init(&frame, 0.0f, ibuf->x, 0.0f, ibuf->y);
+ UI_view2d_view_to_region(&region->v2d, 0.0f, 0.0f, &x, &y);
+ ED_region_image_metadata_draw(x, y, ibuf, &frame, zoomx, zoomy);
+ ED_space_image_release_buffer(sima, ibuf, lock);
}
-
- /* sample line */
- UI_view2d_view_ortho(v2d);
- draw_image_sample_line(sima);
- UI_view2d_view_restore(C);
}
- else {
- GPU_framebuffer_bind(framebuffer_default);
- GPU_clear_color(0.0f, 0.0f, 0.0f, 0.0f);
-
- GPU_framebuffer_bind(framebuffer_overlay);
-
- float col[3];
- /* clear and setup matrix */
- UI_GetThemeColor3fv(TH_BACK, col);
- srgb_to_linearrgb_v3_v3(col, col);
- GPU_clear_color(col[0], col[1], col[2], 1.0f);
- GPU_depth_test(GPU_DEPTH_NONE);
- draw_image_main(C, region);
-
- /* and uvs in 0.0-1.0 space */
- UI_view2d_view_ortho(v2d);
- ED_region_draw_cb_draw(C, region, REGION_DRAW_PRE_VIEW);
-
- ED_uvedit_draw_main(sima, scene, view_layer, obedit, obact, depsgraph);
-
- ED_region_draw_cb_draw(C, region, REGION_DRAW_POST_VIEW);
-
- if (sima->flag & SI_SHOW_GPENCIL) {
- /* Grease Pencil too (in addition to UV's) */
- draw_image_grease_pencil((bContext *)C, true);
- }
- /* sample line */
- draw_image_sample_line(sima);
-
- UI_view2d_view_restore(C);
-
- if (sima->flag & SI_SHOW_GPENCIL) {
- /* draw Grease Pencil - screen space only */
- draw_image_grease_pencil((bContext *)C, false);
- }
- }
+ /* sample line */
+ UI_view2d_view_ortho(v2d);
+ draw_image_sample_line(sima);
+ UI_view2d_view_restore(C);
if (mask) {
Image *image = ED_space_image(sima);
@@ -773,14 +718,7 @@ static void image_main_region_draw(const bContext *C, ARegion *region)
C);
}
- if ((show_uvedit || mask || show_curve) && U.experimental.use_image_editor_legacy_drawing) {
- UI_view2d_view_ortho(v2d);
- ED_image_draw_cursor(region, sima->cursor);
- UI_view2d_view_restore(C);
- }
-
WM_gizmomap_draw(region->gizmo_map, C, WM_GIZMOMAP_DRAWSTEP_2D);
-
draw_image_cache(C, region);
}
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index af03cddfbf5..633344837a1 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -102,7 +102,7 @@
#define M_GOLDEN_RATIO_CONJUGATE 0.618033988749895f
-#define VIEW3D_OVERLAY_LINEHEIGHT (int)(1.1f * BLF_default_height_max())
+#define VIEW3D_OVERLAY_LINEHEIGHT (0.9f * U.widget_unit)
/* -------------------------------------------------------------------- */
/** \name General Functions
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index 0985d65d5f8..0f0a710a82a 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -1019,10 +1019,10 @@ int view3d_opengl_select(ViewContext *vc,
}
if (is_pick_select) {
- if (is_pick_select && select_mode == VIEW3D_SELECT_PICK_NEAREST) {
+ if (select_mode == VIEW3D_SELECT_PICK_NEAREST) {
gpu_select_mode = GPU_SELECT_PICK_NEAREST;
}
- else if (is_pick_select && select_mode == VIEW3D_SELECT_PICK_ALL) {
+ else if (select_mode == VIEW3D_SELECT_PICK_ALL) {
gpu_select_mode = GPU_SELECT_PICK_ALL;
}
else {
diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c
index 044fca2310c..a4ab9164017 100644
--- a/source/blender/editors/uvedit/uvedit_draw.c
+++ b/source/blender/editors/uvedit/uvedit_draw.c
@@ -21,78 +21,20 @@
* \ingroup eduv
*/
-#include <float.h>
-#include <math.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "MEM_guardedalloc.h"
-
-#include "DNA_material_types.h"
-#include "DNA_mesh_types.h"
-#include "DNA_meshdata_types.h"
-#include "DNA_object_types.h"
-#include "DNA_scene_types.h"
-#include "DNA_screen_types.h"
-#include "DNA_space_types.h"
-
-#include "../../draw/intern/draw_cache_impl.h"
-
#include "BLI_math.h"
-#include "BLI_task.h"
#include "BLI_utildefines.h"
-#include "BKE_deform.h"
-#include "BKE_editmesh.h"
-#include "BKE_layer.h"
-#include "BKE_material.h"
-
-#include "BKE_scene.h"
-
-#include "DEG_depsgraph.h"
-#include "DEG_depsgraph_query.h"
+#include "DNA_scene_types.h"
+#include "DNA_screen_types.h"
+#include "DNA_userdef_types.h"
-#include "GPU_batch.h"
-#include "GPU_framebuffer.h"
#include "GPU_immediate.h"
#include "GPU_matrix.h"
-#include "GPU_state.h"
-
-#include "ED_image.h"
-#include "ED_mesh.h"
-#include "ED_uvedit.h"
#include "UI_interface.h"
-#include "UI_resources.h"
#include "UI_view2d.h"
-#include "uvedit_intern.h"
-
-/* Struct containing the needed batches per object.
- * this optimizes the way how data is requested from
- * the draw manager. */
-typedef struct UVEditGPUBatches {
- Object *ob_eval;
- GPUBatch *faces;
- GPUBatch *edges;
- GPUBatch *verts;
- GPUBatch *facedots;
-} UVEditGPUBatches;
-
-static int draw_uvs_face_check(const ToolSettings *ts)
-{
- /* checks if we are selecting only faces */
- if (ts->uv_flag & UV_SYNC_SELECTION) {
- if (ts->selectmode == SCE_SELECT_FACE) {
- return 2;
- }
- if (ts->selectmode & SCE_SELECT_FACE) {
- return 1;
- }
- return 0;
- }
- return (ts->uv_selectmode == UV_SELECT_FACE);
-}
+#include "ED_uvedit.h"
/* ------------------------- */
@@ -166,434 +108,3 @@ void ED_image_draw_cursor(ARegion *region, const float cursor[2])
GPU_matrix_translate_2f(-cursor[0], -cursor[1]);
}
-
-static void uvedit_get_batches(Object *ob,
- SpaceImage *sima,
- const Scene *scene,
- UVEditGPUBatches *batches,
- float *tot_area,
- float *tot_area_uv)
-{
- float *tmp_tot_area, *tmp_tot_area_uv;
- int drawfaces = draw_uvs_face_check(scene->toolsettings);
- const bool draw_stretch = (sima->flag & SI_DRAW_STRETCH) != 0;
- const bool draw_faces = (sima->flag & SI_NO_DRAWFACES) == 0;
-
- DRW_mesh_batch_cache_validate(ob->data);
- batches->edges = DRW_mesh_batch_cache_get_edituv_edges(ob->data);
- batches->verts = DRW_mesh_batch_cache_get_edituv_verts(ob->data);
-
- if (drawfaces) {
- batches->facedots = DRW_mesh_batch_cache_get_edituv_facedots(ob->data);
- }
- else {
- batches->facedots = NULL;
- }
-
- if (draw_stretch && (sima->dt_uvstretch == SI_UVDT_STRETCH_AREA)) {
- batches->faces = DRW_mesh_batch_cache_get_edituv_faces_stretch_area(
- ob->data, &tmp_tot_area, &tmp_tot_area_uv);
- }
- else if (draw_stretch) {
- batches->faces = DRW_mesh_batch_cache_get_edituv_faces_stretch_angle(ob->data);
- }
- else if (draw_faces) {
- batches->faces = DRW_mesh_batch_cache_get_edituv_faces(ob->data);
- }
- else {
- batches->faces = NULL;
- }
- struct TaskGraph *task_graph = BLI_task_graph_create();
- DRW_mesh_batch_cache_create_requested(task_graph, ob, ob->data, scene, false, false);
- BLI_task_graph_work_and_wait(task_graph);
- BLI_task_graph_free(task_graph);
-
- if (draw_stretch && (sima->dt_uvstretch == SI_UVDT_STRETCH_AREA)) {
- /* after create_requested we can load the actual areas */
- *tot_area += *tmp_tot_area;
- *tot_area_uv += *tmp_tot_area_uv;
- }
-}
-
-static void draw_uvs_shadow(SpaceImage *sima,
- const Scene *scene,
- Object *obedit,
- Depsgraph *depsgraph)
-{
- Object *ob_eval = DEG_get_evaluated_object(depsgraph, obedit);
- Mesh *me = ob_eval->data;
- const float overlay_alpha = sima->uv_opacity;
- float col[4];
- UI_GetThemeColor4fv(TH_UV_SHADOW, col);
-
- DRW_mesh_batch_cache_validate(me);
- GPUBatch *edges = DRW_mesh_batch_cache_get_uv_edges(me);
-
- struct TaskGraph *task_graph = BLI_task_graph_create();
- DRW_mesh_batch_cache_create_requested(task_graph, ob_eval, me, scene, false, false);
- BLI_task_graph_work_and_wait(task_graph);
- BLI_task_graph_free(task_graph);
-
- if (edges) {
- if (sima->flag & SI_SMOOTH_UV) {
- GPU_line_smooth(true);
- GPU_blend(GPU_BLEND_ALPHA);
- }
- else if (overlay_alpha < 1.0f) {
- GPU_blend(GPU_BLEND_ALPHA);
- }
-
- col[3] = overlay_alpha;
- GPU_batch_program_set_builtin(edges, GPU_SHADER_2D_UV_UNIFORM_COLOR);
- GPU_batch_uniform_4fv(edges, "color", col);
- GPU_batch_draw(edges);
-
- if (sima->flag & SI_SMOOTH_UV) {
- GPU_line_smooth(false);
- GPU_blend(GPU_BLEND_NONE);
- }
- else if (overlay_alpha < 1.0f) {
- GPU_blend(GPU_BLEND_NONE);
- }
- }
-}
-
-static void draw_uvs_texpaint(const Scene *scene, Object *ob, Depsgraph *depsgraph)
-{
- Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
- Mesh *me = ob_eval->data;
- const ToolSettings *ts = scene->toolsettings;
- float col[4];
- UI_GetThemeColor4fv(TH_UV_SHADOW, col);
-
- if (me->mloopuv == NULL) {
- return;
- }
-
- DRW_mesh_batch_cache_validate(me);
- GPUBatch *geom = DRW_mesh_batch_cache_get_uv_edges(me);
- struct TaskGraph *task_graph = BLI_task_graph_create();
- DRW_mesh_batch_cache_create_requested(task_graph, ob_eval, me, scene, false, false);
- BLI_task_graph_work_and_wait(task_graph);
- BLI_task_graph_free(task_graph);
-
- GPU_batch_program_set_builtin(geom, GPU_SHADER_2D_UV_UNIFORM_COLOR);
- GPU_batch_uniform_4fv(geom, "color", col);
-
- const bool do_material_masking = (ts->uv_flag & UV_SHOW_SAME_IMAGE);
- if (do_material_masking && me->mloopuv) {
- /* Render loops that have the active material. Minize draw calls. */
- MPoly *mpoly = me->mpoly;
- uint draw_start = 0;
- uint idx = 0;
- bool prev_ma_match = (mpoly->mat_nr == (ob_eval->actcol - 1));
-
- /* TODO(fclem): If drawcall count becomes a problem in the future
- * we can use multi draw indirect drawcalls for this.
- * (not implemented in GPU module at the time of writing). */
- for (int a = 0; a < me->totpoly; a++, mpoly++) {
- bool ma_match = (mpoly->mat_nr == (ob_eval->actcol - 1));
- if (ma_match != prev_ma_match) {
- if (ma_match == false) {
- GPU_batch_draw_range(geom, draw_start, idx - draw_start);
- }
- else {
- draw_start = idx;
- }
- }
- idx += mpoly->totloop + 1;
- prev_ma_match = ma_match;
- }
- if (prev_ma_match == true) {
- GPU_batch_draw_range(geom, draw_start, idx - draw_start);
- }
- }
- else {
- GPU_batch_draw(geom);
- }
-}
-
-/* draws uv's in the image space */
-static void draw_uvs(SpaceImage *sima,
- const Scene *scene,
- Depsgraph *depsgraph,
- UVEditGPUBatches *batch,
- float tot_area_ratio,
- float tot_area_ratio_inv)
-{
- Object *ob_eval = batch->ob_eval;
- const ToolSettings *ts = scene->toolsettings;
- float col1[4], col2[4], col3[4], transparent[4] = {0.0f, 0.0f, 0.0f, 0.0f};
- const float overlay_alpha = sima->uv_opacity;
-
- if (sima->flag & SI_DRAWSHADOW) {
- bool is_cage_like_final_meshes = false;
- Mesh *me = (Mesh *)ob_eval->data;
- BMEditMesh *embm = me->edit_mesh;
- is_cage_like_final_meshes = embm && embm->mesh_eval_final &&
- embm->mesh_eval_final->runtime.is_original;
-
- /* When sync selection is enabled, all faces are drawn (except for hidden)
- * so if cage is the same as the final, there is no point in drawing this. */
- if (!((ts->uv_flag & UV_SYNC_SELECTION) && is_cage_like_final_meshes)) {
- draw_uvs_shadow(sima, scene, ob_eval, depsgraph);
- }
- }
-
- bool interpedges;
- bool draw_stretch = (sima->flag & SI_DRAW_STRETCH) != 0;
- if (ts->uv_flag & UV_SYNC_SELECTION) {
- interpedges = (ts->selectmode & SCE_SELECT_VERTEX) != 0;
- }
- else {
- interpedges = (ts->uv_selectmode == UV_SELECT_VERTEX);
- }
-
- GPU_blend(GPU_BLEND_ALPHA);
-
- if (batch->faces) {
- GPU_batch_program_set_builtin(batch->faces,
- (draw_stretch) ? (sima->dt_uvstretch == SI_UVDT_STRETCH_AREA) ?
- GPU_SHADER_2D_UV_FACES_STRETCH_AREA :
- GPU_SHADER_2D_UV_FACES_STRETCH_ANGLE :
- GPU_SHADER_2D_UV_FACES);
-
- if (!draw_stretch) {
- GPU_blend(GPU_BLEND_ALPHA);
-
- UI_GetThemeColor4fv(TH_FACE, col1);
- UI_GetThemeColor4fv(TH_FACE_SELECT, col2);
- UI_GetThemeColor4fv(TH_EDITMESH_ACTIVE, col3);
-
- col1[3] *= overlay_alpha;
- col2[3] *= overlay_alpha;
- col3[3] *= overlay_alpha;
-
- GPU_batch_uniform_4fv(batch->faces, "faceColor", col1);
- GPU_batch_uniform_4fv(batch->faces, "selectColor", col2);
- GPU_batch_uniform_4fv(batch->faces, "activeColor", col3);
- }
- else if (sima->dt_uvstretch == SI_UVDT_STRETCH_ANGLE) {
- float asp[2];
- ED_space_image_get_uv_aspect(sima, &asp[0], &asp[1]);
- GPU_batch_uniform_2fv(batch->faces, "aspect", asp);
- }
- else if (sima->dt_uvstretch == SI_UVDT_STRETCH_AREA) {
- GPU_batch_uniform_1f(batch->faces, "totalAreaRatio", tot_area_ratio);
- GPU_batch_uniform_1f(batch->faces, "totalAreaRatioInv", tot_area_ratio_inv);
- }
-
- GPU_batch_draw(batch->faces);
-
- if (!draw_stretch) {
- GPU_blend(GPU_BLEND_NONE);
- }
- }
- if (batch->edges) {
- if (sima->flag & SI_SMOOTH_UV) {
- GPU_line_smooth(true);
- GPU_blend(GPU_BLEND_ALPHA);
- }
- else if (overlay_alpha < 1.0f) {
- GPU_blend(GPU_BLEND_ALPHA);
- }
-
- {
- /* We could modify the vbo's data filling
- * instead of modifying the provoking vert. */
- GPU_provoking_vertex(GPU_VERTEX_FIRST);
-
- UI_GetThemeColor3fv(TH_EDGE_SELECT, col2);
- col2[3] = overlay_alpha;
-
- const float dash_width = (sima->dt_uv == SI_UVDT_DASH) ? (4.0f * UI_DPI_FAC) : 9999.0f;
- eGPUBuiltinShader shader = (interpedges) ? GPU_SHADER_2D_UV_EDGES_SMOOTH :
- GPU_SHADER_2D_UV_EDGES;
-#ifdef __APPLE__
- if (sima->dt_uv == SI_UVDT_OUTLINE) {
- /* Apple drivers do not support wide line. This is a workaround awaiting the 2D view
- * refactor. Limiting to OSX since this will slow down the drawing. (see T76806) */
- GPU_batch_program_set_builtin(batch->edges, GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR);
-
- float viewport[4];
- GPU_viewport_size_get_f(viewport);
-
- /* No U.pixelsize scaling for now since the inner line is not scalled. */
- GPU_batch_uniform_1f(batch->edges, "lineWidth", 2.0f);
- GPU_batch_uniform_4f(batch->edges, "color", 0.0f, 0.0f, 0.0f, 1.0f);
- GPU_batch_uniform_2fv(batch->edges, "viewportSize", &viewport[2]);
-
- GPU_batch_draw(batch->edges);
- }
-#endif
-
- GPU_batch_program_set_builtin(batch->edges, shader);
-
- if (sima->dt_uv == SI_UVDT_OUTLINE) {
-#ifndef __APPLE__
- /* Black Outline. */
- GPU_line_width(3.0f);
- GPU_batch_uniform_4f(batch->edges, "edgeColor", 0.0f, 0.0f, 0.0f, overlay_alpha);
- GPU_batch_uniform_4f(batch->edges, "selectColor", 0.0f, 0.0f, 0.0f, overlay_alpha);
- GPU_batch_uniform_1f(batch->edges, "dashWidth", dash_width);
- GPU_batch_draw(batch->edges);
-#endif
- UI_GetThemeColor3fv(TH_WIRE_EDIT, col1);
- }
- else if (sima->dt_uv == SI_UVDT_BLACK) {
- copy_v3_fl3(col1, 0.0f, 0.0f, 0.0f);
- }
- else {
- copy_v3_fl3(col1, 1.0f, 1.0f, 1.0f);
- }
- col1[3] = overlay_alpha;
-
- GPU_batch_program_set_builtin(batch->edges, shader);
-
- /* Inner Line. Use depth test to insure selection is drawn on top. */
- GPU_depth_test(GPU_DEPTH_LESS_EQUAL);
- GPU_line_width(1.0f);
- GPU_batch_uniform_4fv(batch->edges, "edgeColor", col1);
- GPU_batch_uniform_4fv(batch->edges, "selectColor", col2);
- GPU_batch_uniform_1f(batch->edges, "dashWidth", dash_width);
- GPU_batch_draw(batch->edges);
- GPU_depth_test(GPU_DEPTH_NONE);
-
- GPU_provoking_vertex(GPU_VERTEX_LAST);
- }
-
- if (sima->flag & SI_SMOOTH_UV) {
- GPU_line_smooth(false);
- GPU_blend(GPU_BLEND_NONE);
- }
- else if (overlay_alpha < 1.0f) {
- GPU_blend(GPU_BLEND_NONE);
- }
- }
-
- if (batch->verts || batch->facedots) {
- UI_GetThemeColor4fv(TH_VERTEX_SELECT, col2);
- if (batch->verts) {
- const float point_size = UI_GetThemeValuef(TH_VERTEX_SIZE);
- const float pinned_col[4] = {1.0f, 0.0f, 0.0f, 1.0f}; /* TODO Theme? */
- UI_GetThemeColor4fv(TH_VERTEX, col1);
- GPU_blend(GPU_BLEND_ALPHA);
- GPU_program_point_size(true);
-
- GPU_batch_program_set_builtin(batch->verts, GPU_SHADER_2D_UV_VERTS);
- GPU_batch_uniform_4f(batch->verts, "vertColor", col1[0], col1[1], col1[2], 1.0f);
- GPU_batch_uniform_4fv(batch->verts, "selectColor", transparent);
- GPU_batch_uniform_4fv(batch->verts, "pinnedColor", pinned_col);
- GPU_batch_uniform_1f(batch->verts, "pointSize", (point_size + 1.5f) * M_SQRT2);
- GPU_batch_uniform_1f(batch->verts, "outlineWidth", 0.75f);
-
- /* #GPU_batch_draw_advanced is needed as unbinding the shader and redrawing
- * causes the vertices not to draw at the right size. */
- GPU_shader_bind(batch->verts->shader);
-
- GPU_batch_draw_advanced(batch->verts, 0, 0, 0, 0);
-
- /* We have problem in this mode when face order make some verts
- * appear unselected because an adjacent face is not selected and
- * render after the selected face.
- * So, to avoid sorting verts by state we just render selected verts
- * on top. A bit overkill but it's simple. */
- GPU_batch_uniform_4fv(batch->verts, "vertColor", transparent);
- GPU_batch_uniform_4fv(batch->verts, "selectColor", col2);
-
- GPU_batch_draw_advanced(batch->verts, 0, 0, 0, 0);
-
- GPU_shader_unbind();
- /* Finish #GPU_batch_draw_advanced drawing. */
-
- GPU_blend(GPU_BLEND_NONE);
- GPU_program_point_size(false);
- }
- if (batch->facedots) {
- const float point_size = UI_GetThemeValuef(TH_FACEDOT_SIZE);
- GPU_point_size(point_size);
-
- UI_GetThemeColor4fv(TH_WIRE, col1);
- GPU_batch_program_set_builtin(batch->facedots, GPU_SHADER_2D_UV_FACEDOTS);
- GPU_batch_uniform_4fv(batch->facedots, "vertColor", col1);
- GPU_batch_uniform_4fv(batch->facedots, "selectColor", col2);
- GPU_batch_draw(batch->facedots);
- }
- }
-}
-
-static void draw_uv_shadows_get(
- SpaceImage *sima, Object *ob, Object *obedit, bool *r_show_shadow, bool *r_show_texpaint)
-{
- *r_show_shadow = *r_show_texpaint = false;
-
- if (ED_space_image_show_render(sima) || (sima->flag & SI_NO_DRAW_TEXPAINT)) {
- return;
- }
-
- if ((sima->mode == SI_MODE_PAINT) && obedit && obedit->type == OB_MESH) {
- struct BMEditMesh *em = BKE_editmesh_from_object(obedit);
-
- *r_show_shadow = EDBM_uv_check(em);
- }
-
- *r_show_texpaint = (ob && ob->type == OB_MESH && ob->mode == OB_MODE_TEXTURE_PAINT);
-}
-
-void ED_uvedit_draw_main(SpaceImage *sima,
- const Scene *scene,
- ViewLayer *view_layer,
- Object *obedit,
- Object *obact,
- Depsgraph *depsgraph)
-{
- bool show_uvedit, show_uvshadow, show_texpaint_uvshadow;
-
- show_uvedit = ED_space_image_show_uvedit(sima, obedit);
- draw_uv_shadows_get(sima, obact, obedit, &show_uvshadow, &show_texpaint_uvshadow);
-
- if (show_uvedit || show_uvshadow || show_texpaint_uvshadow) {
- if (show_uvshadow) {
- draw_uvs_shadow(sima, scene, obedit, depsgraph);
- }
- else if (show_uvedit) {
- uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(
- view_layer, ((View3D *)NULL), &objects_len);
- if (objects_len > 0) {
- GPU_depth_mask(true);
- GPU_clear_depth(1.0f);
- }
-
- /* go over all objects and create the batches + add their areas to the total */
- UVEditGPUBatches *batches = MEM_mallocN(sizeof(UVEditGPUBatches) * objects_len, __func__);
- float tot_area = 0.0f;
- float tot_area_uv = 0.0f;
- float tot_area_ratio = 0.0f;
- float tot_area_ratio_inv = 0.0f;
-
- for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
- Object *ob_iter = objects[ob_index];
- Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob_iter);
- batches[ob_index].ob_eval = ob_eval;
- uvedit_get_batches(ob_eval, sima, scene, &batches[ob_index], &tot_area, &tot_area_uv);
- }
-
- if (tot_area > FLT_EPSILON && tot_area_uv > FLT_EPSILON) {
- tot_area_ratio = tot_area / tot_area_uv;
- tot_area_ratio_inv = tot_area_uv / tot_area;
- }
-
- /* go over all batches created in the previous loop and draw them */
- for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
- UVEditGPUBatches *batch = &batches[ob_index];
- draw_uvs(sima, scene, depsgraph, batch, tot_area_ratio, tot_area_ratio_inv);
- }
- MEM_freeN(batches);
- MEM_freeN(objects);
- }
- else {
- draw_uvs_texpaint(scene, obact, depsgraph);
- }
- }
-}
diff --git a/source/blender/io/alembic/intern/abc_reader_object.cc b/source/blender/io/alembic/intern/abc_reader_object.cc
index 1e832de1f47..707241ca17f 100644
--- a/source/blender/io/alembic/intern/abc_reader_object.cc
+++ b/source/blender/io/alembic/intern/abc_reader_object.cc
@@ -44,10 +44,7 @@ using Alembic::AbcGeom::IXformSchema;
namespace blender::io::alembic {
AbcObjectReader::AbcObjectReader(const IObject &object, ImportSettings &settings)
- : m_name(""),
- m_object_name(""),
- m_data_name(""),
- m_object(NULL),
+ : m_object(NULL),
m_iobject(object),
m_settings(&settings),
m_min_time(std::numeric_limits<chrono_t>::max()),
diff --git a/source/blender/makesdna/DNA_fluid_defaults.h b/source/blender/makesdna/DNA_fluid_defaults.h
index 14ea874a674..2ee83cf3387 100644
--- a/source/blender/makesdna/DNA_fluid_defaults.h
+++ b/source/blender/makesdna/DNA_fluid_defaults.h
@@ -109,6 +109,7 @@
.particle_radius = 1.0f, \
.particle_band_width = 3.0f, \
.fractions_threshold = 0.05f, \
+ .fractions_distance = 0.5f, \
.flip_ratio = 0.97f, \
.sys_particle_maximum = 0, \
.simulation_method = FLUID_DOMAIN_METHOD_FLIP, \
diff --git a/source/blender/makesdna/DNA_fluid_types.h b/source/blender/makesdna/DNA_fluid_types.h
index afb2a294605..2786d4df868 100644
--- a/source/blender/makesdna/DNA_fluid_types.h
+++ b/source/blender/makesdna/DNA_fluid_types.h
@@ -586,10 +586,11 @@ typedef struct FluidDomainSettings {
float particle_radius;
float particle_band_width;
float fractions_threshold;
+ float fractions_distance;
float flip_ratio;
int sys_particle_maximum;
short simulation_method;
- char _pad4[2];
+ char _pad4[6];
/* Diffusion options. */
float surface_tension;
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index be02e450412..7785c700e1c 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -1169,7 +1169,7 @@ typedef enum eSpaceImage_Flag {
* in the image view, it's unrelated to UDIM tiles.
*/
SI_DRAW_TILE = (1 << 19),
- SI_SMOOTH_UV = (1 << 20),
+ SI_FLAG_UNUSED_20 = (1 << 20), /* cleared */
SI_DRAW_STRETCH = (1 << 21),
SI_SHOW_GPENCIL = (1 << 22),
SI_FLAG_UNUSED_23 = (1 << 23), /* cleared */
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index 954da51e3bf..1f39e803f12 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -626,7 +626,6 @@ typedef struct UserDef_Experimental {
/* Debug options, always available. */
char use_undo_legacy;
char use_cycles_debug;
- char use_image_editor_legacy_drawing;
char SANITIZE_AFTER_HERE;
/* The following options are automatically sanitized (set to 0)
* when the release cycle is not alpha. */
@@ -636,7 +635,7 @@ typedef struct UserDef_Experimental {
char use_tools_missing_icons;
char use_switch_object_operator;
char use_sculpt_tools_tilt;
- char _pad[6];
+ char _pad[7];
/** `makesdna` does not allow empty structs. */
} UserDef_Experimental;
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index 8096c6d7d10..6b92c99df87 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -1145,13 +1145,13 @@ char *RNA_path_from_real_ID_to_struct(struct Main *bmain, PointerRNA *ptr, struc
char *RNA_path_from_ID_to_property(PointerRNA *ptr, PropertyRNA *prop);
char *RNA_path_from_ID_to_property_index(PointerRNA *ptr,
PropertyRNA *prop,
- int array_dim,
+ int index_dim,
int index);
char *RNA_path_from_real_ID_to_property_index(struct Main *bmain,
PointerRNA *ptr,
PropertyRNA *prop,
- int array_dim,
+ int index_dim,
int index,
struct ID **r_real_id);
@@ -1301,14 +1301,14 @@ char *RNA_pointer_as_string(struct bContext *C,
PointerRNA *ptr_prop);
char *RNA_pointer_as_string_keywords_ex(struct bContext *C,
PointerRNA *ptr,
- const bool skip_optional_value,
+ const bool as_function,
const bool all_args,
const bool nested_args,
const int max_prop_length,
PropertyRNA *iterprop);
char *RNA_pointer_as_string_keywords(struct bContext *C,
PointerRNA *ptr,
- const bool skip_optional_value,
+ const bool as_function,
const bool all_args,
const bool nested_args,
const int max_prop_length);
diff --git a/source/blender/makesrna/RNA_define.h b/source/blender/makesrna/RNA_define.h
index de8e13875a6..272246d75d3 100644
--- a/source/blender/makesrna/RNA_define.h
+++ b/source/blender/makesrna/RNA_define.h
@@ -66,7 +66,7 @@ void RNA_def_struct_flag(StructRNA *srna, int flag);
void RNA_def_struct_clear_flag(StructRNA *srna, int flag);
void RNA_def_struct_property_tags(StructRNA *srna, const EnumPropertyItem *prop_tag_defines);
void RNA_def_struct_refine_func(StructRNA *srna, const char *refine);
-void RNA_def_struct_idprops_func(StructRNA *srna, const char *refine);
+void RNA_def_struct_idprops_func(StructRNA *srna, const char *idproperties);
void RNA_def_struct_register_funcs(StructRNA *srna,
const char *reg,
const char *unreg,
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
index fa589597111..bd762bd5357 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -239,10 +239,8 @@ static int replace_if_different(const char *tmpfile, const char *dep_files[])
if (cmp) {
REN_IF_DIFF;
}
- else {
- remove(tmpfile);
- return 0;
- }
+ remove(tmpfile);
+ return 0;
#undef REN_IF_DIFF
}
@@ -254,7 +252,7 @@ static const char *rna_safe_id(const char *id)
if (STREQ(id, "default")) {
return "default_value";
}
- else if (STREQ(id, "operator")) {
+ if (STREQ(id, "operator")) {
return "operator_value";
}
else if (STREQ(id, "new")) {
@@ -286,14 +284,14 @@ static int cmp_property(const void *a, const void *b)
if (STREQ(propa->identifier, "rna_type")) {
return -1;
}
- else if (STREQ(propb->identifier, "rna_type")) {
+ if (STREQ(propb->identifier, "rna_type")) {
return 1;
}
if (STREQ(propa->identifier, "name")) {
return -1;
}
- else if (STREQ(propb->identifier, "name")) {
+ if (STREQ(propb->identifier, "name")) {
return 1;
}
@@ -551,9 +549,7 @@ static const char *rna_parameter_type_name(PropertyRNA *parm)
if (parm->flag_parameter & PARM_RNAPTR) {
return "PointerRNA";
}
- else {
- return rna_find_dna_type((const char *)pparm->type);
- }
+ return rna_find_dna_type((const char *)pparm->type);
}
case PROP_COLLECTION: {
return "CollectionListBase";
@@ -2270,9 +2266,7 @@ static const char *rna_parameter_type_cpp_name(PropertyRNA *prop)
return (const char *)pprop->type;
}
- else {
- return rna_parameter_type_name(prop);
- }
+ return rna_parameter_type_name(prop);
}
static void rna_def_struct_function_prototype_cpp(FILE *f,
@@ -3206,9 +3200,7 @@ static const char *rna_property_subtypename(PropertySubType type)
if (RNA_SUBTYPE_UNIT(type)) {
return rna_property_subtypename(type & ~RNA_SUBTYPE_UNIT(type));
}
- else {
- return "PROP_SUBTYPE_UNKNOWN";
- }
+ return "PROP_SUBTYPE_UNKNOWN";
}
}
}
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index 15a4a4e740e..a631fe4fc26 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -132,9 +132,7 @@ void RNA_id_pointer_create(ID *id, PointerRNA *r_ptr)
if (type == idtype) {
break;
}
- else {
- idtype = type;
- }
+ idtype = type;
}
}
@@ -166,9 +164,7 @@ void RNA_pointer_create(ID *id, StructRNA *type, void *data, PointerRNA *r_ptr)
if (rtype == r_ptr->type) {
break;
}
- else {
- r_ptr->type = rtype;
- }
+ r_ptr->type = rtype;
}
}
}
@@ -209,15 +205,11 @@ PointerRNA rna_pointer_inherit_refine(PointerRNA *ptr, StructRNA *type, void *da
if (type == result.type) {
break;
}
- else {
- result.type = type;
- }
+ result.type = type;
}
return result;
}
- else {
- return PointerRNA_NULL;
- }
+ return PointerRNA_NULL;
}
void RNA_pointer_recast(PointerRNA *ptr, PointerRNA *r_ptr)
@@ -399,14 +391,12 @@ IDProperty *rna_idproperty_find(PointerRNA *ptr, const char *name)
if (group->type == IDP_GROUP) {
return IDP_GetPropertyFromGroup(group, name);
}
- else {
- /* Not sure why that happens sometimes, with nested properties... */
- /* Seems to be actually array prop, name is usually "0"... To be sorted out later. */
+ /* Not sure why that happens sometimes, with nested properties... */
+ /* Seems to be actually array prop, name is usually "0"... To be sorted out later. */
#if 0
printf(
"Got unexpected IDProp container when trying to retrieve %s: %d\n", name, group->type);
#endif
- }
}
return NULL;
@@ -430,15 +420,13 @@ static int rna_ensure_property_array_length(PointerRNA *ptr, PropertyRNA *prop)
int arraylen[RNA_MAX_ARRAY_DIMENSION];
return (prop->getlength && ptr->data) ? prop->getlength(ptr, arraylen) : prop->totarraylength;
}
- else {
- IDProperty *idprop = (IDProperty *)prop;
+ IDProperty *idprop = (IDProperty *)prop;
- if (idprop->type == IDP_ARRAY) {
- return idprop->len;
- }
- else {
- return 0;
- }
+ if (idprop->type == IDP_ARRAY) {
+ return idprop->len;
+ }
+ else {
+ return 0;
}
}
@@ -447,11 +435,9 @@ static bool rna_ensure_property_array_check(PropertyRNA *prop)
if (prop->magic == RNA_MAGIC) {
return (prop->getlength || prop->totarraylength);
}
- else {
- IDProperty *idprop = (IDProperty *)prop;
+ IDProperty *idprop = (IDProperty *)prop;
- return (idprop->type == IDP_ARRAY);
- }
+ return (idprop->type == IDP_ARRAY);
}
static void rna_ensure_property_multi_array_length(PointerRNA *ptr,
@@ -675,9 +661,7 @@ PropertyRNA *rna_ensure_property(PropertyRNA *prop)
if (idprop->type == IDP_ARRAY) {
return arraytypemap[(int)(idprop->subtype)];
}
- else {
- return typemap[(int)(idprop->type)];
- }
+ return typemap[(int)(idprop->type)];
}
}
@@ -686,9 +670,7 @@ static const char *rna_ensure_property_identifier(const PropertyRNA *prop)
if (prop->magic == RNA_MAGIC) {
return prop->identifier;
}
- else {
- return ((const IDProperty *)prop)->name;
- }
+ return ((const IDProperty *)prop)->name;
}
static const char *rna_ensure_property_description(const PropertyRNA *prop)
@@ -758,9 +740,7 @@ int RNA_struct_ui_icon(const StructRNA *type)
if (type) {
return type->icon;
}
- else {
- return ICON_DOT;
- }
+ return ICON_DOT;
}
const char *RNA_struct_ui_description(const StructRNA *type)
@@ -1107,9 +1087,7 @@ bool RNA_struct_available_or_report(ReportList *reports, const char *identifier)
MEM_freeN(result);
return false;
}
- else {
- return true;
- }
+ return true;
}
bool RNA_struct_bl_idname_ok_or_report(ReportList *reports,
@@ -1279,15 +1257,15 @@ char RNA_property_array_item_char(PropertyRNA *prop, int index)
if ((index < 4) && ELEM(subtype, PROP_QUATERNION, PROP_AXISANGLE)) {
return quatitem[index];
}
- else if ((index < 4) && ELEM(subtype,
- PROP_TRANSLATION,
- PROP_DIRECTION,
- PROP_XYZ,
- PROP_XYZ_LENGTH,
- PROP_EULER,
- PROP_VELOCITY,
- PROP_ACCELERATION,
- PROP_COORDS)) {
+ if ((index < 4) && ELEM(subtype,
+ PROP_TRANSLATION,
+ PROP_DIRECTION,
+ PROP_XYZ,
+ PROP_XYZ_LENGTH,
+ PROP_EULER,
+ PROP_VELOCITY,
+ PROP_ACCELERATION,
+ PROP_COORDS)) {
return vectoritem[index];
}
else if ((index < 4) && ELEM(subtype, PROP_COLOR, PROP_COLOR_GAMMA)) {
@@ -1551,7 +1529,7 @@ int RNA_property_float_clamp(PointerRNA *ptr, PropertyRNA *prop, float *value)
*value = min;
return -1;
}
- else if (*value > max) {
+ if (*value > max) {
*value = max;
return 1;
}
@@ -1570,7 +1548,7 @@ int RNA_property_int_clamp(PointerRNA *ptr, PropertyRNA *prop, int *value)
*value = min;
return -1;
}
- else if (*value > max) {
+ if (*value > max) {
*value = max;
return 1;
}
@@ -1597,7 +1575,7 @@ StructRNA *RNA_property_pointer_type(PointerRNA *ptr, PropertyRNA *prop)
if (pprop->typef) {
return pprop->typef(ptr);
}
- else if (pprop->type) {
+ if (pprop->type) {
return pprop->type;
}
}
@@ -1624,9 +1602,7 @@ bool RNA_property_pointer_poll(PointerRNA *ptr, PropertyRNA *prop, PointerRNA *v
if (rna_idproperty_check(&prop, ptr)) {
return ((PropPointerPollFuncPy)pprop->poll)(ptr, *value, prop);
}
- else {
- return pprop->poll(ptr, *value);
- }
+ return pprop->poll(ptr, *value);
}
return 1;
@@ -1859,9 +1835,7 @@ bool RNA_enum_identifier(const EnumPropertyItem *item, const int value, const ch
*r_identifier = item[i].identifier;
return true;
}
- else {
- return false;
- }
+ return false;
}
int RNA_enum_bitflag_identifiers(const EnumPropertyItem *item,
@@ -1885,9 +1859,7 @@ bool RNA_enum_name(const EnumPropertyItem *item, const int value, const char **r
*r_name = item[i].name;
return true;
}
- else {
- return false;
- }
+ return false;
}
bool RNA_enum_description(const EnumPropertyItem *item,
@@ -1899,9 +1871,7 @@ bool RNA_enum_description(const EnumPropertyItem *item,
*r_description = item[i].description;
return true;
}
- else {
- return false;
- }
+ return false;
}
int RNA_enum_from_identifier(const EnumPropertyItem *item, const char *identifier)
@@ -2620,16 +2590,14 @@ bool RNA_property_boolean_get_default_index(PointerRNA *ptr, PropertyRNA *prop,
RNA_property_boolean_get_default_array(ptr, prop, tmp);
return tmp[index];
}
- else {
- bool *tmparray, value;
+ bool *tmparray, value;
- tmparray = MEM_mallocN(sizeof(bool) * len, __func__);
- RNA_property_boolean_get_default_array(ptr, prop, tmparray);
- value = tmparray[index];
- MEM_freeN(tmparray);
+ tmparray = MEM_mallocN(sizeof(bool) * len, __func__);
+ RNA_property_boolean_get_default_array(ptr, prop, tmparray);
+ value = tmparray[index];
+ MEM_freeN(tmparray);
- return value;
- }
+ return value;
}
int RNA_property_int_get(PointerRNA *ptr, PropertyRNA *prop)
@@ -2643,7 +2611,7 @@ int RNA_property_int_get(PointerRNA *ptr, PropertyRNA *prop)
if ((idprop = rna_idproperty_check(&prop, ptr))) {
return IDP_Int(idprop);
}
- else if (iprop->get) {
+ if (iprop->get) {
return iprop->get(ptr);
}
else if (iprop->get_ex) {
@@ -2800,16 +2768,14 @@ int RNA_property_int_get_index(PointerRNA *ptr, PropertyRNA *prop, int index)
RNA_property_int_get_array(ptr, prop, tmp);
return tmp[index];
}
- else {
- int *tmparray, value;
+ int *tmparray, value;
- tmparray = MEM_mallocN(sizeof(int) * len, __func__);
- RNA_property_int_get_array(ptr, prop, tmparray);
- value = tmparray[index];
- MEM_freeN(tmparray);
+ tmparray = MEM_mallocN(sizeof(int) * len, __func__);
+ RNA_property_int_get_array(ptr, prop, tmparray);
+ value = tmparray[index];
+ MEM_freeN(tmparray);
- return value;
- }
+ return value;
}
void RNA_property_int_set_array(PointerRNA *ptr, PropertyRNA *prop, const int *values)
@@ -2912,9 +2878,7 @@ bool RNA_property_int_set_default(PointerRNA *ptr, PropertyRNA *prop, int value)
};
return rna_idproperty_ui_set_default(ptr, prop, IDP_INT, &val);
}
- else {
- return rna_idproperty_ui_set_default(ptr, prop, IDP_INT, NULL);
- }
+ return rna_idproperty_ui_set_default(ptr, prop, IDP_INT, NULL);
}
void RNA_property_int_get_default_array(PointerRNA *ptr, PropertyRNA *prop, int *values)
@@ -2962,16 +2926,14 @@ int RNA_property_int_get_default_index(PointerRNA *ptr, PropertyRNA *prop, int i
RNA_property_int_get_default_array(ptr, prop, tmp);
return tmp[index];
}
- else {
- int *tmparray, value;
+ int *tmparray, value;
- tmparray = MEM_mallocN(sizeof(int) * len, __func__);
- RNA_property_int_get_default_array(ptr, prop, tmparray);
- value = tmparray[index];
- MEM_freeN(tmparray);
+ tmparray = MEM_mallocN(sizeof(int) * len, __func__);
+ RNA_property_int_get_default_array(ptr, prop, tmparray);
+ value = tmparray[index];
+ MEM_freeN(tmparray);
- return value;
- }
+ return value;
}
float RNA_property_float_get(PointerRNA *ptr, PropertyRNA *prop)
@@ -2986,9 +2948,7 @@ float RNA_property_float_get(PointerRNA *ptr, PropertyRNA *prop)
if (idprop->type == IDP_FLOAT) {
return IDP_Float(idprop);
}
- else {
- return (float)IDP_Double(idprop);
- }
+ return (float)IDP_Double(idprop);
}
else if (fprop->get) {
return fprop->get(ptr);
@@ -3159,16 +3119,14 @@ float RNA_property_float_get_index(PointerRNA *ptr, PropertyRNA *prop, int index
RNA_property_float_get_array(ptr, prop, tmp);
return tmp[index];
}
- else {
- float *tmparray, value;
+ float *tmparray, value;
- tmparray = MEM_mallocN(sizeof(float) * len, __func__);
- RNA_property_float_get_array(ptr, prop, tmparray);
- value = tmparray[index];
- MEM_freeN(tmparray);
+ tmparray = MEM_mallocN(sizeof(float) * len, __func__);
+ RNA_property_float_get_array(ptr, prop, tmparray);
+ value = tmparray[index];
+ MEM_freeN(tmparray);
- return value;
- }
+ return value;
}
void RNA_property_float_set_array(PointerRNA *ptr, PropertyRNA *prop, const float *values)
@@ -3285,9 +3243,7 @@ bool RNA_property_float_set_default(PointerRNA *ptr, PropertyRNA *prop, float va
};
return rna_idproperty_ui_set_default(ptr, prop, IDP_DOUBLE, &val);
}
- else {
- return rna_idproperty_ui_set_default(ptr, prop, IDP_DOUBLE, NULL);
- }
+ return rna_idproperty_ui_set_default(ptr, prop, IDP_DOUBLE, NULL);
}
void RNA_property_float_get_default_array(PointerRNA *ptr, PropertyRNA *prop, float *values)
@@ -3341,16 +3297,14 @@ float RNA_property_float_get_default_index(PointerRNA *ptr, PropertyRNA *prop, i
RNA_property_float_get_default_array(ptr, prop, tmp);
return tmp[index];
}
- else {
- float *tmparray, value;
+ float *tmparray, value;
- tmparray = MEM_mallocN(sizeof(float) * len, __func__);
- RNA_property_float_get_default_array(ptr, prop, tmparray);
- value = tmparray[index];
- MEM_freeN(tmparray);
+ tmparray = MEM_mallocN(sizeof(float) * len, __func__);
+ RNA_property_float_get_default_array(ptr, prop, tmparray);
+ value = tmparray[index];
+ MEM_freeN(tmparray);
- return value;
- }
+ return value;
}
void RNA_property_string_get(PointerRNA *ptr, PropertyRNA *prop, char *value)
@@ -3429,13 +3383,11 @@ int RNA_property_string_length(PointerRNA *ptr, PropertyRNA *prop)
if (idprop->subtype == IDP_STRING_SUB_BYTE) {
return idprop->len;
}
- else {
#ifndef NDEBUG
- /* these _must_ stay in sync */
- BLI_assert(strlen(IDP_String(idprop)) == idprop->len - 1);
+ /* these _must_ stay in sync */
+ BLI_assert(strlen(IDP_String(idprop)) == idprop->len - 1);
#endif
- return idprop->len - 1;
- }
+ return idprop->len - 1;
}
else if (sprop->length) {
return sprop->length(ptr);
@@ -3600,7 +3552,7 @@ int RNA_property_enum_get(PointerRNA *ptr, PropertyRNA *prop)
if ((idprop = rna_idproperty_check(&prop, ptr))) {
return IDP_Int(idprop);
}
- else if (eprop->get) {
+ if (eprop->get) {
return eprop->get(ptr);
}
else if (eprop->get_ex) {
@@ -3717,9 +3669,7 @@ PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop)
if (pprop->typef) {
return rna_pointer_inherit_refine(ptr, pprop->typef(ptr), idprop);
}
- else {
- return rna_pointer_inherit_refine(ptr, pprop->type, idprop);
- }
+ return rna_pointer_inherit_refine(ptr, pprop->type, idprop);
}
else if (pprop->get) {
return pprop->get(ptr);
@@ -3971,7 +3921,7 @@ int RNA_property_collection_length(PointerRNA *ptr, PropertyRNA *prop)
if ((idprop = rna_idproperty_check(&prop, ptr))) {
return idprop->len;
}
- else if (cprop->length) {
+ if (cprop->length) {
return cprop->length(ptr);
}
else {
@@ -4146,7 +4096,7 @@ bool RNA_property_collection_remove(PointerRNA *ptr, PropertyRNA *prop, int key)
return true;
}
- else if (prop->flag & PROP_IDPROPERTY) {
+ if (prop->flag & PROP_IDPROPERTY) {
return true;
}
@@ -4210,7 +4160,7 @@ bool RNA_property_collection_move(PointerRNA *ptr, PropertyRNA *prop, int key, i
return true;
}
- else if (prop->flag & PROP_IDPROPERTY) {
+ if (prop->flag & PROP_IDPROPERTY) {
return true;
}
@@ -4269,9 +4219,7 @@ int RNA_property_collection_lookup_index(PointerRNA *ptr, PropertyRNA *prop, Poi
if (iter.valid) {
return index;
}
- else {
- return -1;
- }
+ return -1;
}
int RNA_property_collection_lookup_int(PointerRNA *ptr,
@@ -4287,26 +4235,24 @@ int RNA_property_collection_lookup_int(PointerRNA *ptr,
/* we have a callback defined, use it */
return cprop->lookupint(ptr, key, r_ptr);
}
- else {
- /* no callback defined, just iterate and find the nth item */
- CollectionPropertyIterator iter;
- int i;
-
- RNA_property_collection_begin(ptr, prop, &iter);
- for (i = 0; iter.valid; RNA_property_collection_next(&iter), i++) {
- if (i == key) {
- *r_ptr = iter.ptr;
- break;
- }
- }
- RNA_property_collection_end(&iter);
+ /* no callback defined, just iterate and find the nth item */
+ CollectionPropertyIterator iter;
+ int i;
- if (!iter.valid) {
- memset(r_ptr, 0, sizeof(*r_ptr));
+ RNA_property_collection_begin(ptr, prop, &iter);
+ for (i = 0; iter.valid; RNA_property_collection_next(&iter), i++) {
+ if (i == key) {
+ *r_ptr = iter.ptr;
+ break;
}
+ }
+ RNA_property_collection_end(&iter);
- return iter.valid;
+ if (!iter.valid) {
+ memset(r_ptr, 0, sizeof(*r_ptr));
}
+
+ return iter.valid;
}
int RNA_property_collection_lookup_string_index(
@@ -4320,49 +4266,47 @@ int RNA_property_collection_lookup_string_index(
/* we have a callback defined, use it */
return cprop->lookupstring(ptr, key, r_ptr);
}
- else {
- /* no callback defined, compare with name properties if they exist */
- CollectionPropertyIterator iter;
- PropertyRNA *nameprop;
- char name[256], *nameptr;
- int found = 0;
- int keylen = strlen(key);
- int namelen;
- int index = 0;
-
- RNA_property_collection_begin(ptr, prop, &iter);
- for (; iter.valid; RNA_property_collection_next(&iter), index++) {
- if (iter.ptr.data && iter.ptr.type->nameproperty) {
- nameprop = iter.ptr.type->nameproperty;
+ /* no callback defined, compare with name properties if they exist */
+ CollectionPropertyIterator iter;
+ PropertyRNA *nameprop;
+ char name[256], *nameptr;
+ int found = 0;
+ int keylen = strlen(key);
+ int namelen;
+ int index = 0;
- nameptr = RNA_property_string_get_alloc(&iter.ptr, nameprop, name, sizeof(name), &namelen);
+ RNA_property_collection_begin(ptr, prop, &iter);
+ for (; iter.valid; RNA_property_collection_next(&iter), index++) {
+ if (iter.ptr.data && iter.ptr.type->nameproperty) {
+ nameprop = iter.ptr.type->nameproperty;
- if ((keylen == namelen) && STREQ(nameptr, key)) {
- *r_ptr = iter.ptr;
- found = 1;
- }
+ nameptr = RNA_property_string_get_alloc(&iter.ptr, nameprop, name, sizeof(name), &namelen);
- if ((char *)&name != nameptr) {
- MEM_freeN(nameptr);
- }
+ if ((keylen == namelen) && STREQ(nameptr, key)) {
+ *r_ptr = iter.ptr;
+ found = 1;
+ }
- if (found) {
- break;
- }
+ if ((char *)&name != nameptr) {
+ MEM_freeN(nameptr);
}
- }
- RNA_property_collection_end(&iter);
- if (!iter.valid) {
- memset(r_ptr, 0, sizeof(*r_ptr));
- *r_index = -1;
- }
- else {
- *r_index = index;
+ if (found) {
+ break;
+ }
}
+ }
+ RNA_property_collection_end(&iter);
- return iter.valid;
+ if (!iter.valid) {
+ memset(r_ptr, 0, sizeof(*r_ptr));
+ *r_index = -1;
+ }
+ else {
+ *r_index = index;
}
+
+ return iter.valid;
}
int RNA_property_collection_lookup_string(PointerRNA *ptr,
@@ -5240,7 +5184,7 @@ static bool rna_path_parse_array_index(const char **path,
return false;
}
/* check for "" to see if it is a string */
- else if (rna_token_strip_quotes(token)) {
+ if (rna_token_strip_quotes(token)) {
temp_index = RNA_property_array_item_index(prop, *(token + 1));
}
else {
@@ -5809,44 +5753,42 @@ static char *rna_idp_path(PointerRNA *ptr,
path = rna_idp_path_create(&link);
break;
}
- else {
- if (iter->type == IDP_GROUP) {
- /* ensure this is RNA */
- PropertyRNA *prop = RNA_struct_find_property(ptr, iter->name);
- if (prop && prop->type == PROP_POINTER) {
- PointerRNA child_ptr = RNA_property_pointer_get(ptr, prop);
- link.name = iter->name;
- link.index = -1;
- if ((path = rna_idp_path(&child_ptr, iter, needle, &link))) {
- break;
- }
+ if (iter->type == IDP_GROUP) {
+ /* ensure this is RNA */
+ PropertyRNA *prop = RNA_struct_find_property(ptr, iter->name);
+ if (prop && prop->type == PROP_POINTER) {
+ PointerRNA child_ptr = RNA_property_pointer_get(ptr, prop);
+ link.name = iter->name;
+ link.index = -1;
+ if ((path = rna_idp_path(&child_ptr, iter, needle, &link))) {
+ break;
}
}
- else if (iter->type == IDP_IDPARRAY) {
- PropertyRNA *prop = RNA_struct_find_property(ptr, iter->name);
- if (prop && prop->type == PROP_COLLECTION) {
- IDProperty *array = IDP_IDPArray(iter);
- if (needle >= array && needle < (iter->len + array)) { /* found! */
- link.name = iter->name;
- link.index = (int)(needle - array);
- path = rna_idp_path_create(&link);
- break;
- }
- else {
- int j;
- link.name = iter->name;
- for (j = 0; j < iter->len; j++, array++) {
- PointerRNA child_ptr;
- if (RNA_property_collection_lookup_int(ptr, prop, j, &child_ptr)) {
- link.index = j;
- if ((path = rna_idp_path(&child_ptr, array, needle, &link))) {
- break;
- }
+ }
+ else if (iter->type == IDP_IDPARRAY) {
+ PropertyRNA *prop = RNA_struct_find_property(ptr, iter->name);
+ if (prop && prop->type == PROP_COLLECTION) {
+ IDProperty *array = IDP_IDPArray(iter);
+ if (needle >= array && needle < (iter->len + array)) { /* found! */
+ link.name = iter->name;
+ link.index = (int)(needle - array);
+ path = rna_idp_path_create(&link);
+ break;
+ }
+ else {
+ int j;
+ link.name = iter->name;
+ for (j = 0; j < iter->len; j++, array++) {
+ PointerRNA child_ptr;
+ if (RNA_property_collection_lookup_int(ptr, prop, j, &child_ptr)) {
+ link.index = j;
+ if ((path = rna_idp_path(&child_ptr, array, needle, &link))) {
+ break;
}
}
- if (path) {
- break;
- }
+ }
+ if (path) {
+ break;
}
}
}
@@ -5870,9 +5812,7 @@ char *RNA_path_from_struct_to_idproperty(PointerRNA *ptr, IDProperty *needle)
if (haystack) { /* can fail when called on bones */
return rna_idp_path(ptr, haystack, needle, NULL);
}
- else {
- return NULL;
- }
+ return NULL;
}
static char *rna_path_from_ID_to_idpgroup(PointerRNA *ptr)
@@ -5954,9 +5894,7 @@ static char *rna_prepend_real_ID_path(Main *bmain, ID *id, char *path, ID **r_re
MEM_freeN(path);
return new_path;
}
- else {
- return prefix[0] != '\0' ? BLI_strdup(prefix) : NULL;
- }
+ return prefix[0] != '\0' ? BLI_strdup(prefix) : NULL;
}
char *RNA_path_from_ID_to_struct(PointerRNA *ptr)
@@ -6351,10 +6289,8 @@ bool RNA_boolean_get(PointerRNA *ptr, const char *name)
if (prop) {
return RNA_property_boolean_get(ptr, prop);
}
- else {
- printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name);
- return 0;
- }
+ printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name);
+ return 0;
}
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
@@ -6400,10 +6336,8 @@ int RNA_int_get(PointerRNA *ptr, const char *name)
if (prop) {
return RNA_property_int_get(ptr, prop);
}
- else {
- printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name);
- return 0;
- }
+ printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name);
+ return 0;
}
void RNA_int_set(PointerRNA *ptr, const char *name, int value)
@@ -6449,10 +6383,8 @@ float RNA_float_get(PointerRNA *ptr, const char *name)
if (prop) {
return RNA_property_float_get(ptr, prop);
}
- else {
- printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name);
- return 0;
- }
+ printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name);
+ return 0;
}
void RNA_float_set(PointerRNA *ptr, const char *name, float value)
@@ -6498,10 +6430,8 @@ int RNA_enum_get(PointerRNA *ptr, const char *name)
if (prop) {
return RNA_property_enum_get(ptr, prop);
}
- else {
- printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name);
- return 0;
- }
+ printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name);
+ return 0;
}
void RNA_enum_set(PointerRNA *ptr, const char *name, int value)
@@ -6561,10 +6491,8 @@ bool RNA_enum_is_equal(bContext *C, PointerRNA *ptr, const char *name, const cha
printf("%s: %s.%s item %s not found.\n", __func__, ptr->type->identifier, name, enumname);
return false;
}
- else {
- printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name);
- return false;
- }
+ printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name);
+ return false;
}
bool RNA_enum_value_from_id(const EnumPropertyItem *item, const char *identifier, int *r_value)
@@ -6574,9 +6502,7 @@ bool RNA_enum_value_from_id(const EnumPropertyItem *item, const char *identifier
*r_value = item[i].value;
return true;
}
- else {
- return false;
- }
+ return false;
}
bool RNA_enum_id_from_value(const EnumPropertyItem *item, int value, const char **r_identifier)
@@ -6586,9 +6512,7 @@ bool RNA_enum_id_from_value(const EnumPropertyItem *item, int value, const char
*r_identifier = item[i].identifier;
return true;
}
- else {
- return false;
- }
+ return false;
}
bool RNA_enum_icon_from_value(const EnumPropertyItem *item, int value, int *r_icon)
@@ -6598,9 +6522,7 @@ bool RNA_enum_icon_from_value(const EnumPropertyItem *item, int value, int *r_ic
*r_icon = item[i].icon;
return true;
}
- else {
- return false;
- }
+ return false;
}
bool RNA_enum_name_from_value(const EnumPropertyItem *item, int value, const char **r_name)
@@ -6610,9 +6532,7 @@ bool RNA_enum_name_from_value(const EnumPropertyItem *item, int value, const cha
*r_name = item[i].name;
return true;
}
- else {
- return false;
- }
+ return false;
}
void RNA_string_get(PointerRNA *ptr, const char *name, char *value)
@@ -6636,10 +6556,8 @@ char *RNA_string_get_alloc(PointerRNA *ptr, const char *name, char *fixedbuf, in
/* TODO, pass length */
return RNA_property_string_get_alloc(ptr, prop, fixedbuf, fixedlen, NULL);
}
- else {
- printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name);
- return NULL;
- }
+ printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name);
+ return NULL;
}
int RNA_string_length(PointerRNA *ptr, const char *name)
@@ -6649,10 +6567,8 @@ int RNA_string_length(PointerRNA *ptr, const char *name)
if (prop) {
return RNA_property_string_length(ptr, prop);
}
- else {
- printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name);
- return 0;
- }
+ printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name);
+ return 0;
}
void RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
@@ -6674,11 +6590,9 @@ PointerRNA RNA_pointer_get(PointerRNA *ptr, const char *name)
if (prop) {
return RNA_property_pointer_get(ptr, prop);
}
- else {
- printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name);
+ printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name);
- return PointerRNA_NULL;
- }
+ return PointerRNA_NULL;
}
void RNA_pointer_set(PointerRNA *ptr, const char *name, PointerRNA ptr_value)
@@ -6748,10 +6662,8 @@ int RNA_collection_length(PointerRNA *ptr, const char *name)
if (prop) {
return RNA_property_collection_length(ptr, prop);
}
- else {
- printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name);
- return 0;
- }
+ printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name);
+ return 0;
}
bool RNA_property_is_set_ex(PointerRNA *ptr, PropertyRNA *prop, bool use_ghost)
@@ -6761,9 +6673,7 @@ bool RNA_property_is_set_ex(PointerRNA *ptr, PropertyRNA *prop, bool use_ghost)
IDProperty *idprop = rna_idproperty_find(ptr, prop->identifier);
return ((idprop != NULL) && (use_ghost == false || !(idprop->flag & IDP_FLAG_GHOST)));
}
- else {
- return true;
- }
+ return true;
}
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
@@ -6773,9 +6683,7 @@ bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
IDProperty *idprop = rna_idproperty_find(ptr, prop->identifier);
return ((idprop != NULL) && !(idprop->flag & IDP_FLAG_GHOST));
}
- else {
- return true;
- }
+ return true;
}
void RNA_property_unset(PointerRNA *ptr, PropertyRNA *prop)
@@ -6793,11 +6701,9 @@ bool RNA_struct_property_is_set_ex(PointerRNA *ptr, const char *identifier, bool
if (prop) {
return RNA_property_is_set_ex(ptr, prop, use_ghost);
}
- else {
- /* python raises an error */
- /* printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name); */
- return 0;
- }
+ /* python raises an error */
+ /* printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name); */
+ return 0;
}
bool RNA_struct_property_is_set(PointerRNA *ptr, const char *identifier)
@@ -6807,11 +6713,9 @@ bool RNA_struct_property_is_set(PointerRNA *ptr, const char *identifier)
if (prop) {
return RNA_property_is_set(ptr, prop);
}
- else {
- /* python raises an error */
- /* printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name); */
- return 0;
- }
+ /* python raises an error */
+ /* printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name); */
+ return 0;
}
void RNA_struct_property_unset(PointerRNA *ptr, const char *identifier)
@@ -6835,9 +6739,7 @@ bool RNA_property_is_unlink(PropertyRNA *prop)
if (RNA_property_type(prop) == PROP_STRING) {
return (flag & PROP_NEVER_UNLINK) == 0;
}
- else {
- return (flag & (PROP_NEVER_UNLINK | PROP_NEVER_NULL)) == 0;
- }
+ return (flag & (PROP_NEVER_UNLINK | PROP_NEVER_NULL)) == 0;
}
/* string representation of a property, python
@@ -6883,7 +6785,7 @@ static char *rna_pointer_as_string__bldata(Main *bmain, PointerRNA *ptr)
if (ptr->type == NULL || ptr->owner_id == NULL) {
return BLI_strdup("None");
}
- else if (RNA_struct_is_ID(ptr->type)) {
+ if (RNA_struct_is_ID(ptr->type)) {
return RNA_path_full_ID_py(bmain, ptr->owner_id);
}
else {
@@ -6900,7 +6802,7 @@ char *RNA_pointer_as_string(bContext *C,
if (ptr_prop->data == NULL) {
return BLI_strdup("None");
}
- else if ((prop = rna_idproperty_check(&prop_ptr, ptr)) && prop->type != IDP_ID) {
+ if ((prop = rna_idproperty_check(&prop_ptr, ptr)) && prop->type != IDP_ID) {
return RNA_pointer_as_string_id(C, ptr_prop);
}
else {
@@ -7970,7 +7872,7 @@ int RNA_function_call_direct_va(bContext *C,
retdata = iter.data;
continue;
}
- else if (flag_parameter & PARM_OUTPUT) {
+ if (flag_parameter & PARM_OUTPUT) {
continue;
}
@@ -8307,9 +8209,7 @@ bool RNA_path_resolved_create(PointerRNA *ptr,
return true;
}
- else {
- return false;
- }
+ return false;
}
static char rna_struct_state_owner[64];
diff --git a/source/blender/makesrna/intern/rna_access_compare_override.c b/source/blender/makesrna/intern/rna_access_compare_override.c
index 202864a7d82..562738efdaa 100644
--- a/source/blender/makesrna/intern/rna_access_compare_override.c
+++ b/source/blender/makesrna/intern/rna_access_compare_override.c
@@ -80,11 +80,9 @@ bool RNA_property_overridable_get(PointerRNA *ptr, PropertyRNA *prop)
return !(prop->flag_override & PROPOVERRIDE_NO_COMPARISON) &&
(prop->flag_override & PROPOVERRIDE_OVERRIDABLE_LIBRARY);
}
- else {
- /* If this is a real 'pure' IDProp (aka custom property), we want to use the IDProp flag. */
- IDProperty *idprop = (IDProperty *)prop;
- return (idprop->flag & IDP_FLAG_OVERRIDABLE_LIBRARY) != 0;
- }
+ /* If this is a real 'pure' IDProp (aka custom property), we want to use the IDProp flag. */
+ IDProperty *idprop = (IDProperty *)prop;
+ return (idprop->flag & IDP_FLAG_OVERRIDABLE_LIBRARY) != 0;
}
/* Should only be used for custom properties */
@@ -124,14 +122,14 @@ bool RNA_property_comparable(PointerRNA *UNUSED(ptr), PropertyRNA *prop)
}
static bool rna_property_override_operation_apply(Main *bmain,
- PointerRNA *ptr_local,
- PointerRNA *ptr_override,
+ PointerRNA *ptr_dst,
+ PointerRNA *ptr_src,
PointerRNA *ptr_storage,
- PropertyRNA *prop_local,
- PropertyRNA *prop_override,
+ PropertyRNA *prop_dst,
+ PropertyRNA *prop_src,
PropertyRNA *prop_storage,
- PointerRNA *ptr_item_local,
- PointerRNA *ptr_item_override,
+ PointerRNA *ptr_item_dst,
+ PointerRNA *ptr_item_src,
PointerRNA *ptr_item_storage,
IDOverrideLibraryPropertyOperation *opop);
@@ -208,7 +206,7 @@ bool RNA_struct_equals(Main *bmain, PointerRNA *ptr_a, PointerRNA *ptr_b, eRNACo
if (ptr_a == NULL && ptr_b == NULL) {
return true;
}
- else if (ptr_a == NULL || ptr_b == NULL) {
+ if (ptr_a == NULL || ptr_b == NULL) {
return false;
}
else if (ptr_a->type != ptr_b->type) {
diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c
index 875c5398488..8eb964b8c17 100644
--- a/source/blender/makesrna/intern/rna_define.c
+++ b/source/blender/makesrna/intern/rna_define.c
@@ -500,7 +500,7 @@ static int rna_find_sdna_member(SDNA *sdna,
return 1;
}
- else if (cmp == 2) {
+ if (cmp == 2) {
smember->type = "";
smember->name = dnaname;
smember->offset = *offset;
@@ -1885,7 +1885,7 @@ void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item
DefRNA.error = true;
break;
}
- else if (item[i].value == eprop->defaultvalue) {
+ if (item[i].value == eprop->defaultvalue) {
defaultfound = 1;
}
}
@@ -2182,7 +2182,7 @@ static PropertyDefRNA *rna_def_property_sdna(PropertyRNA *prop,
if (DefRNA.silent) {
return NULL;
}
- else if (!DefRNA.verify) {
+ if (!DefRNA.verify) {
/* some basic values to survive even with sdna info */
dp->dnastructname = structname;
dp->dnaname = propname;
@@ -4269,7 +4269,7 @@ void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
ret->identifier);
return;
}
- else if (ret->arraydimension) {
+ if (ret->arraydimension) {
CLOG_ERROR(&LOG,
"\"%s.%s\", arrays are not allowed as strict returns, "
"use RNA_def_function_output instead.",
@@ -4357,9 +4357,7 @@ int rna_parameter_size(PropertyRNA *parm)
if (parm->flag & PROP_THICK_WRAP) {
return sizeof(PointerRNA);
}
- else {
- return sizeof(PointerRNA *);
- }
+ return sizeof(PointerRNA *);
}
else {
return sizeof(void *);
diff --git a/source/blender/makesrna/intern/rna_fluid.c b/source/blender/makesrna/intern/rna_fluid.c
index 84187786c46..60eed60ace1 100644
--- a/source/blender/makesrna/intern/rna_fluid.c
+++ b/source/blender/makesrna/intern/rna_fluid.c
@@ -1895,12 +1895,22 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna)
RNA_def_property_range(prop, 0.001, 1.0);
RNA_def_property_ui_range(prop, 0.01, 1.0, 0.05, -1);
RNA_def_property_ui_text(prop,
- "Obstacle-Fluid Threshold",
+ "Obstacle Threshold",
"Determines how much fluid is allowed in an obstacle cell "
"(higher values will tag a boundary cell as an obstacle easier "
"and reduce the boundary smoothening effect)");
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
+ prop = RNA_def_property(srna, "fractions_distance", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_range(prop, -5.0, 5.0);
+ RNA_def_property_ui_range(prop, 0.01, 5.0, 0.1, -1);
+ RNA_def_property_ui_text(prop,
+ "Obstacle Distance",
+ "Determines how far apart fluid and obstacle are (higher values will "
+ "result in fluid being further away from obstacles, smaller values "
+ "will let fluid move towards the inside of obstacles)");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
+
prop = RNA_def_property(srna, "sys_particle_maximum", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "sys_particle_maximum");
RNA_def_property_range(prop, 0, INT_MAX);
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 5b34281ffa0..d3c7787586f 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -2923,11 +2923,6 @@ static void rna_def_space_image_uv(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Display As", "Display style for UV edges");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL);
- prop = RNA_def_property(srna, "show_smooth_edges", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_SMOOTH_UV);
- RNA_def_property_ui_text(prop, "Display Smooth Edges", "Display UV edges anti-aliased");
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL);
-
prop = RNA_def_property(srna, "show_stretch", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_DRAW_STRETCH);
RNA_def_property_ui_text(
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index 74edc3b9a44..91660342d10 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -6170,11 +6170,6 @@ static void rna_def_userdef_experimental(BlenderRNA *brna)
RNA_def_property_ui_text(
prop, "Switch Object Operator", "Enable the operator to switch objects by pressing D");
- prop = RNA_def_property(srna, "use_image_editor_legacy_drawing", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "use_image_editor_legacy_drawing", 1);
- RNA_def_property_ui_text(
- prop, "Image Editor Legacy Drawing", "Use legacy UV/Image editor drawing");
-
prop = RNA_def_property(srna, "use_tools_missing_icons", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "use_tools_missing_icons", 1);
RNA_def_property_ui_text(prop, "Tools with Missing Icons", "Show tools with missing icons");
diff --git a/source/blender/modifiers/intern/MOD_mesh_to_volume.cc b/source/blender/modifiers/intern/MOD_mesh_to_volume.cc
index 2e45ac66cff..cc16da0fa80 100644
--- a/source/blender/modifiers/intern/MOD_mesh_to_volume.cc
+++ b/source/blender/modifiers/intern/MOD_mesh_to_volume.cc
@@ -176,6 +176,7 @@ static void panelRegister(ARegionType *region_type)
modifier_panel_register(region_type, eModifierType_MeshToVolume, panel_draw);
}
+#ifdef WITH_OPENVDB
static float compute_voxel_size(const ModifierEvalContext *ctx,
const MeshToVolumeModifierData *mvmd,
const blender::float4x4 &transform)
@@ -202,6 +203,7 @@ static float compute_voxel_size(const ModifierEvalContext *ctx,
const float voxel_size = approximate_volume_side_length / mvmd->voxel_amount / volume_simplify;
return voxel_size;
}
+#endif
static Volume *modifyVolume(ModifierData *md, const ModifierEvalContext *ctx, Volume *input_volume)
{
@@ -272,7 +274,6 @@ static Volume *modifyVolume(ModifierData *md, const ModifierEvalContext *ctx, Vo
#else
UNUSED_VARS(md, ctx);
- UNUSED_VARS(compute_voxel_size);
BKE_modifier_set_error(md, "Compiled without OpenVDB");
return input_volume;
#endif
diff --git a/source/blender/render/intern/source/render_result.c b/source/blender/render/intern/source/render_result.c
index d2f21ab035c..db75cb5cfed 100644
--- a/source/blender/render/intern/source/render_result.c
+++ b/source/blender/render/intern/source/render_result.c
@@ -444,15 +444,6 @@ RenderResult *render_result_new(Render *re,
if (view_layer->passflag & SCE_PASS_SUBSURFACE_COLOR) {
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_SUBSURFACE_COLOR, view, "RGB");
}
- if (view_layer->eevee.render_passes & EEVEE_RENDER_PASS_BLOOM) {
- RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_BLOOM, view, "RGB");
- }
- if (view_layer->eevee.render_passes & EEVEE_RENDER_PASS_VOLUME_SCATTER) {
- RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_VOLUME_SCATTER, view, "RGB");
- }
- if (view_layer->eevee.render_passes & EEVEE_RENDER_PASS_VOLUME_TRANSMITTANCE) {
- RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_VOLUME_TRANSMITTANCE, view, "RGB");
- }
#undef RENDER_LAYER_ADD_PASS_SAFE
}
}
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h
index acd72a4b1fd..b23446e0dce 100644
--- a/source/blender/windowmanager/WM_types.h
+++ b/source/blender/windowmanager/WM_types.h
@@ -498,6 +498,11 @@ typedef struct wmGesture {
uint is_active_prev : 1;
/** Use for gestures that support both immediate or delayed activation. */
uint wait_for_input : 1;
+ /** Use for gestures that can be moved, like box selection */
+ uint move : 1;
+ /** For gestures that support snapping, stores if snapping is enabled using the modal keymap
+ * toggle. */
+ uint use_snap : 1;
/**
* customdata
diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c
index 6d36000abb4..ae8b78876c2 100644
--- a/source/blender/windowmanager/intern/wm_gesture.c
+++ b/source/blender/windowmanager/intern/wm_gesture.c
@@ -62,6 +62,7 @@ wmGesture *WM_gesture_new(wmWindow *window, const ARegion *region, const wmEvent
gesture->winrct = region->winrct;
gesture->user_data.use_free = true; /* Free if userdata is set. */
gesture->modal_state = GESTURE_MODAL_NOP;
+ gesture->move = false;
if (ELEM(type,
WM_GESTURE_RECT,
diff --git a/source/blender/windowmanager/intern/wm_gesture_ops.c b/source/blender/windowmanager/intern/wm_gesture_ops.c
index 2c79b1f2215..8357d4c2331 100644
--- a/source/blender/windowmanager/intern/wm_gesture_ops.c
+++ b/source/blender/windowmanager/intern/wm_gesture_ops.c
@@ -32,6 +32,7 @@
#include "DNA_windowmanager_types.h"
#include "BLI_math.h"
+#include "BLI_rect.h"
#include "BKE_context.h"
@@ -45,6 +46,8 @@
#include "ED_screen.h"
#include "ED_select_utils.h"
+#include "UI_interface.h"
+
#include "RNA_access.h"
#include "RNA_define.h"
@@ -204,31 +207,23 @@ int WM_gesture_box_modal(bContext *C, wmOperator *op, const wmEvent *event)
wmGesture *gesture = op->customdata;
rcti *rect = gesture->customdata;
- if (event->type == MOUSEMOVE) {
- if (gesture->type == WM_GESTURE_CROSS_RECT && gesture->is_active == false) {
- rect->xmin = rect->xmax = event->x - gesture->winrct.xmin;
- rect->ymin = rect->ymax = event->y - gesture->winrct.ymin;
- }
- else {
- rect->xmax = event->x - gesture->winrct.xmin;
- rect->ymax = event->y - gesture->winrct.ymin;
- }
- gesture_box_apply_rect(op);
-
- wm_gesture_tag_redraw(win);
- }
- else if (event->type == EVT_MODAL_MAP) {
+ if (event->type == EVT_MODAL_MAP) {
switch (event->val) {
- case GESTURE_MODAL_BEGIN:
+ case GESTURE_MODAL_MOVE: {
+ gesture->move = !gesture->move;
+ break;
+ }
+ case GESTURE_MODAL_BEGIN: {
if (gesture->type == WM_GESTURE_CROSS_RECT && gesture->is_active == false) {
gesture->is_active = true;
wm_gesture_tag_redraw(win);
}
break;
+ }
case GESTURE_MODAL_SELECT:
case GESTURE_MODAL_DESELECT:
case GESTURE_MODAL_IN:
- case GESTURE_MODAL_OUT:
+ case GESTURE_MODAL_OUT: {
if (gesture->wait_for_input) {
gesture->modal_state = event->val;
}
@@ -238,24 +233,47 @@ int WM_gesture_box_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
gesture_modal_end(C, op);
return OPERATOR_CANCELLED;
-
- case GESTURE_MODAL_CANCEL:
+ }
+ case GESTURE_MODAL_CANCEL: {
gesture_modal_end(C, op);
return OPERATOR_CANCELLED;
+ }
}
}
+ else {
+ switch (event->type) {
+ case MOUSEMOVE: {
+ if (gesture->type == WM_GESTURE_CROSS_RECT && gesture->is_active == false) {
+ rect->xmin = rect->xmax = event->x - gesture->winrct.xmin;
+ rect->ymin = rect->ymax = event->y - gesture->winrct.ymin;
+ }
+ else if (gesture->move) {
+ BLI_rcti_translate(rect,
+ (event->x - gesture->winrct.xmin) - rect->xmax,
+ (event->y - gesture->winrct.ymin) - rect->ymax);
+ }
+ else {
+ rect->xmax = event->x - gesture->winrct.xmin;
+ rect->ymax = event->y - gesture->winrct.ymin;
+ }
+ gesture_box_apply_rect(op);
+
+ wm_gesture_tag_redraw(win);
+
+ break;
+ }
#ifdef WITH_INPUT_NDOF
- else if (event->type == NDOF_MOTION) {
- return OPERATOR_PASS_THROUGH;
- }
+ case NDOF_MOTION: {
+ return OPERATOR_PASS_THROUGH;
+ }
#endif
-#if 0
- /* Allow view navigation??? */
- else {
- return OPERATOR_PASS_THROUGH;
- }
+#if 0 /* This allows view navigation, keep disabled as it's too unpredictable. */
+ default:
+ return OPERATOR_PASS_THROUGH;
#endif
+ }
+ }
gesture->is_active_prev = gesture->is_active;
return OPERATOR_RUNNING_MODAL;
@@ -651,47 +669,62 @@ int WM_gesture_lasso_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
wmGesture *gesture = op->customdata;
- switch (event->type) {
- case MOUSEMOVE:
- case INBETWEEN_MOUSEMOVE:
-
- wm_gesture_tag_redraw(CTX_wm_window(C));
-
- if (gesture->points == gesture->points_alloc) {
- gesture->points_alloc *= 2;
- gesture->customdata = MEM_reallocN(gesture->customdata,
- sizeof(short[2]) * gesture->points_alloc);
+ if (event->type == EVT_MODAL_MAP) {
+ switch (event->val) {
+ case GESTURE_MODAL_MOVE: {
+ gesture->move = !gesture->move;
+ break;
}
+ }
+ }
+ else {
+ switch (event->type) {
+ case MOUSEMOVE:
+ case INBETWEEN_MOUSEMOVE: {
+ wm_gesture_tag_redraw(CTX_wm_window(C));
+
+ if (gesture->points == gesture->points_alloc) {
+ gesture->points_alloc *= 2;
+ gesture->customdata = MEM_reallocN(gesture->customdata,
+ sizeof(short[2]) * gesture->points_alloc);
+ }
- {
- int x, y;
- short *lasso = gesture->customdata;
+ {
+ short(*lasso)[2] = gesture->customdata;
- lasso += (2 * gesture->points - 2);
- x = (event->x - gesture->winrct.xmin - lasso[0]);
- y = (event->y - gesture->winrct.ymin - lasso[1]);
+ const int x = ((event->x - gesture->winrct.xmin) - lasso[gesture->points - 1][0]);
+ const int y = ((event->y - gesture->winrct.ymin) - lasso[gesture->points - 1][1]);
- /* make a simple distance check to get a smoother lasso
- * add only when at least 2 pixels between this and previous location */
- if ((x * x + y * y) > 4) {
- lasso += 2;
- lasso[0] = event->x - gesture->winrct.xmin;
- lasso[1] = event->y - gesture->winrct.ymin;
- gesture->points++;
+ /* move the lasso */
+ if (gesture->move) {
+ for (int i = 0; i < gesture->points; i++) {
+ lasso[i][0] += x;
+ lasso[i][1] += y;
+ }
+ }
+ /* Make a simple distance check to get a smoother lasso
+ * add only when at least 2 pixels between this and previous location. */
+ else if ((x * x + y * y) > pow2f(2.0f * UI_DPI_FAC)) {
+ lasso[gesture->points][0] = event->x - gesture->winrct.xmin;
+ lasso[gesture->points][1] = event->y - gesture->winrct.ymin;
+ gesture->points++;
+ }
}
+ break;
}
- break;
-
- case LEFTMOUSE:
- case MIDDLEMOUSE:
- case RIGHTMOUSE:
- if (event->val == KM_RELEASE) { /* key release */
- return gesture_lasso_apply(C, op);
+ case LEFTMOUSE:
+ case MIDDLEMOUSE:
+ case RIGHTMOUSE: {
+ if (event->val == KM_RELEASE) { /* key release */
+ return gesture_lasso_apply(C, op);
+ }
+ break;
}
- break;
- case EVT_ESCKEY:
- gesture_modal_end(C, op);
- return OPERATOR_CANCELLED;
+ case EVT_ESCKEY: {
+ gesture_modal_end(C, op);
+ return OPERATOR_CANCELLED;
+ }
+ }
}
gesture->is_active_prev = gesture->is_active;
@@ -861,6 +894,32 @@ int WM_gesture_straightline_active_side_invoke(bContext *C, wmOperator *op, cons
return OPERATOR_RUNNING_MODAL;
}
+#define STRAIGHTLINE_SNAP_DEG 15.0f
+static void wm_gesture_straightline_do_angle_snap(rcti *rect)
+{
+ const float line_start[2] = {rect->xmin, rect->ymin};
+ const float line_end[2] = {rect->xmax, rect->ymax};
+ const float x_axis[2] = {1.0f, 0.0f};
+
+ float line_direction[2];
+ sub_v2_v2v2(line_direction, line_end, line_start);
+ const float line_length = normalize_v2(line_direction);
+
+ const float angle = angle_signed_v2v2(x_axis, line_direction);
+ const float angle_deg = RAD2DEG(angle) + (STRAIGHTLINE_SNAP_DEG / 2.0f);
+ const float angle_snapped_deg = -floorf(angle_deg / STRAIGHTLINE_SNAP_DEG) *
+ STRAIGHTLINE_SNAP_DEG;
+ const float angle_snapped = DEG2RAD(angle_snapped_deg);
+
+ float line_snapped_end[2];
+ rotate_v2_v2fl(line_snapped_end, x_axis, angle_snapped);
+ mul_v2_fl(line_snapped_end, line_length);
+ add_v2_v2(line_snapped_end, line_start);
+
+ rect->xmax = (int)line_snapped_end[0];
+ rect->ymax = (int)line_snapped_end[1];
+}
+
/**
* This modal callback calls exec once per mouse move event while the gesture is active with the
* updated line start and end values, so it can be used for tools that have a real time preview
@@ -872,38 +931,65 @@ int WM_gesture_straightline_modal(bContext *C, wmOperator *op, const wmEvent *ev
wmWindow *win = CTX_wm_window(C);
rcti *rect = gesture->customdata;
- if (event->type == MOUSEMOVE) {
- if (gesture->is_active == false) {
- rect->xmin = rect->xmax = event->x - gesture->winrct.xmin;
- rect->ymin = rect->ymax = event->y - gesture->winrct.ymin;
- }
- else {
- rect->xmax = event->x - gesture->winrct.xmin;
- rect->ymax = event->y - gesture->winrct.ymin;
- gesture_straightline_apply(C, op);
- }
-
- wm_gesture_tag_redraw(win);
- }
- else if (event->type == EVT_MODAL_MAP) {
+ if (event->type == EVT_MODAL_MAP) {
switch (event->val) {
- case GESTURE_MODAL_BEGIN:
+ case GESTURE_MODAL_MOVE: {
+ gesture->move = !gesture->move;
+ break;
+ }
+ case GESTURE_MODAL_BEGIN: {
if (gesture->is_active == false) {
gesture->is_active = true;
wm_gesture_tag_redraw(win);
}
break;
- case GESTURE_MODAL_SELECT:
+ }
+ case GESTURE_MODAL_SNAP: {
+ /* Toggle snapping on/off. */
+ gesture->use_snap = !gesture->use_snap;
+ break;
+ }
+ case GESTURE_MODAL_SELECT: {
if (gesture_straightline_apply(C, op)) {
gesture_modal_end(C, op);
return OPERATOR_FINISHED;
}
gesture_modal_end(C, op);
return OPERATOR_CANCELLED;
-
- case GESTURE_MODAL_CANCEL:
+ }
+ case GESTURE_MODAL_CANCEL: {
gesture_modal_end(C, op);
return OPERATOR_CANCELLED;
+ }
+ }
+ }
+ else {
+ switch (event->type) {
+ case MOUSEMOVE: {
+ if (gesture->is_active == false) {
+ rect->xmin = rect->xmax = event->x - gesture->winrct.xmin;
+ rect->ymin = rect->ymax = event->y - gesture->winrct.ymin;
+ }
+ else if (gesture->move) {
+ BLI_rcti_translate(rect,
+ (event->x - gesture->winrct.xmin) - rect->xmax,
+ (event->y - gesture->winrct.ymin) - rect->ymax);
+ gesture_straightline_apply(C, op);
+ }
+ else {
+ rect->xmax = event->x - gesture->winrct.xmin;
+ rect->ymax = event->y - gesture->winrct.ymin;
+ gesture_straightline_apply(C, op);
+ }
+
+ if (gesture->use_snap) {
+ wm_gesture_straightline_do_angle_snap(rect);
+ }
+
+ wm_gesture_tag_redraw(win);
+
+ break;
+ }
}
}
@@ -924,30 +1010,28 @@ int WM_gesture_straightline_oneshot_modal(bContext *C, wmOperator *op, const wmE
wmWindow *win = CTX_wm_window(C);
rcti *rect = gesture->customdata;
- if (event->type == MOUSEMOVE) {
- if (gesture->is_active == false) {
- rect->xmin = rect->xmax = event->x - gesture->winrct.xmin;
- rect->ymin = rect->ymax = event->y - gesture->winrct.ymin;
- }
- else {
- rect->xmax = event->x - gesture->winrct.xmin;
- rect->ymax = event->y - gesture->winrct.ymin;
- }
-
- wm_gesture_tag_redraw(win);
- }
- else if (event->type == EVT_MODAL_MAP) {
+ if (event->type == EVT_MODAL_MAP) {
switch (event->val) {
- case GESTURE_MODAL_BEGIN:
+ case GESTURE_MODAL_MOVE: {
+ gesture->move = !gesture->move;
+ break;
+ }
+ case GESTURE_MODAL_BEGIN: {
if (gesture->is_active == false) {
gesture->is_active = true;
wm_gesture_tag_redraw(win);
}
break;
+ }
+ case GESTURE_MODAL_SNAP: {
+ /* Toggle snapping on/off. */
+ gesture->use_snap = !gesture->use_snap;
+ break;
+ }
case GESTURE_MODAL_SELECT:
case GESTURE_MODAL_DESELECT:
case GESTURE_MODAL_IN:
- case GESTURE_MODAL_OUT:
+ case GESTURE_MODAL_OUT: {
if (gesture->wait_for_input) {
gesture->modal_state = event->val;
}
@@ -957,10 +1041,38 @@ int WM_gesture_straightline_oneshot_modal(bContext *C, wmOperator *op, const wmE
}
gesture_modal_end(C, op);
return OPERATOR_CANCELLED;
-
- case GESTURE_MODAL_CANCEL:
+ }
+ case GESTURE_MODAL_CANCEL: {
gesture_modal_end(C, op);
return OPERATOR_CANCELLED;
+ }
+ }
+ }
+ else {
+ switch (event->type) {
+ case MOUSEMOVE: {
+ if (gesture->is_active == false) {
+ rect->xmin = rect->xmax = event->x - gesture->winrct.xmin;
+ rect->ymin = rect->ymax = event->y - gesture->winrct.ymin;
+ }
+ else if (gesture->move) {
+ BLI_rcti_translate(rect,
+ (event->x - gesture->winrct.xmin) - rect->xmax,
+ (event->y - gesture->winrct.ymin) - rect->ymax);
+ }
+ else {
+ rect->xmax = event->x - gesture->winrct.xmin;
+ rect->ymax = event->y - gesture->winrct.ymin;
+ }
+
+ if (gesture->use_snap) {
+ wm_gesture_straightline_do_angle_snap(rect);
+ }
+
+ wm_gesture_tag_redraw(win);
+
+ break;
+ }
}
}
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index c51086c5f0a..5e4a45ea3be 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -3805,6 +3805,8 @@ static void gesture_straightline_modal_keymap(wmKeyConfig *keyconf)
{GESTURE_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""},
{GESTURE_MODAL_SELECT, "SELECT", 0, "Select", ""},
{GESTURE_MODAL_BEGIN, "BEGIN", 0, "Begin", ""},
+ {GESTURE_MODAL_MOVE, "MOVE", 0, "Move", ""},
+ {GESTURE_MODAL_SNAP, "SNAP", 0, "Snap", ""},
{0, NULL, 0, NULL, NULL},
};
@@ -3821,6 +3823,8 @@ static void gesture_straightline_modal_keymap(wmKeyConfig *keyconf)
WM_modalkeymap_assign(keymap, "IMAGE_OT_sample_line");
WM_modalkeymap_assign(keymap, "PAINT_OT_weight_gradient");
WM_modalkeymap_assign(keymap, "MESH_OT_bisect");
+ WM_modalkeymap_assign(keymap, "PAINT_OT_mask_line_gesture");
+ WM_modalkeymap_assign(keymap, "SCULPT_OT_project_line_gesture");
}
/* box_select-like modal operators */
@@ -3831,6 +3835,7 @@ static void gesture_box_modal_keymap(wmKeyConfig *keyconf)
{GESTURE_MODAL_SELECT, "SELECT", 0, "Select", ""},
{GESTURE_MODAL_DESELECT, "DESELECT", 0, "DeSelect", ""},
{GESTURE_MODAL_BEGIN, "BEGIN", 0, "Begin", ""},
+ {GESTURE_MODAL_MOVE, "MOVE", 0, "Move", ""},
{0, NULL, 0, NULL, NULL},
};
@@ -3868,8 +3873,6 @@ static void gesture_box_modal_keymap(wmKeyConfig *keyconf)
WM_modalkeymap_assign(keymap, "PAINT_OT_mask_box_gesture");
WM_modalkeymap_assign(keymap, "SCULPT_OT_face_set_box_gesture");
WM_modalkeymap_assign(keymap, "SCULPT_OT_trim_box_gesture");
- WM_modalkeymap_assign(keymap, "PAINT_OT_mask_line_gesture");
- WM_modalkeymap_assign(keymap, "SCULPT_OT_project_line_gesture");
WM_modalkeymap_assign(keymap, "VIEW2D_OT_zoom_border");
WM_modalkeymap_assign(keymap, "VIEW3D_OT_clip_border");
WM_modalkeymap_assign(keymap, "VIEW3D_OT_render_border");
@@ -3881,6 +3884,38 @@ static void gesture_box_modal_keymap(wmKeyConfig *keyconf)
WM_modalkeymap_assign(keymap, "GPENCIL_OT_select_box");
}
+/* lasso modal operators */
+static void gesture_lasso_modal_keymap(wmKeyConfig *keyconf)
+{
+ static const EnumPropertyItem modal_items[] = {
+ {GESTURE_MODAL_MOVE, "MOVE", 0, "Move", ""},
+ {0, NULL, 0, NULL, NULL},
+ };
+
+ wmKeyMap *keymap = WM_modalkeymap_find(keyconf, "Gesture Lasso");
+
+ /* this function is called for each spacetype, only needs to add map once */
+ if (keymap && keymap->modal_items) {
+ return;
+ }
+
+ keymap = WM_modalkeymap_ensure(keyconf, "Gesture Lasso", modal_items);
+
+ /* assign map to operators */
+ WM_modalkeymap_assign(keymap, "VIEW3D_OT_select_lasso");
+ WM_modalkeymap_assign(keymap, "GPENCIL_OT_stroke_cutter");
+ WM_modalkeymap_assign(keymap, "GPENCIL_OT_select_lasso");
+ WM_modalkeymap_assign(keymap, "MASK_OT_select_lasso");
+ WM_modalkeymap_assign(keymap, "PAINT_OT_mask_lasso_gesture");
+ WM_modalkeymap_assign(keymap, "SCULPT_OT_face_set_lasso_gesture");
+ WM_modalkeymap_assign(keymap, "SCULPT_OT_trim_lasso_gesture");
+ WM_modalkeymap_assign(keymap, "ACTION_OT_select_lasso");
+ WM_modalkeymap_assign(keymap, "CLIP_OT_select_lasso");
+ WM_modalkeymap_assign(keymap, "GRAPH_OT_select_lasso");
+ WM_modalkeymap_assign(keymap, "NODE_OT_select_lasso");
+ WM_modalkeymap_assign(keymap, "UV_OT_select_lasso");
+}
+
/* zoom to border modal operators */
static void gesture_zoom_border_modal_keymap(wmKeyConfig *keyconf)
{
@@ -3917,6 +3952,7 @@ void wm_window_keymap(wmKeyConfig *keyconf)
gesture_box_modal_keymap(keyconf);
gesture_zoom_border_modal_keymap(keyconf);
gesture_straightline_modal_keymap(keyconf);
+ gesture_lasso_modal_keymap(keyconf);
WM_keymap_fix_linking();
}
diff --git a/source/blender/windowmanager/wm_event_types.h b/source/blender/windowmanager/wm_event_types.h
index c8f282e678f..21662a4e83a 100644
--- a/source/blender/windowmanager/wm_event_types.h
+++ b/source/blender/windowmanager/wm_event_types.h
@@ -490,6 +490,12 @@ enum {
/** circle select: size brush (for trackpad event). */
GESTURE_MODAL_CIRCLE_SIZE = 11,
+
+ /** Move selection area. */
+ GESTURE_MODAL_MOVE = 12,
+
+ /** Toggle to activate snapping (angle snapping for straight line). */
+ GESTURE_MODAL_SNAP = 13,
};
#ifdef __cplusplus