Cleanup: style, use const args
This commit is contained in:
@@ -61,17 +61,18 @@ float *BKE_mball_make_orco(struct Object *ob, struct ListBase *dispbase);
|
||||
|
||||
void BKE_mball_properties_copy(struct Scene *scene, struct Object *active_object);
|
||||
|
||||
bool BKE_mball_minmax(struct MetaBall *mb, float min[3], float max[3]);
|
||||
bool BKE_mball_minmax_ex(struct MetaBall *mb, float min[3], float max[3],
|
||||
float obmat[4][4], const short flag);
|
||||
bool BKE_mball_center_median(struct MetaBall *mb, float r_cent[3]);
|
||||
bool BKE_mball_center_bounds(struct MetaBall *mb, float r_cent[3]);
|
||||
bool BKE_mball_minmax_ex(
|
||||
const struct MetaBall *mb, float min[3], float max[3],
|
||||
const float obmat[4][4], const short flag);
|
||||
bool BKE_mball_minmax(const struct MetaBall *mb, float min[3], float max[3]);
|
||||
bool BKE_mball_center_median(const struct MetaBall *mb, float r_cent[3]);
|
||||
bool BKE_mball_center_bounds(const struct MetaBall *mb, float r_cent[3]);
|
||||
void BKE_mball_transform(struct MetaBall *mb, float mat[4][4], const bool do_props);
|
||||
void BKE_mball_translate(struct MetaBall *mb, const float offset[3]);
|
||||
|
||||
struct MetaElem *BKE_mball_element_add(struct MetaBall *mb, const int type);
|
||||
|
||||
int BKE_mball_select_count(struct MetaBall *mb);
|
||||
int BKE_mball_select_count(const struct MetaBall *mb);
|
||||
int BKE_mball_select_count_multi(struct Object **objects, int objects_len);
|
||||
void BKE_mball_select_all(struct MetaBall *mb);
|
||||
void BKE_mball_select_all_multi(struct Object **objects, int objects_len);
|
||||
|
||||
@@ -66,8 +66,6 @@
|
||||
#include "BKE_object.h"
|
||||
#include "BKE_material.h"
|
||||
|
||||
//#include "DEG_depsgraph.h"
|
||||
|
||||
/* Functions */
|
||||
|
||||
/** Free (or release) any data used by this mball (does not free the mball itself). */
|
||||
@@ -443,17 +441,17 @@ Object *BKE_mball_basis_find(Scene *scene, Object *basis)
|
||||
return basis;
|
||||
}
|
||||
|
||||
bool BKE_mball_minmax_ex(MetaBall *mb, float min[3], float max[3],
|
||||
float obmat[4][4], const short flag)
|
||||
bool BKE_mball_minmax_ex(
|
||||
const MetaBall *mb, float min[3], float max[3],
|
||||
const float obmat[4][4], const short flag)
|
||||
{
|
||||
const float scale = obmat ? mat4_to_scale(obmat) : 1.0f;
|
||||
MetaElem *ml;
|
||||
bool changed = false;
|
||||
float centroid[3], vec[3];
|
||||
|
||||
INIT_MINMAX(min, max);
|
||||
|
||||
for (ml = mb->elems.first; ml; ml = ml->next) {
|
||||
for (const MetaElem *ml = mb->elems.first; ml; ml = ml->next) {
|
||||
if ((ml->flag & flag) == flag) {
|
||||
const float scale_mb = (ml->rad * 0.5f) * scale;
|
||||
int i;
|
||||
@@ -480,27 +478,24 @@ bool BKE_mball_minmax_ex(MetaBall *mb, float min[3], float max[3],
|
||||
|
||||
|
||||
/* basic vertex data functions */
|
||||
bool BKE_mball_minmax(MetaBall *mb, float min[3], float max[3])
|
||||
bool BKE_mball_minmax(const MetaBall *mb, float min[3], float max[3])
|
||||
{
|
||||
MetaElem *ml;
|
||||
|
||||
INIT_MINMAX(min, max);
|
||||
|
||||
for (ml = mb->elems.first; ml; ml = ml->next) {
|
||||
for (const MetaElem *ml = mb->elems.first; ml; ml = ml->next) {
|
||||
minmax_v3v3_v3(min, max, &ml->x);
|
||||
}
|
||||
|
||||
return (BLI_listbase_is_empty(&mb->elems) == false);
|
||||
}
|
||||
|
||||
bool BKE_mball_center_median(MetaBall *mb, float r_cent[3])
|
||||
bool BKE_mball_center_median(const MetaBall *mb, float r_cent[3])
|
||||
{
|
||||
MetaElem *ml;
|
||||
int total = 0;
|
||||
|
||||
zero_v3(r_cent);
|
||||
|
||||
for (ml = mb->elems.first; ml; ml = ml->next) {
|
||||
for (const MetaElem *ml = mb->elems.first; ml; ml = ml->next) {
|
||||
add_v3_v3(r_cent, &ml->x);
|
||||
total++;
|
||||
}
|
||||
@@ -512,7 +507,7 @@ bool BKE_mball_center_median(MetaBall *mb, float r_cent[3])
|
||||
return (total != 0);
|
||||
}
|
||||
|
||||
bool BKE_mball_center_bounds(MetaBall *mb, float r_cent[3])
|
||||
bool BKE_mball_center_bounds(const MetaBall *mb, float r_cent[3])
|
||||
{
|
||||
float min[3], max[3];
|
||||
|
||||
@@ -526,26 +521,25 @@ bool BKE_mball_center_bounds(MetaBall *mb, float r_cent[3])
|
||||
|
||||
void BKE_mball_transform(MetaBall *mb, float mat[4][4], const bool do_props)
|
||||
{
|
||||
MetaElem *me;
|
||||
float quat[4];
|
||||
const float scale = mat4_to_scale(mat);
|
||||
const float scale_sqrt = sqrtf(scale);
|
||||
|
||||
mat4_to_quat(quat, mat);
|
||||
|
||||
for (me = mb->elems.first; me; me = me->next) {
|
||||
mul_m4_v3(mat, &me->x);
|
||||
mul_qt_qtqt(me->quat, quat, me->quat);
|
||||
for (MetaElem *ml = mb->elems.first; ml; ml = ml->next) {
|
||||
mul_m4_v3(mat, &ml->x);
|
||||
mul_qt_qtqt(ml->quat, quat, ml->quat);
|
||||
|
||||
if (do_props) {
|
||||
me->rad *= scale;
|
||||
ml->rad *= scale;
|
||||
/* hrmf, probably elems shouldn't be
|
||||
* treating scale differently - campbell */
|
||||
if (!MB_TYPE_SIZE_SQUARED(me->type)) {
|
||||
mul_v3_fl(&me->expx, scale);
|
||||
if (!MB_TYPE_SIZE_SQUARED(ml->type)) {
|
||||
mul_v3_fl(&ml->expx, scale);
|
||||
}
|
||||
else {
|
||||
mul_v3_fl(&me->expx, scale_sqrt);
|
||||
mul_v3_fl(&ml->expx, scale_sqrt);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -553,19 +547,16 @@ void BKE_mball_transform(MetaBall *mb, float mat[4][4], const bool do_props)
|
||||
|
||||
void BKE_mball_translate(MetaBall *mb, const float offset[3])
|
||||
{
|
||||
MetaElem *ml;
|
||||
|
||||
for (ml = mb->elems.first; ml; ml = ml->next) {
|
||||
for (MetaElem *ml = mb->elems.first; ml; ml = ml->next) {
|
||||
add_v3_v3(&ml->x, offset);
|
||||
}
|
||||
}
|
||||
|
||||
/* *** select funcs *** */
|
||||
int BKE_mball_select_count(struct MetaBall *mb) {
|
||||
int BKE_mball_select_count(const MetaBall *mb)
|
||||
{
|
||||
int sel = 0;
|
||||
MetaElem *ml;
|
||||
|
||||
for (ml = mb->editelems->first; ml; ml = ml->next) {
|
||||
for (const MetaElem *ml = mb->editelems->first; ml; ml = ml->next) {
|
||||
if (ml->flag & SELECT) {
|
||||
sel++;
|
||||
}
|
||||
@@ -573,22 +564,20 @@ int BKE_mball_select_count(struct MetaBall *mb) {
|
||||
return sel;
|
||||
}
|
||||
|
||||
int BKE_mball_select_count_multi(Object **objects, int objects_len) {
|
||||
|
||||
int BKE_mball_select_count_multi(Object **objects, int objects_len)
|
||||
{
|
||||
int sel = 0;
|
||||
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
|
||||
Object *obedit = objects[ob_index];
|
||||
MetaBall *mb = (MetaBall *)obedit->data;
|
||||
const Object *obedit = objects[ob_index];
|
||||
const MetaBall *mb = (MetaBall *)obedit->data;
|
||||
sel += BKE_mball_select_count(mb);
|
||||
}
|
||||
return sel;
|
||||
}
|
||||
|
||||
void BKE_mball_select_all(struct MetaBall *mb)
|
||||
void BKE_mball_select_all(MetaBall *mb)
|
||||
{
|
||||
MetaElem *ml;
|
||||
|
||||
for (ml = mb->editelems->first; ml; ml = ml->next) {
|
||||
for (MetaElem *ml = mb->editelems->first; ml; ml = ml->next) {
|
||||
ml->flag |= SELECT;
|
||||
}
|
||||
}
|
||||
@@ -597,16 +586,14 @@ void BKE_mball_select_all_multi(Object **objects, int objects_len)
|
||||
{
|
||||
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
|
||||
Object *obedit = objects[ob_index];
|
||||
MetaBall *mb = (MetaBall *)obedit->data;
|
||||
MetaBall *mb = obedit->data;
|
||||
BKE_mball_select_all(mb);
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_mball_deselect_all(MetaBall *mb)
|
||||
{
|
||||
MetaElem *ml;
|
||||
|
||||
for (ml = mb->editelems->first; ml; ml = ml->next) {
|
||||
for (MetaElem *ml = mb->editelems->first; ml; ml = ml->next) {
|
||||
ml->flag &= ~SELECT;
|
||||
}
|
||||
}
|
||||
@@ -615,17 +602,15 @@ void BKE_mball_deselect_all_multi(Object **objects, int objects_len)
|
||||
{
|
||||
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
|
||||
Object *obedit = objects[ob_index];
|
||||
MetaBall *mb = (MetaBall *)obedit->data;
|
||||
MetaBall *mb = obedit->data;
|
||||
|
||||
BKE_mball_deselect_all(mb);
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_mball_select_swap(struct MetaBall *mb)
|
||||
void BKE_mball_select_swap(MetaBall *mb)
|
||||
{
|
||||
MetaElem *ml;
|
||||
|
||||
for (ml = mb->editelems->first; ml; ml = ml->next) {
|
||||
for (MetaElem *ml = mb->editelems->first; ml; ml = ml->next) {
|
||||
ml->flag ^= SELECT;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,7 +259,7 @@ static bool mball_select_similar_type(Object *obedit, MetaBall *mb, int type, co
|
||||
mul_m3_v3(smat, radius_vec);
|
||||
radius = (radius_vec[0] + radius_vec[1] + radius_vec[2]) / 3;
|
||||
|
||||
if(ED_select_similar_compare_float_tree(tree, radius, thresh, SIM_CMP_EQ)) {
|
||||
if (ED_select_similar_compare_float_tree(tree, radius, thresh, SIM_CMP_EQ)) {
|
||||
select = true;
|
||||
}
|
||||
break;
|
||||
@@ -267,7 +267,7 @@ static bool mball_select_similar_type(Object *obedit, MetaBall *mb, int type, co
|
||||
case SIMMBALL_STIFFNESS:
|
||||
{
|
||||
float s = ml->s;
|
||||
if(ED_select_similar_compare_float_tree(tree, s, thresh, SIM_CMP_EQ)) {
|
||||
if (ED_select_similar_compare_float_tree(tree, s, thresh, SIM_CMP_EQ)) {
|
||||
select = true;
|
||||
}
|
||||
break;
|
||||
@@ -359,7 +359,7 @@ static int mball_select_similar_exec(bContext *C, wmOperator *op)
|
||||
MetaBall *mb = (MetaBall *)obedit->data;
|
||||
bool changed = false;
|
||||
|
||||
switch(type) {
|
||||
switch (type) {
|
||||
case SIMMBALL_TYPE:
|
||||
{
|
||||
MetaElem *ml;
|
||||
|
||||
Reference in New Issue
Block a user