diff options
author | Hans Goudey <h.goudey@me.com> | 2020-08-12 04:59:16 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2020-08-12 04:59:16 +0300 |
commit | ef11238c743e6985fe325280fb13e05d6ec27378 (patch) | |
tree | 1dd2605a676bee52296535825b99f000a9c255eb /source/blender/editors/object | |
parent | 1f768bbe4145daed111636ca09dd53b25b8d29b5 (diff) | |
parent | ec5f39208785c1bbe723054ffe69e1ac2ab470dd (diff) |
Merge branch 'master' into property-search-uiproperty-search-ui
Diffstat (limited to 'source/blender/editors/object')
-rw-r--r-- | source/blender/editors/object/object_add.c | 64 | ||||
-rw-r--r-- | source/blender/editors/object/object_bake.c | 4 | ||||
-rw-r--r-- | source/blender/editors/object/object_bake_api.c | 8 | ||||
-rw-r--r-- | source/blender/editors/object/object_intern.h | 5 | ||||
-rw-r--r-- | source/blender/editors/object/object_modifier.c | 22 | ||||
-rw-r--r-- | source/blender/editors/object/object_relations.c | 5 | ||||
-rw-r--r-- | source/blender/editors/object/object_remesh.c | 7 | ||||
-rw-r--r-- | source/blender/editors/object/object_transform.c | 2 |
8 files changed, 74 insertions, 43 deletions
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index f92dafcc7f9..81b8cd70353 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -205,7 +205,7 @@ void ED_object_rotation_from_quat(float rot[3], const float viewquat[4], const c switch (align_axis) { case 'X': { /* Same as 'rv3d->viewinv[1]' */ - float axis_y[4] = {0.0f, 1.0f, 0.0f}; + const float axis_y[4] = {0.0f, 1.0f, 0.0f}; float quat_y[4], quat[4]; axis_angle_to_quat(quat_y, axis_y, M_PI_2); mul_qt_qtqt(quat, viewquat, quat_y); @@ -255,13 +255,13 @@ void ED_object_base_init_transform_on_add(Object *object, const float loc[3], co /* Uses context to figure out transform for primitive. * Returns standard diameter. */ float ED_object_new_primitive_matrix( - bContext *C, Object *obedit, const float loc[3], const float rot[3], float primmat[4][4]) + bContext *C, Object *obedit, const float loc[3], const float rot[3], float r_primmat[4][4]) { Scene *scene = CTX_data_scene(C); View3D *v3d = CTX_wm_view3d(C); float mat[3][3], rmat[3][3], cmat[3][3], imat[3][3]; - unit_m4(primmat); + unit_m4(r_primmat); eul_to_mat3(rmat, rot); invert_m3(rmat); @@ -270,13 +270,13 @@ float ED_object_new_primitive_matrix( copy_m3_m4(mat, obedit->obmat); mul_m3_m3m3(cmat, rmat, mat); invert_m3_m3(imat, cmat); - copy_m4_m3(primmat, imat); + copy_m4_m3(r_primmat, imat); /* center */ - copy_v3_v3(primmat[3], loc); - sub_v3_v3v3(primmat[3], primmat[3], obedit->obmat[3]); + copy_v3_v3(r_primmat[3], loc); + sub_v3_v3v3(r_primmat[3], r_primmat[3], obedit->obmat[3]); invert_m3_m3(imat, mat); - mul_m3_v3(imat, primmat[3]); + mul_m3_v3(imat, r_primmat[3]); { const float dia = v3d ? ED_view3d_grid_scale(scene, v3d, NULL) : @@ -692,6 +692,46 @@ void OBJECT_OT_lightprobe_add(wmOperatorType *ot) * \{ */ /* for object add operator */ + +static const char *get_effector_defname(ePFieldType type) +{ + switch (type) { + case PFIELD_FORCE: + return CTX_DATA_(BLT_I18NCONTEXT_ID_OBJECT, "Force"); + case PFIELD_VORTEX: + return CTX_DATA_(BLT_I18NCONTEXT_ID_OBJECT, "Vortex"); + case PFIELD_MAGNET: + return CTX_DATA_(BLT_I18NCONTEXT_ID_OBJECT, "Magnet"); + case PFIELD_WIND: + return CTX_DATA_(BLT_I18NCONTEXT_ID_OBJECT, "Wind"); + case PFIELD_GUIDE: + return CTX_DATA_(BLT_I18NCONTEXT_ID_OBJECT, "CurveGuide"); + case PFIELD_TEXTURE: + return CTX_DATA_(BLT_I18NCONTEXT_ID_OBJECT, "TextureField"); + case PFIELD_HARMONIC: + return CTX_DATA_(BLT_I18NCONTEXT_ID_OBJECT, "Harmonic"); + case PFIELD_CHARGE: + return CTX_DATA_(BLT_I18NCONTEXT_ID_OBJECT, "Charge"); + case PFIELD_LENNARDJ: + return CTX_DATA_(BLT_I18NCONTEXT_ID_OBJECT, "Lennard-Jones"); + case PFIELD_BOID: + return CTX_DATA_(BLT_I18NCONTEXT_ID_OBJECT, "Boid"); + case PFIELD_TURBULENCE: + return CTX_DATA_(BLT_I18NCONTEXT_ID_OBJECT, "Turbulence"); + case PFIELD_DRAG: + return CTX_DATA_(BLT_I18NCONTEXT_ID_OBJECT, "Drag"); + case PFIELD_FLUIDFLOW: + return CTX_DATA_(BLT_I18NCONTEXT_ID_OBJECT, "FluidField"); + case PFIELD_NULL: + return CTX_DATA_(BLT_I18NCONTEXT_ID_OBJECT, "Field"); + case NUM_PFIELD_TYPES: + break; + } + + BLI_assert(false); + return CTX_DATA_(BLT_I18NCONTEXT_ID_OBJECT, "Field"); +} + static int effector_add_exec(bContext *C, wmOperator *op) { Object *ob; @@ -712,8 +752,8 @@ static int effector_add_exec(bContext *C, wmOperator *op) if (type == PFIELD_GUIDE) { Curve *cu; - const char *name = CTX_DATA_(BLT_I18NCONTEXT_ID_OBJECT, "CurveGuide"); - ob = ED_object_add_type(C, OB_CURVE, name, loc, rot, false, local_view_bits); + ob = ED_object_add_type( + C, OB_CURVE, get_effector_defname(type), loc, rot, false, local_view_bits); cu = ob->data; cu->flag |= CU_PATH | CU_3D; @@ -726,8 +766,8 @@ static int effector_add_exec(bContext *C, wmOperator *op) } } else { - const char *name = CTX_DATA_(BLT_I18NCONTEXT_ID_OBJECT, "Field"); - ob = ED_object_add_type(C, OB_EMPTY, name, loc, rot, false, local_view_bits); + ob = ED_object_add_type( + C, OB_EMPTY, get_effector_defname(type), loc, rot, false, local_view_bits); BKE_object_obdata_size_init(ob, dia); if (ELEM(type, PFIELD_WIND, PFIELD_VORTEX)) { ob->empty_drawtype = OB_SINGLE_ARROW; @@ -1237,7 +1277,7 @@ static int object_gpencil_add_exec(bContext *C, wmOperator *op) break; } - /* if this is a new object, initialise default stuff (colors, etc.) */ + /* If this is a new object, initialize default stuff (colors, etc.) */ if (newob) { /* set default viewport color to black */ copy_v3_fl(ob->color, 0.0f); diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index baa24ab2f4e..ae1aae27b7f 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -60,8 +60,6 @@ #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" -#include "GPU_draw.h" /* GPU_free_image */ - #include "WM_api.h" #include "WM_types.h" @@ -530,7 +528,7 @@ static void multiresbake_freejob(void *bkv) /* delete here, since this delete will be called from main thread */ for (link = data->images.first; link; link = link->next) { Image *ima = (Image *)link->data; - GPU_free_image(ima); + BKE_image_free_gputextures(ima); } MEM_freeN(data->ob_image.array); diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c index c4cb21a67f3..cb92fab3cb0 100644 --- a/source/blender/editors/object/object_bake_api.c +++ b/source/blender/editors/object/object_bake_api.c @@ -68,8 +68,6 @@ #include "ED_screen.h" #include "ED_uvedit.h" -#include "GPU_draw.h" - #include "object_intern.h" /* prototypes */ @@ -308,7 +306,7 @@ static void refresh_images(BakeImages *bake_images) Image *ima = bake_images->data[i].image; LISTBASE_FOREACH (ImageTile *, tile, &ima->tiles) { if (tile->ok == IMA_OK_LOADED) { - GPU_free_image(ima); + BKE_image_free_gputextures(ima); DEG_id_tag_update(&ima->id, 0); break; } @@ -675,7 +673,7 @@ static void build_image_lookup(Main *bmain, Object *ob, BakeImages *bake_images) /* * returns the total number of pixels */ -static size_t initialize_internal_images(BakeImages *bake_images, ReportList *reports) +static size_t init_internal_images(BakeImages *bake_images, ReportList *reports) { int i; size_t tot_size = 0; @@ -830,7 +828,7 @@ static int bake(Render *re, build_image_lookup(bmain, ob_low, &bake_images); if (is_save_internal) { - num_pixels = initialize_internal_images(&bake_images, reports); + num_pixels = init_internal_images(&bake_images, reports); if (num_pixels == 0) { goto cleanup; diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index 9dc204b9083..bc3c263e0a3 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -21,8 +21,7 @@ * \ingroup edobj */ -#ifndef __OBJECT_INTERN_H__ -#define __OBJECT_INTERN_H__ +#pragma once #ifdef __cplusplus extern "C" { @@ -311,5 +310,3 @@ void OBJECT_OT_datalayout_transfer(struct wmOperatorType *ot); #ifdef __cplusplus } #endif - -#endif /* __OBJECT_INTERN_H__ */ diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 8a736c380bf..8d6d2e3e31d 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -345,7 +345,8 @@ static bool object_modifier_remove( object_remove_particle_system(bmain, scene, ob); return true; } - else if (md->type == eModifierType_Softbody) { + + if (md->type == eModifierType_Softbody) { if (ob->soft) { sbFree(ob); ob->softflag = 0; /* TODO(Sybren): this should probably be moved into sbFree() */ @@ -888,12 +889,11 @@ int ED_object_modifier_copy( BLI_insertlinkafter(&ob->modifiers, md, nmd); return true; } - else { - nmd = BKE_modifier_new(md->type); - BKE_modifier_copydata(md, nmd); - BLI_insertlinkafter(&ob->modifiers, md, nmd); - BKE_modifier_unique_name(&ob->modifiers, nmd); - } + + nmd = BKE_modifier_new(md->type); + BKE_modifier_copydata(md, nmd); + BLI_insertlinkafter(&ob->modifiers, md, nmd); + BKE_modifier_unique_name(&ob->modifiers, nmd); return 1; } @@ -1347,7 +1347,7 @@ static bool modifier_apply_poll_ex(bContext *C, bool allow_shared) Object *ob = (ptr.owner_id != NULL) ? (Object *)ptr.owner_id : ED_object_active_context(C); ModifierData *md = ptr.data; /* May be NULL. */ - if (ID_IS_OVERRIDE_LIBRARY(ob) || ID_IS_OVERRIDE_LIBRARY(ob->data)) { + if (ID_IS_OVERRIDE_LIBRARY(ob) || ((ob->data != NULL) && ID_IS_OVERRIDE_LIBRARY(ob->data))) { CTX_wm_operator_poll_msg_set(C, "Modifiers cannot be applied on override data"); return false; } @@ -1458,9 +1458,7 @@ static int modifier_apply_as_shapekey_invoke(bContext *C, wmOperator *op, const if (edit_modifier_invoke_properties(C, op, event, &retval)) { return modifier_apply_as_shapekey_exec(C, op); } - else { - return retval; - } + return retval; } static char *modifier_apply_as_shapekey_get_description(struct bContext *UNUSED(C), @@ -2813,7 +2811,7 @@ static int ocean_bake_exec(bContext *C, wmOperator *op) /* make a copy of ocean to use for baking - threadsafety */ ocean = BKE_ocean_add(); - BKE_ocean_init_from_modifier(ocean, omd); + BKE_ocean_init_from_modifier(ocean, omd, omd->resolution); #if 0 BKE_ocean_bake(ocean, och); diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 9520b03f3a6..732d2f6ad52 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -1175,7 +1175,7 @@ static int parent_noinv_set_exec(bContext *C, wmOperator *op) else { /* clear inverse matrix and also the object location */ unit_m4(ob->parentinv); - memset(ob->loc, 0, 3 * sizeof(float)); + memset(ob->loc, 0, sizeof(float[3])); /* set recalc flags */ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); @@ -2283,7 +2283,8 @@ static int make_override_library_invoke(bContext *C, wmOperator *op, const wmEve /* This invoke just calls another instance of this operator... */ return OPERATOR_INTERFACE; } - else if (ID_IS_LINKED(obact)) { + + if (ID_IS_LINKED(obact)) { /* Show menu with list of directly linked collections containing the active object. */ WM_enum_search_invoke(C, op, event); return OPERATOR_CANCELLED; diff --git a/source/blender/editors/object/object_remesh.c b/source/blender/editors/object/object_remesh.c index 8981851394d..8d8f01dd61a 100644 --- a/source/blender/editors/object/object_remesh.c +++ b/source/blender/editors/object/object_remesh.c @@ -72,7 +72,6 @@ #include "RNA_define.h" #include "RNA_enum_types.h" -#include "GPU_draw.h" #include "GPU_immediate.h" #include "GPU_immediate_util.h" #include "GPU_matrix.h" @@ -407,7 +406,7 @@ static int voxel_size_edit_modal(bContext *C, wmOperator *op, const wmEvent *eve return OPERATOR_FINISHED; } - float mval[2] = {event->mval[0], event->mval[1]}; + const float mval[2] = {event->mval[0], event->mval[1]}; float d = cd->init_mval[0] - mval[0]; @@ -471,7 +470,7 @@ static int voxel_size_edit_invoke(bContext *C, wmOperator *op, const wmEvent *ev BoundBox *bb = BKE_mesh_boundbox_get(cd->active_object); /* Indices of the Bounding Box faces. */ - int BB_faces[6][4] = { + const int BB_faces[6][4] = { {3, 0, 4, 7}, {1, 2, 6, 5}, {3, 2, 1, 0}, @@ -526,7 +525,7 @@ static int voxel_size_edit_invoke(bContext *C, wmOperator *op, const wmEvent *ev float d_a[3], d_b[3]; float d_a_proj[2], d_b_proj[2]; float preview_plane_proj[4][3]; - float y_axis_proj[2] = {0.0f, 1.0f}; + const float y_axis_proj[2] = {0.0f, 1.0f}; mid_v3_v3v3(text_pos, cd->preview_plane[0], cd->preview_plane[2]); diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index f2d7ad3ac11..52b572fb0dd 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -1907,7 +1907,7 @@ static int object_transform_axis_target_modal(bContext *C, wmOperator *op, const for (int x = -ofs; x <= ofs; x += ofs / 2) { for (int y = -ofs; y <= ofs; y += ofs / 2) { if (x != 0 && y != 0) { - int mval_ofs[2] = {event->mval[0] + x, event->mval[1] + y}; + const int mval_ofs[2] = {event->mval[0] + x, event->mval[1] + y}; float n[3]; if (ED_view3d_depth_read_cached_normal(&xfd->vc, mval_ofs, n)) { add_v3_v3(normal, n); |