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
diff options
context:
space:
mode:
-rw-r--r--source/blender/bmesh/intern/bmesh_opdefines.c8
-rw-r--r--source/blender/bmesh/operators/bmo_primitive.c43
-rw-r--r--source/blender/editors/curve/editcurve_add.c8
-rw-r--r--source/blender/editors/include/ED_object.h1
-rw-r--r--source/blender/editors/mesh/editmesh_add.c14
-rw-r--r--source/blender/editors/object/object_add.c39
6 files changed, 57 insertions, 56 deletions
diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c
index b63a09a97a6..7865c79323d 100644
--- a/source/blender/bmesh/intern/bmesh_opdefines.c
+++ b/source/blender/bmesh/intern/bmesh_opdefines.c
@@ -1587,7 +1587,7 @@ static BMOpDefine bmo_create_uvsphere_def = {
/* slots_in */
{{"u_segments", BMO_OP_SLOT_INT}, /* number of u segments */
{"v_segments", BMO_OP_SLOT_INT}, /* number of v segment */
- {"diameter", BMO_OP_SLOT_FLT}, /* diameter */
+ {"radius", BMO_OP_SLOT_FLT}, /* radius */
{"matrix", BMO_OP_SLOT_MAT}, /* matrix to multiply the new geometry with */
{"calc_uvs", BMO_OP_SLOT_BOOL}, /* calculate default UVs */
{{'\0'}},
@@ -1610,7 +1610,7 @@ static BMOpDefine bmo_create_icosphere_def = {
"create_icosphere",
/* slots_in */
{{"subdivisions", BMO_OP_SLOT_INT}, /* how many times to recursively subdivide the sphere */
- {"diameter", BMO_OP_SLOT_FLT}, /* diameter */
+ {"radius", BMO_OP_SLOT_FLT}, /* radius */
{"matrix", BMO_OP_SLOT_MAT}, /* matrix to multiply the new geometry with */
{"calc_uvs", BMO_OP_SLOT_BOOL}, /* calculate default UVs */
{{'\0'}},
@@ -1656,8 +1656,8 @@ static BMOpDefine bmo_create_cone_def = {
{{"cap_ends", BMO_OP_SLOT_BOOL}, /* whether or not to fill in the ends with faces */
{"cap_tris", BMO_OP_SLOT_BOOL}, /* fill ends with triangles instead of ngons */
{"segments", BMO_OP_SLOT_INT}, /* number of vertices in the base circle */
- {"diameter1", BMO_OP_SLOT_FLT}, /* diameter of one end */
- {"diameter2", BMO_OP_SLOT_FLT}, /* diameter of the opposite */
+ {"radius1", BMO_OP_SLOT_FLT}, /* radius of one end */
+ {"radius2", BMO_OP_SLOT_FLT}, /* radius of the opposite */
{"depth", BMO_OP_SLOT_FLT}, /* distance between ends */
{"matrix", BMO_OP_SLOT_MAT}, /* matrix to multiply the new geometry with */
{"calc_uvs", BMO_OP_SLOT_BOOL}, /* calculate default UVs */
diff --git a/source/blender/bmesh/operators/bmo_primitive.c b/source/blender/bmesh/operators/bmo_primitive.c
index 8d5963cfb1c..d8047499780 100644
--- a/source/blender/bmesh/operators/bmo_primitive.c
+++ b/source/blender/bmesh/operators/bmo_primitive.c
@@ -854,7 +854,7 @@ void BM_mesh_calc_uvs_grid(BMesh *bm,
void bmo_create_uvsphere_exec(BMesh *bm, BMOperator *op)
{
- const float dia = BMO_slot_float_get(op->slots_in, "diameter");
+ const float rad = BMO_slot_float_get(op->slots_in, "radius");
const int seg = BMO_slot_int_get(op->slots_in, "u_segments");
const int tot = BMO_slot_int_get(op->slots_in, "v_segments");
@@ -881,8 +881,8 @@ void bmo_create_uvsphere_exec(BMesh *bm, BMOperator *op)
const float phi = M_PI * ((double)a / (double)tot);
vec[0] = 0.0;
- vec[1] = dia * sinf(phi);
- vec[2] = dia * cosf(phi);
+ vec[1] = rad * sinf(phi);
+ vec[2] = rad * cosf(phi);
eve = BM_vert_create(bm, vec, NULL, BM_CREATE_NOP);
BMO_vert_flag_enable(bm, eve, VERT_MARK);
@@ -921,12 +921,12 @@ void bmo_create_uvsphere_exec(BMesh *bm, BMOperator *op)
{
float len, len2, vec2[3];
- len = 2 * dia * sinf(phid / 2.0f);
+ len = 2 * rad * sinf(phid / 2.0f);
/* Length of one segment in shortest parallel. */
- vec[0] = dia * sinf(phid);
+ vec[0] = rad * sinf(phid);
vec[1] = 0.0f;
- vec[2] = dia * cosf(phid);
+ vec[2] = rad * cosf(phid);
mul_v3_m3v3(vec2, cmat, vec);
len2 = len_v3v3(vec, vec2);
@@ -973,8 +973,8 @@ void bmo_create_uvsphere_exec(BMesh *bm, BMOperator *op)
void bmo_create_icosphere_exec(BMesh *bm, BMOperator *op)
{
- const float dia = BMO_slot_float_get(op->slots_in, "diameter");
- const float dia_div = dia / 200.0f;
+ const float rad = BMO_slot_float_get(op->slots_in, "radius");
+ const float rad_div = rad / 200.0f;
const int subdiv = BMO_slot_int_get(op->slots_in, "subdivisions");
const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPUV);
@@ -994,9 +994,9 @@ void bmo_create_icosphere_exec(BMesh *bm, BMOperator *op)
/* phi = 0.25f * (float)M_PI; */ /* UNUSED */
for (a = 0; a < 12; a++) {
- vec[0] = dia_div * icovert[a][0];
- vec[1] = dia_div * icovert[a][1];
- vec[2] = dia_div * icovert[a][2];
+ vec[0] = rad_div * icovert[a][0];
+ vec[1] = rad_div * icovert[a][1];
+ vec[2] = rad_div * icovert[a][2];
eva[a] = BM_vert_create(bm, vec, NULL, BM_CREATE_NOP);
BMO_vert_flag_enable(bm, eva[a], VERT_MARK);
@@ -1041,7 +1041,7 @@ void bmo_create_icosphere_exec(BMesh *bm, BMOperator *op)
"cuts=%i "
"use_grid_fill=%b use_sphere=%b",
EDGE_MARK,
- dia,
+ rad,
(1 << (subdiv - 1)) - 1,
true,
true);
@@ -1392,8 +1392,8 @@ void bmo_create_cone_exec(BMesh *bm, BMOperator *op)
BMVert *v1, *v2, *lastv1 = NULL, *lastv2 = NULL, *cent1, *cent2, *firstv1, *firstv2;
BMFace *f;
float vec[3], mat[4][4];
- const float dia1 = BMO_slot_float_get(op->slots_in, "diameter1");
- const float dia2 = BMO_slot_float_get(op->slots_in, "diameter2");
+ const float rad1 = BMO_slot_float_get(op->slots_in, "radius1");
+ const float rad2 = BMO_slot_float_get(op->slots_in, "radius2");
const float depth_half = 0.5f * BMO_slot_float_get(op->slots_in, "depth");
int segs = BMO_slot_int_get(op->slots_in, "segments");
const bool cap_ends = BMO_slot_bool_get(op->slots_in, "cap_ends");
@@ -1431,15 +1431,14 @@ void bmo_create_cone_exec(BMesh *bm, BMOperator *op)
for (int i = 0; i < segs; i++) {
/* Calculate with doubles for higher precision, see: T87779. */
const float phi = (2.0 * M_PI) * ((double)i / (double)segs);
-
- vec[0] = dia1 * sinf(phi);
- vec[1] = dia1 * cosf(phi);
+ vec[0] = rad1 * sinf(phi);
+ vec[1] = rad1 * cosf(phi);
vec[2] = -depth_half;
mul_m4_v3(mat, vec);
v1 = BM_vert_create(bm, vec, NULL, BM_CREATE_NOP);
- vec[0] = dia2 * sinf(phi);
- vec[1] = dia2 * cosf(phi);
+ vec[0] = rad2 * sinf(phi);
+ vec[1] = rad2 * cosf(phi);
vec[2] = depth_half;
mul_m4_v3(mat, vec);
v2 = BM_vert_create(bm, vec, NULL, BM_CREATE_NOP);
@@ -1497,11 +1496,11 @@ void bmo_create_cone_exec(BMesh *bm, BMOperator *op)
}
if (calc_uvs) {
- BM_mesh_calc_uvs_cone(bm, mat, dia2, dia1, segs, cap_ends, FACE_MARK, cd_loop_uv_offset);
+ BM_mesh_calc_uvs_cone(bm, mat, rad2, rad1, segs, cap_ends, FACE_MARK, cd_loop_uv_offset);
}
/* Collapse vertices at the first end. */
- if (dia1 == 0.0f) {
+ if (rad1 == 0.0f) {
if (cap_ends) {
BM_vert_kill(bm, cent1);
}
@@ -1513,7 +1512,7 @@ void bmo_create_cone_exec(BMesh *bm, BMOperator *op)
}
/* Collapse vertices at the second end. */
- if (dia2 == 0.0f) {
+ if (rad2 == 0.0f) {
if (cap_ends) {
BM_vert_kill(bm, cent2);
}
diff --git a/source/blender/editors/curve/editcurve_add.c b/source/blender/editors/curve/editcurve_add.c
index 19aad20cbc1..75fb17e8cc1 100644
--- a/source/blender/editors/curve/editcurve_add.c
+++ b/source/blender/editors/curve/editcurve_add.c
@@ -515,7 +515,6 @@ static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf)
bool newob = false;
bool enter_editmode;
ushort local_view_bits;
- float dia;
float loc[3], rot[3];
float mat[4][4];
@@ -555,9 +554,10 @@ static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf)
}
}
- ED_object_new_primitive_matrix(C, obedit, loc, rot, mat);
- dia = RNA_float_get(op->ptr, "radius");
- mul_mat3_m4_fl(mat, dia);
+ float radius = RNA_float_get(op->ptr, "radius");
+ float scale[3];
+ copy_v3_fl(scale, radius);
+ ED_object_new_primitive_matrix(C, obedit, loc, rot, scale, mat);
nu = ED_curve_add_nurbs_primitive(C, obedit, mat, type, newob);
editnurb = object_editcurve_get(obedit);
diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h
index a9cf04e1ad7..5397cd95ace 100644
--- a/source/blender/editors/include/ED_object.h
+++ b/source/blender/editors/include/ED_object.h
@@ -286,6 +286,7 @@ float ED_object_new_primitive_matrix(struct bContext *C,
struct Object *obedit,
const float loc[3],
const float rot[3],
+ const float scale[3],
float primmat[4][4]);
/* Avoid allowing too much insane values even by typing
diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c
index a64b90e15a3..c826da74010 100644
--- a/source/blender/editors/mesh/editmesh_add.c
+++ b/source/blender/editors/mesh/editmesh_add.c
@@ -73,11 +73,7 @@ static Object *make_prim_init(bContext *C,
r_creation_data->was_editmode = true;
}
- ED_object_new_primitive_matrix(C, obedit, loc, rot, r_creation_data->mat);
-
- if (scale) {
- rescale_m4(r_creation_data->mat, scale);
- }
+ ED_object_new_primitive_matrix(C, obedit, loc, rot, scale, r_creation_data->mat);
return obedit;
}
@@ -351,7 +347,7 @@ static int add_primitive_cylinder_exec(bContext *C, wmOperator *op)
op,
"verts.out",
false,
- "create_cone segments=%i diameter1=%f diameter2=%f cap_ends=%b "
+ "create_cone segments=%i radius1=%f radius2=%f cap_ends=%b "
"cap_tris=%b depth=%f matrix=%m4 calc_uvs=%b",
RNA_int_get(op->ptr, "vertices"),
RNA_float_get(op->ptr, "radius"),
@@ -427,7 +423,7 @@ static int add_primitive_cone_exec(bContext *C, wmOperator *op)
op,
"verts.out",
false,
- "create_cone segments=%i diameter1=%f diameter2=%f cap_ends=%b "
+ "create_cone segments=%i radius1=%f radius2=%f cap_ends=%b "
"cap_tris=%b depth=%f matrix=%m4 calc_uvs=%b",
RNA_int_get(op->ptr, "vertices"),
RNA_float_get(op->ptr, "radius1"),
@@ -642,7 +638,7 @@ static int add_primitive_uvsphere_exec(bContext *C, wmOperator *op)
op,
"verts.out",
false,
- "create_uvsphere u_segments=%i v_segments=%i diameter=%f matrix=%m4 calc_uvs=%b",
+ "create_uvsphere u_segments=%i v_segments=%i radius=%f matrix=%m4 calc_uvs=%b",
RNA_int_get(op->ptr, "segments"),
RNA_int_get(op->ptr, "ring_count"),
RNA_float_get(op->ptr, "radius"),
@@ -710,7 +706,7 @@ static int add_primitive_icosphere_exec(bContext *C, wmOperator *op)
op,
"verts.out",
false,
- "create_icosphere subdivisions=%i diameter=%f matrix=%m4 calc_uvs=%b",
+ "create_icosphere subdivisions=%i radius=%f matrix=%m4 calc_uvs=%b",
RNA_int_get(op->ptr, "subdivisions"),
RNA_float_get(op->ptr, "radius"),
creation_data.mat,
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index f95e3f3b236..beadbf2689e 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -332,8 +332,12 @@ 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 r_primmat[4][4])
+float ED_object_new_primitive_matrix(bContext *C,
+ Object *obedit,
+ const float loc[3],
+ const float rot[3],
+ const float scale[3],
+ float r_primmat[4][4])
{
Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C);
@@ -356,6 +360,10 @@ float ED_object_new_primitive_matrix(
invert_m3_m3(imat, mat);
mul_m3_v3(imat, r_primmat[3]);
+ if (scale != NULL) {
+ rescale_m4(r_primmat, scale);
+ }
+
{
const float dia = v3d ? ED_view3d_grid_scale(scene, v3d, NULL) :
ED_scene_grid_scale(scene, NULL);
@@ -863,7 +871,7 @@ static int effector_add_exec(bContext *C, wmOperator *op)
ED_object_editmode_enter_ex(bmain, scene, ob, 0);
float mat[4][4];
- ED_object_new_primitive_matrix(C, ob, loc, rot, mat);
+ ED_object_new_primitive_matrix(C, ob, loc, rot, NULL, mat);
mul_mat3_m4_fl(mat, dia);
BLI_addtail(&cu->editnurb->nurbs,
ED_curve_add_nurbs_primitive(C, ob, mat, CU_NURBS | CU_PRIM_PATH, 1));
@@ -999,7 +1007,7 @@ static int object_metaball_add_exec(bContext *C, wmOperator *op)
}
float mat[4][4];
- ED_object_new_primitive_matrix(C, obedit, loc, rot, mat);
+ ED_object_new_primitive_matrix(C, obedit, loc, rot, NULL, mat);
/* Halving here is done to account for constant values from #BKE_mball_element_add.
* While the default radius of the resulting meta element is 2,
* we want to pass in 1 so other values such as resolution are scaled by 1.0. */
@@ -1365,30 +1373,28 @@ static int object_gpencil_add_exec(bContext *C, wmOperator *op)
case GP_EMPTY: {
float mat[4][4];
- ED_object_new_primitive_matrix(C, ob, loc, rot, mat);
+ ED_object_new_primitive_matrix(C, ob, loc, rot, NULL, mat);
ED_gpencil_create_blank(C, ob, mat);
break;
}
case GP_STROKE: {
float radius = RNA_float_get(op->ptr, "radius");
+ float scale[3];
+ copy_v3_fl(scale, radius);
float mat[4][4];
- ED_object_new_primitive_matrix(C, ob, loc, rot, mat);
- mul_v3_fl(mat[0], radius);
- mul_v3_fl(mat[1], radius);
- mul_v3_fl(mat[2], radius);
+ ED_object_new_primitive_matrix(C, ob, loc, rot, scale, mat);
ED_gpencil_create_stroke(C, ob, mat);
break;
}
case GP_MONKEY: {
float radius = RNA_float_get(op->ptr, "radius");
+ float scale[3];
+ copy_v3_fl(scale, radius);
float mat[4][4];
- ED_object_new_primitive_matrix(C, ob, loc, rot, mat);
- mul_v3_fl(mat[0], radius);
- mul_v3_fl(mat[1], radius);
- mul_v3_fl(mat[2], radius);
+ ED_object_new_primitive_matrix(C, ob, loc, rot, scale, mat);
ED_gpencil_create_monkey(C, ob, mat);
break;
@@ -1397,12 +1403,11 @@ static int object_gpencil_add_exec(bContext *C, wmOperator *op)
case GP_LRT_COLLECTION:
case GP_LRT_OBJECT: {
float radius = RNA_float_get(op->ptr, "radius");
+ float scale[3];
+ copy_v3_fl(scale, radius);
float mat[4][4];
- ED_object_new_primitive_matrix(C, ob, loc, rot, mat);
- mul_v3_fl(mat[0], radius);
- mul_v3_fl(mat[1], radius);
- mul_v3_fl(mat[2], radius);
+ ED_object_new_primitive_matrix(C, ob, loc, rot, scale, mat);
ED_gpencil_create_lineart(C, ob);