Blender V4.3
BKE_mball.hh File Reference
#include "BLI_span.hh"

Go to the source code of this file.

Functions

MetaBallBKE_mball_add (Main *bmain, const char *name)
 
bool BKE_mball_is_any_selected (const MetaBall *mb)
 
bool BKE_mball_is_any_selected_multi (blender::Span< Base * > bases)
 
bool BKE_mball_is_any_unselected (const MetaBall *mb)
 
bool BKE_mball_is_same_group (const Object *ob1, const Object *ob2)
 
bool BKE_mball_is_basis_for (const Object *ob1, const Object *ob2)
 
bool BKE_mball_is_basis (const Object *ob)
 
ObjectBKE_mball_basis_find (Scene *scene, Object *ob)
 
void BKE_mball_properties_copy (Main *bmain, MetaBall *metaball_src)
 
bool BKE_mball_minmax_ex (const MetaBall *mb, float min[3], float max[3], const float obmat[4][4], short flag)
 
bool BKE_mball_minmax (const MetaBall *mb, float min[3], float max[3])
 
bool BKE_mball_center_median (const MetaBall *mb, float r_cent[3])
 
bool BKE_mball_center_bounds (const MetaBall *mb, float r_cent[3])
 
void BKE_mball_transform (MetaBall *mb, const float mat[4][4], bool do_props)
 
void BKE_mball_translate (MetaBall *mb, const float offset[3])
 
MetaElemBKE_mball_element_add (MetaBall *mb, int type)
 
int BKE_mball_select_count (const MetaBall *mb)
 
int BKE_mball_select_count_multi (blender::Span< Base * > bases)
 
bool BKE_mball_select_all (MetaBall *mb)
 
bool BKE_mball_select_all_multi_ex (blender::Span< Base * > bases)
 
bool BKE_mball_deselect_all (MetaBall *mb)
 
bool BKE_mball_deselect_all_multi_ex (blender::Span< Base * > bases)
 
bool BKE_mball_select_swap (MetaBall *mb)
 
bool BKE_mball_select_swap_multi_ex (blender::Span< Base * > bases)
 
void BKE_mball_data_update (Depsgraph *depsgraph, Scene *scene, Object *ob)
 

Function Documentation

◆ BKE_mball_add()

MetaBall * BKE_mball_add ( Main * bmain,
const char * name )

Definition at line 177 of file mball.cc.

References BKE_id_new(), and ID_MB.

Referenced by BKE_object_obdata_add_from_type().

◆ BKE_mball_basis_find()

Object * BKE_mball_basis_find ( Scene * scene,
Object * ob )

This function finds the basis meta-ball.

Basis meta-ball doesn't include any number at the end of its name. All meta-balls with same base of name can be blended. meta-balls with different basic name can't be blended.

Warning
BKE_mball_is_basis() can fail on returned object, see function docs for details.

Definition at line 394 of file mball.cc.

References BASE_FROM_DUPLI, BKE_view_layer_object_bases_get(), BKE_view_layer_synced_ensure(), BLI_string_split_name_number(), Object::id, LISTBASE_FOREACH, MAX_ID_NAME, ID::name, OB_MBALL, STREQ, and Object::type.

Referenced by BKE_mball_data_update(), blender::deg::DepsgraphRelationBuilder::build_object_data_geometry(), and blender::ed::object::object_convert_exec().

◆ BKE_mball_center_bounds()

bool BKE_mball_center_bounds ( const MetaBall * mb,
float r_cent[3] )

Definition at line 488 of file mball.cc.

References BKE_mball_minmax(), mid_v3_v3v3(), and min.

Referenced by blender::ed::object::object_origin_set_exec().

◆ BKE_mball_center_median()

bool BKE_mball_center_median ( const MetaBall * mb,
float r_cent[3] )

◆ BKE_mball_data_update()

◆ BKE_mball_deselect_all()

bool BKE_mball_deselect_all ( MetaBall * mb)

◆ BKE_mball_deselect_all_multi_ex()

bool BKE_mball_deselect_all_multi_ex ( blender::Span< Base * > bases)

◆ BKE_mball_element_add()

MetaElem * BKE_mball_element_add ( MetaBall * mb,
int type )

Most simple meta-element adding function.

Note
don't do context manipulation here (rna uses).

Definition at line 183 of file mball.cc.

References BLI_addtail(), MetaBall::elems, MetaElem::expx, MetaElem::expy, MetaElem::expz, MetaElem::flag, MB_BALL, MB_CUBE, MB_ELIPSOID, MB_PLANE, MB_SCALE_RAD, MB_TUBE, MetaElem::quat, MetaElem::rad, MetaElem::s, MetaElem::type, and unit_qt().

Referenced by ED_mball_add_primitive().

◆ BKE_mball_is_any_selected()

bool BKE_mball_is_any_selected ( const MetaBall * mb)

◆ BKE_mball_is_any_selected_multi()

bool BKE_mball_is_any_selected_multi ( blender::Span< Base * > bases)

Referenced by mball_select_all_exec().

