Cleanup: remove redundant scene argument in BKE_object_add

This commit is contained in:
Campbell Barton 2020-09-07 14:09:50 +10:00
parent c695523687
commit c350d1eb13
9 changed files with 17 additions and 31 deletions

View File

@ -112,10 +112,9 @@ int BKE_object_visibility(const struct Object *ob, const int dag_eval_mode);
struct Object *BKE_object_add_only_object(struct Main *bmain, int type, const char *name)
ATTR_NONNULL(1) ATTR_RETURNS_NONNULL;
struct Object *BKE_object_add(struct Main *bmain,
struct Scene *scene,
struct ViewLayer *view_layer,
int type,
const char *name) ATTR_NONNULL(1, 2, 3) ATTR_RETURNS_NONNULL;
const char *name) ATTR_NONNULL(1, 2) ATTR_RETURNS_NONNULL;
struct Object *BKE_object_add_from(struct Main *bmain,
struct Scene *scene,
struct ViewLayer *view_layer,

View File

@ -1352,8 +1352,7 @@ static Object *object_add_common(Main *bmain, ViewLayer *view_layer, int type, c
* If there is no linked collection to the active ViewLayer we create a new one.
*/
/* creates minimum required data, but without vertices etc. */
Object *BKE_object_add(
Main *bmain, Scene *UNUSED(scene), ViewLayer *view_layer, int type, const char *name)
Object *BKE_object_add(Main *bmain, ViewLayer *view_layer, int type, const char *name)
{
Object *ob;
Base *base;

View File

@ -650,7 +650,7 @@ static void txt_add_object(bContext *C, TextLine *firstline, int totline, const
int a;
const float rot[3] = {0.f, 0.f, 0.f};
obedit = BKE_object_add(bmain, scene, view_layer, OB_FONT, NULL);
obedit = BKE_object_add(bmain, view_layer, OB_FONT, NULL);
base = view_layer->basact;
/* seems to assume view align ? TODO - look into this, could be an operator option */

View File

@ -397,7 +397,6 @@ bool ED_object_modifier_move_to_index(struct ReportList *reports,
bool ED_object_modifier_convert(struct ReportList *reports,
struct Main *bmain,
struct Depsgraph *depsgraph,
struct Scene *scene,
struct ViewLayer *view_layer,
struct Object *ob,
struct ModifierData *md);

View File

@ -544,7 +544,7 @@ Object *ED_object_add_type_with_obdata(bContext *C,
}
}
else {
ob = BKE_object_add(bmain, scene, view_layer, type, name);
ob = BKE_object_add(bmain, view_layer, type, name);
}
BASACT(view_layer)->local_view_bits = local_view_bits;
/* editor level activate, notifiers */

View File

@ -1970,13 +1970,12 @@ static bool get_new_constraint_target(
/* if still not found, add a new empty to act as a target (if allowed) */
if ((found == false) && (add)) {
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
Base *base = BASACT(view_layer);
Object *obt;
/* add new target object */
obt = BKE_object_add(bmain, scene, view_layer, OB_EMPTY, NULL);
obt = BKE_object_add(bmain, view_layer, OB_EMPTY, NULL);
/* transform cent to global coords for loc */
if (pchanact) {

View File

@ -496,13 +496,12 @@ static bool hook_op_edit_poll(bContext *C)
return false;
}
static Object *add_hook_object_new(
Main *bmain, Scene *scene, ViewLayer *view_layer, View3D *v3d, Object *obedit)
static Object *add_hook_object_new(Main *bmain, ViewLayer *view_layer, View3D *v3d, Object *obedit)
{
Base *basedit;
Object *ob;
ob = BKE_object_add(bmain, scene, view_layer, OB_EMPTY, NULL);
ob = BKE_object_add(bmain, view_layer, OB_EMPTY, NULL);
basedit = BKE_view_layer_base_find(view_layer, obedit);
BLI_assert(view_layer->basact->object == ob);
@ -545,7 +544,7 @@ static int add_hook_object(const bContext *C,
if (mode == OBJECT_ADDHOOK_NEWOB && !ob) {
ob = add_hook_object_new(bmain, scene, view_layer, v3d, obedit);
ob = add_hook_object_new(bmain, view_layer, v3d, obedit);
/* transform cent to global coords for loc */
mul_v3_m4v3(ob->loc, obedit->obmat, cent);

View File

@ -516,7 +516,6 @@ bool ED_object_modifier_move_to_index(ReportList *reports,
bool ED_object_modifier_convert(ReportList *UNUSED(reports),
Main *bmain,
Depsgraph *depsgraph,
Scene *scene,
ViewLayer *view_layer,
Object *ob,
ModifierData *md)
@ -583,7 +582,7 @@ bool ED_object_modifier_convert(ReportList *UNUSED(reports),
}
/* add new mesh */
obn = BKE_object_add(bmain, scene, view_layer, OB_MESH, NULL);
obn = BKE_object_add(bmain, view_layer, OB_MESH, NULL);
me = obn->data;
me->totvert = totvert;
@ -642,7 +641,6 @@ bool ED_object_modifier_convert(ReportList *UNUSED(reports),
/* Gets mesh for the modifier which corresponds to an evaluated state. */
static Mesh *modifier_apply_create_mesh_for_modifier(Depsgraph *depsgraph,
Scene *UNUSED(scene),
Object *object,
ModifierData *md_eval,
bool build_shapekey_layers)
@ -690,7 +688,7 @@ static int modifier_apply_shape(Main *bmain,
return 0;
}
mesh_applied = modifier_apply_create_mesh_for_modifier(depsgraph, scene, ob, md_eval, false);
mesh_applied = modifier_apply_create_mesh_for_modifier(depsgraph, ob, md_eval, false);
if (!mesh_applied) {
BKE_report(reports, RPT_ERROR, "Modifier is disabled or returned error, skipping apply");
return 0;
@ -750,7 +748,7 @@ static int modifier_apply_obdata(
}
}
else {
mesh_applied = modifier_apply_create_mesh_for_modifier(depsgraph, scene, ob, md_eval, true);
mesh_applied = modifier_apply_create_mesh_for_modifier(depsgraph, ob, md_eval, true);
if (!mesh_applied) {
BKE_report(reports, RPT_ERROR, "Modifier returned error, skipping apply");
return 0;
@ -1509,13 +1507,11 @@ static int modifier_convert_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob = ED_object_active_context(C);
ModifierData *md = edit_modifier_property_get(op, ob, 0);
if (!md ||
!ED_object_modifier_convert(op->reports, bmain, depsgraph, scene, view_layer, ob, md)) {
if (!md || !ED_object_modifier_convert(op->reports, bmain, depsgraph, view_layer, ob, md)) {
return OPERATOR_CANCELLED;
}
@ -2336,10 +2332,7 @@ static void skin_armature_bone_create(Object *skin_ob,
}
}
static Object *modifier_skin_armature_create(Depsgraph *depsgraph,
Main *bmain,
Scene *scene,
Object *skin_ob)
static Object *modifier_skin_armature_create(Depsgraph *depsgraph, Main *bmain, Object *skin_ob)
{
BLI_bitmap *edges_visited;
Mesh *me_eval_deform;
@ -2362,7 +2355,7 @@ static Object *modifier_skin_armature_create(Depsgraph *depsgraph,
CustomData_add_layer(&me->vdata, CD_MDEFORMVERT, CD_CALLOC, NULL, me->totvert);
ViewLayer *view_layer = DEG_get_input_view_layer(depsgraph);
arm_ob = BKE_object_add(bmain, scene, view_layer, OB_ARMATURE, NULL);
arm_ob = BKE_object_add(bmain, view_layer, OB_ARMATURE, NULL);
BKE_object_transform_copy(arm_ob, skin_ob);
arm = arm_ob->data;
arm->layer = 1;
@ -2414,7 +2407,6 @@ static int skin_armature_create_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C), *arm_ob;
Mesh *me = ob->data;
ModifierData *skin_md;
@ -2426,7 +2418,7 @@ static int skin_armature_create_exec(bContext *C, wmOperator *op)
}
/* create new armature */
arm_ob = modifier_skin_armature_create(depsgraph, bmain, scene, ob);
arm_ob = modifier_skin_armature_create(depsgraph, bmain, ob);
/* add a modifier to connect the new armature to the mesh */
arm_md = (ArmatureModifierData *)BKE_modifier_new(eModifierType_Armature);

View File

@ -141,8 +141,7 @@ BlenderStrokeRenderer::BlenderStrokeRenderer(Render *re, int render_count) : Str
view_layer->layflag = SCE_LAY_SOLID | SCE_LAY_ZTRA;
// Camera
Object *object_camera = BKE_object_add(
freestyle_bmain, freestyle_scene, view_layer, OB_CAMERA, NULL);
Object *object_camera = BKE_object_add(freestyle_bmain, view_layer, OB_CAMERA, NULL);
Camera *camera = (Camera *)object_camera->data;
camera->type = CAM_ORTHO;
@ -577,7 +576,7 @@ void BlenderStrokeRenderer::GenerateStrokeMesh(StrokeGroup *group, bool hasTex)
{
#if 0
Object *object_mesh = BKE_object_add(
freestyle_bmain, freestyle_scene, (ViewLayer *)freestyle_scene->view_layers.first, OB_MESH);
freestyle_bmain, (ViewLayer *)freestyle_scene->view_layers.first, OB_MESH);
DEG_relations_tag_update(freestyle_bmain);
#else
Object *object_mesh = NewMesh();