fix [#24780] Metaballs are not drawn correctly in new scenes

this is a can of worms, at the moment blender depends on broken behavior for metaballs:
 find_basis_mball() can return a metaball object that fails a is_basis_mball() check which makes this logic very confusing (added note about this in mball.c).

Metaballs needs a refactor however at least make drawing fail consistently,
For wire draw is_basis_mball() wasn't being checked, for solid drawing it was (hence the strange wire frame).

For now the motherball needs to exist in the main scene else it wont work.
This commit is contained in:
2010-11-18 04:26:50 +00:00
parent 7045ef617f
commit 48524d6e91
6 changed files with 40 additions and 26 deletions

View File

@@ -309,6 +309,19 @@ float *make_orco_mball(Object *ob, ListBase *dispbase)
return orcodata;
}
/* Note on mball basis stuff 2.5x (this is a can of worms)
* This really needs a rewrite/refactorm its totally broken in anything other then basic cases
* Multiple Scenes + Set Scenes & mixing mball basis SHOULD work but fails to update the depsgraph on rename
* and linking into scenes or removal of basis mball. so take care when changing this code.
*
* Main idiot thing here is that the system returns find_basis_mball() objects which fail a is_basis_mball() test.
*
* Not only that but the depsgraph and ther areas depend on this behavior!, so making small fixes here isnt worth it.
* - campbell
*/
/** \brief Test, if Object *ob is basic MetaBall.
*
* It test last character of Object ID name. If last character
@@ -385,6 +398,8 @@ void copy_mball_properties(Scene *scene, Object *active_object)
* its name. All MetaBalls with same base of name can be
* blended. MetaBalls with different basic name can't be
* blended.
*
* warning!, is_basis_mball() can fail on returned object, see long note above.
*/
Object *find_basis_mball(Scene *scene, Object *basis)
{

View File

@@ -486,16 +486,6 @@ void OBJECT_OT_camera_add(wmOperatorType *ot)
/* ***************** add primitives *************** */
static EnumPropertyItem prop_metaball_types[]= {
{MB_BALL, "MBALL_BALL", ICON_META_BALL, "Meta Ball", ""},
{MB_TUBE, "MBALL_CAPSULE", ICON_META_CAPSULE, "Meta Capsule", ""},
{MB_PLANE, "MBALL_PLANE", ICON_META_PLANE, "Meta Plane", ""},
{MB_CUBE, "MBALL_CUBE", ICON_META_CUBE, "Meta Cube", ""},
{MB_ELIPSOID, "MBALL_ELLIPSOID", ICON_META_ELLIPSOID, "Meta Ellipsoid", ""},
{0, NULL, 0, NULL, NULL}
};
static int object_metaball_add_exec(bContext *C, wmOperator *op)
{
Object *obedit= CTX_data_edit_object(C);
@@ -565,7 +555,7 @@ void OBJECT_OT_metaball_add(wmOperatorType *ot)
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
RNA_def_enum(ot->srna, "type", prop_metaball_types, 0, "Primitive", "");
RNA_def_enum(ot->srna, "type", metaelem_type_items, 0, "Primitive", "");
ED_object_add_generic_props(ot, TRUE);
}

View File

@@ -5352,10 +5352,12 @@ static void draw_bounding_volume(Scene *scene, Object *ob)
bb= ob->bb ? ob->bb : ( (Curve *)ob->data )->bb;
}
else if(ob->type==OB_MBALL) {
bb= ob->bb;
if(bb==0) {
makeDispListMBall(scene, ob);
if(is_basis_mball(ob)) {
bb= ob->bb;
if(bb==0) {
makeDispListMBall(scene, ob);
bb= ob->bb;
}
}
}
else {
@@ -5435,8 +5437,10 @@ static void drawSolidSelect(Scene *scene, View3D *v3d, ARegion *ar, Base *base)
draw_index_wire= 1;
}
} else if (ob->type==OB_MBALL) {
if((base->flag & OB_FROMDUPLI)==0)
drawDispListwire(&ob->disp);
if(is_basis_mball(ob)) {
if((base->flag & OB_FROMDUPLI)==0)
drawDispListwire(&ob->disp);
}
}
else if(ob->type==OB_ARMATURE) {
if(!(ob->mode & OB_MODE_POSE))
@@ -5490,7 +5494,9 @@ static void drawWireExtra(Scene *scene, RegionView3D *rv3d, Object *ob)
draw_index_wire= 1;
}
} else if (ob->type==OB_MBALL) {
drawDispListwire(&ob->disp);
if(is_basis_mball(ob)) {
drawDispListwire(&ob->disp);
}
}
glDepthMask(1);