◆ BKE_mball_is_any_unselected()

bool BKE_mball_is_any_unselected ( const MetaBall * mb)

Definition at line 296 of file mball.cc.

References MetaBall::editelems, LISTBASE_FOREACH, and SELECT.

Referenced by select_random_metaelems_exec().

◆ BKE_mball_is_basis()

bool BKE_mball_is_basis ( const Object * ob)

Test, if ob is a basis meta-ball.

It test last character of Object ID name. If last character is digit it return 0, else it return 1.

Definition at line 230 of file mball.cc.

References Object::id, len, and ID::name.

Referenced by BKE_mball_is_basis_for(), libblock_remap_data_postprocess_object_update(), blender::ed::object::object_convert_exec(), blender::draw::overlay::Bounds::object_sync(), and OVERLAY_bounds().

◆ BKE_mball_is_basis_for()

bool BKE_mball_is_basis_for ( const Object * ob1,
const Object * ob2 )

Return true if ob1 and ob2 are part of the same metaBall group, and ob1 is its basis.

Definition at line 269 of file mball.cc.

References BKE_mball_is_basis(), and BKE_mball_is_same_group().

Referenced by libblock_remap_data_postprocess_object_update().

◆ BKE_mball_is_same_group()

bool BKE_mball_is_same_group ( const Object * ob1,
const Object * ob2 )

Return true if ob1 and ob2 are part of the same metaBall group.

Note
Currently checks whether their two base names (without numerical suffix) is the same.

Definition at line 253 of file mball.cc.

References BLI_string_split_name_number(), Object::id, MAX_ID_NAME, ID::name, and STREQ.

Referenced by BKE_mball_is_basis_for().

◆ BKE_mball_minmax()

bool BKE_mball_minmax ( const MetaBall * mb,
float min[3],
float max[3] )

◆ BKE_mball_minmax_ex()

bool BKE_mball_minmax_ex ( const MetaBall * mb,
float min[3],
float max[3],
const float obmat[4][4],
short flag )

◆ BKE_mball_properties_copy()

void BKE_mball_properties_copy ( Main * bmain,
MetaBall * metaball_src )

Copy some properties from a meta-ball obdata to all other meta-ball obdata belonging to the same family (i.e. object sharing the same name basis).

When some properties (wire-size, threshold, update flags) of meta-ball are changed, then this properties are copied to all meta-balls in same "group" (meta-balls with same base name: MBall, MBall.001, MBall.002, etc). The most important is to copy properties to the base meta-ball, because this meta-ball influences polygonization of meta-balls.

WARNING: This code does not cover all potential corner-cases. E.g. if:

|   Object   |   ObData   |
| ---------- | ---------- |
| Meta_A     | Meta_A     |
| Meta_A.001 | Meta_A.001 |
| Meta_B     | Meta_A     |
| Meta_B.001 | Meta_B.001 |

Calling this function with metaball_src being Meta_A.001 will update Meta_A, but NOT Meta_B.001. So in the 'Meta_B' family, the two metaballs will have unmatching settings now.

Solving this case would drastically increase the complexity of this code though, so don't think it would be worth it.

Definition at line 315 of file mball.cc.

References BLI_string_split_name_number(), Object::data, ListBase::first, Object::id, ID_IS_EDITABLE, MAX_ID_NAME, mball_data_properties_copy(), ID::name, ID::next, OB_MBALL, Main::objects, ID::prev, STREQ, and Object::type.

◆ BKE_mball_select_all()

bool BKE_mball_select_all ( MetaBall * mb)

Definition at line 555 of file mball.cc.

References MetaBall::editelems, LISTBASE_FOREACH, and SELECT.

Referenced by BKE_mball_select_all_multi_ex().

◆ BKE_mball_select_all_multi_ex()

bool BKE_mball_select_all_multi_ex ( blender::Span< Base * > bases)

Referenced by mball_select_all_exec().

◆ BKE_mball_select_count()

int BKE_mball_select_count ( const MetaBall * mb)

Definition at line 533 of file mball.cc.

References MetaBall::editelems, LISTBASE_FOREACH, and SELECT.

Referenced by BKE_mball_select_count_multi().

◆ BKE_mball_select_count_multi()

int BKE_mball_select_count_multi ( blender::Span< Base * > bases)

◆ BKE_mball_select_swap()

bool BKE_mball_select_swap ( MetaBall * mb)

Definition at line 602 of file mball.cc.

References MetaBall::editelems, LISTBASE_FOREACH, and SELECT.

Referenced by BKE_mball_select_swap_multi_ex().

◆ BKE_mball_select_swap_multi_ex()

bool BKE_mball_select_swap_multi_ex ( blender::Span< Base * > bases)

Referenced by mball_select_all_exec().

◆ BKE_mball_transform()

◆ BKE_mball_translate()

void BKE_mball_translate ( MetaBall * mb,
const float offset[3] )

Definition at line 526 of file mball.cc.

References add_v3_v3(), MetaBall::elems, and LISTBASE_FOREACH.

Referenced by blender::ed::object::object_origin_set_exec().