View File

@@ -36,6 +36,7 @@ extern EnumPropertyItem DummyRNA_NULL_items[];
extern EnumPropertyItem DummyRNA_DEFAULT_items[];
extern EnumPropertyItem object_mode_items[];
extern EnumPropertyItem metaelem_type_items[];
extern EnumPropertyItem proportional_falloff_items[];
extern EnumPropertyItem proportional_editing_items[];

View File

@@ -25,6 +25,7 @@
#include <stdlib.h>
#include "RNA_define.h"
#include "RNA_enum_types.h"
#include "rna_internal.h"
@@ -138,14 +139,6 @@ static void rna_MetaBall_elements_remove(MetaBall *mb, ReportList *reports, Meta
#else
static EnumPropertyItem metaelem_type_items[] = {
{MB_BALL, "BALL", ICON_META_BALL, "Ball", ""},
{MB_TUBE, "CAPSULE", ICON_META_CAPSULE, "Capsule", ""},
{MB_PLANE, "PLANE", ICON_META_PLANE, "Plane", ""},
{MB_ELIPSOID, "ELLIPSOID", ICON_META_ELLIPSOID, "Ellipsoid", ""}, // NOTE: typo at original definition!
{MB_CUBE, "CUBE", ICON_META_CUBE, "Cube", ""},
{0, NULL, 0, NULL, NULL}};
static void rna_def_metaelement(BlenderRNA *brna)
{
StructRNA *srna;
@@ -155,7 +148,7 @@ static void rna_def_metaelement(BlenderRNA *brna)
RNA_def_struct_sdna(srna, "MetaElem");
RNA_def_struct_ui_text(srna, "Meta Element", "Blobby element in a MetaBall datablock");
RNA_def_struct_ui_icon(srna, ICON_OUTLINER_DATA_META);
/* enums */
prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, metaelem_type_items);

View File

@@ -40,6 +40,7 @@
#include "DNA_object_types.h"
#include "DNA_property_types.h"
#include "DNA_scene_types.h"
#include "DNA_meta_types.h"
#include "BLO_sys_types.h" /* needed for intptr_t used in ED_mesh.h */
#include "ED_mesh.h"
@@ -80,6 +81,14 @@ static EnumPropertyItem collision_bounds_items[] = {
//{OB_DYN_MESH, "DYNAMIC_MESH", 0, "Dynamic Mesh", ""},
{0, NULL, 0, NULL, NULL}};
EnumPropertyItem metaelem_type_items[] = {
{MB_BALL, "BALL", ICON_META_BALL, "Ball", ""},
{MB_TUBE, "CAPSULE", ICON_META_CAPSULE, "Capsule", ""},
{MB_PLANE, "PLANE", ICON_META_PLANE, "Plane", ""},
{MB_ELIPSOID, "ELLIPSOID", ICON_META_ELLIPSOID, "Ellipsoid", ""}, // NOTE: typo at original definition!
{MB_CUBE, "CUBE", ICON_META_CUBE, "Cube", ""},
{0, NULL, 0, NULL, NULL}};
/* used for 2 enums */
#define OBTYPE_CU_CURVE {OB_CURVE, "CURVE", 0, "Curve", ""}
#define OBTYPE_CU_SURF {OB_SURF, "SURFACE", 0, "Surface", ""}