diff options
Diffstat (limited to 'source/blender/makesrna/intern/rna_object_api.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_object_api.c | 180 |
1 files changed, 90 insertions, 90 deletions
diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index 78c3c665797..51fd52360e4 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -39,9 +39,9 @@ #include "DNA_object_types.h" #include "DNA_modifier_types.h" -// #include "BLO_sys_types.h" /* needed for intptr_t used in ED_mesh.h */ +/* #include "BLO_sys_types.h" *//* needed for intptr_t used in ED_mesh.h */ -// #include "ED_mesh.h" +/* #include "ED_mesh.h" */ #ifdef RNA_RUNTIME @@ -92,12 +92,12 @@ Mesh *rna_Object_to_mesh(Object *ob, ReportList *reports, Scene *sce, int apply_ case OB_SURF: /* copies object and modifiers (but not the data) */ - tmpobj= copy_object(ob); + tmpobj = copy_object(ob); tmpcu = (Curve *)tmpobj->data; tmpcu->id.us--; /* if getting the original caged mesh, delete object modifiers */ - if( cage ) + if ( cage ) object_free_modifiers(tmpobj); /* copies the data */ @@ -133,12 +133,12 @@ Mesh *rna_Object_to_mesh(Object *ob, ReportList *reports, Scene *sce, int apply_ /* todo, re-generatre for render-res */ /* metaball_polygonize(scene, ob) */ - if(ob != basis_ob) + if (ob != basis_ob) return NULL; /* only do basis metaball */ tmpmesh = add_mesh("Mesh"); - if(render) { + if (render) { ListBase disp = {NULL, NULL}; makeDispListMBall_forRender(sce, ob, &disp); mball_to_mesh(&disp, tmpmesh); @@ -187,8 +187,8 @@ Mesh *rna_Object_to_mesh(Object *ob, ReportList *reports, Scene *sce, int apply_ tmpmesh->totcol = tmpcu->totcol; /* free old material list (if it exists) and adjust user counts */ - if( tmpcu->mat ) { - for( i = tmpcu->totcol; i-- > 0; ) { + if ( tmpcu->mat ) { + for ( i = tmpcu->totcol; i-- > 0; ) { /* are we an object material or data based? */ tmpmesh->mat[i] = ob->matbits[i] ? ob->mat[i] : tmpcu->mat[i]; @@ -207,8 +207,8 @@ Mesh *rna_Object_to_mesh(Object *ob, ReportList *reports, Scene *sce, int apply_ tmpmesh->totcol = tmpmb->totcol; /* free old material list (if it exists) and adjust user counts */ - if( tmpmb->mat ) { - for( i = tmpmb->totcol; i-- > 0; ) { + if ( tmpmb->mat ) { + for ( i = tmpmb->totcol; i-- > 0; ) { tmpmesh->mat[i] = tmpmb->mat[i]; /* CRASH HERE ??? */ if (tmpmesh->mat[i]) { tmpmb->mat[i]->id.us++; @@ -220,13 +220,13 @@ Mesh *rna_Object_to_mesh(Object *ob, ReportList *reports, Scene *sce, int apply_ case OB_MESH: if (!cage) { - Mesh *origmesh= ob->data; - tmpmesh->flag= origmesh->flag; + Mesh *origmesh = ob->data; + tmpmesh->flag = origmesh->flag; tmpmesh->mat = MEM_dupallocN(origmesh->mat); tmpmesh->totcol = origmesh->totcol; - tmpmesh->smoothresh= origmesh->smoothresh; - if( origmesh->mat ) { - for( i = origmesh->totcol; i-- > 0; ) { + tmpmesh->smoothresh = origmesh->smoothresh; + if ( origmesh->mat ) { + for ( i = origmesh->totcol; i-- > 0; ) { /* are we an object material or data based? */ tmpmesh->mat[i] = ob->matbits[i] ? ob->mat[i] : origmesh->mat[i]; @@ -264,35 +264,35 @@ static void dupli_render_particle_set(Scene *scene, Object *ob, int level, int e unit_m4(mat); - if(level >= MAX_DUPLI_RECUR) + if (level >= MAX_DUPLI_RECUR) return; - if(ob->transflag & OB_DUPLIPARTS) { - for(psys=ob->particlesystem.first; psys; psys=psys->next) { - if(ELEM(psys->part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) { - if(enable) + if (ob->transflag & OB_DUPLIPARTS) { + for (psys = ob->particlesystem.first; psys; psys = psys->next) { + if (ELEM(psys->part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) { + if (enable) psys_render_set(ob, psys, mat, mat, 1, 1, 0.f); else psys_render_restore(ob, psys); } } - if(level == 0 && enable) { + if (level == 0 && enable) { /* this is to make sure we get render level duplis in groups: * the derivedmesh must be created before init_render_mesh, * since object_duplilist does dupliparticles before that */ dm = mesh_create_derived_render(scene, ob, CD_MASK_BAREMESH|CD_MASK_MTFACE|CD_MASK_MCOL); dm->release(dm); - for(psys=ob->particlesystem.first; psys; psys=psys->next) + for (psys = ob->particlesystem.first; psys; psys = psys->next) psys_get_modifier(ob, psys)->flag &= ~eParticleSystemFlag_psys_updated; } } - if(ob->dup_group==NULL) return; - group= ob->dup_group; + if (ob->dup_group == NULL) return; + group = ob->dup_group; - for(go= group->gobject.first; go; go= go->next) + for (go = group->gobject.first; go; go = go->next) dupli_render_particle_set(scene, go->ob, level+1, enable); } /* When no longer needed, duplilist should be freed with Object.free_duplilist */ @@ -308,12 +308,12 @@ void rna_Object_create_duplilist(Object *ob, ReportList *reports, Scene *sce) BKE_reportf(reports, RPT_WARNING, "Object.dupli_list has not been freed"); free_object_duplilist(ob->duplilist); - ob->duplilist= NULL; + ob->duplilist = NULL; } - if(G.rendering) + if (G.rendering) dupli_render_particle_set(sce, ob, 0, 1); - ob->duplilist= object_duplilist(sce, ob); - if(G.rendering) + ob->duplilist = object_duplilist(sce, ob); + if (G.rendering) dupli_render_particle_set(sce, ob, 0, 0); /* ob->duplilist should now be freed with Object.free_duplilist */ } @@ -322,16 +322,16 @@ void rna_Object_free_duplilist(Object *ob) { if (ob->duplilist) { free_object_duplilist(ob->duplilist); - ob->duplilist= NULL; + ob->duplilist = NULL; } } static PointerRNA rna_Object_shape_key_add(Object *ob, bContext *C, ReportList *reports, const char *name, int from_mix) { - Scene *scene= CTX_data_scene(C); - KeyBlock *kb= NULL; + Scene *scene = CTX_data_scene(C); + KeyBlock *kb = NULL; - if((kb=object_insert_shape_key(scene, ob, name, from_mix))) { + if ((kb = object_insert_shape_key(scene, ob, name, from_mix))) { PointerRNA keyptr; RNA_pointer_create((ID *)ob->data, &RNA_ShapeKey, kb, &keyptr); @@ -350,7 +350,7 @@ int rna_Object_is_visible(Object *ob, Scene *sce) return !(ob->restrictflag & OB_RESTRICT_VIEW) && (ob->lay & sce->lay); } -/* +#if 0 static void rna_Mesh_assign_verts_to_group(Object *ob, bDeformGroup *group, int *indices, int totindex, float weight, int assignmode) { if (ob->type != OB_MESH) { @@ -370,13 +370,13 @@ static void rna_Mesh_assign_verts_to_group(Object *ob, bDeformGroup *group, int return; } - // makes a set of dVerts corresponding to the mVerts + /* makes a set of dVerts corresponding to the mVerts */ if (!me->dvert) create_dverts(&me->id); - // loop list adding verts to group - for (i= 0; i < totindex; i++) { - if(i < 0 || i >= me->totvert) { + /* loop list adding verts to group */ + for (i = 0; i < totindex; i++) { + if (i < 0 || i >= me->totvert) { BKE_report(reports, RPT_ERROR, "Bad vertex index in list"); return; } @@ -384,13 +384,13 @@ static void rna_Mesh_assign_verts_to_group(Object *ob, bDeformGroup *group, int add_vert_defnr(ob, group_index, i, weight, assignmode); } } -*/ +#endif void rna_Object_ray_cast(Object *ob, ReportList *reports, float ray_start[3], float ray_end[3], float r_location[3], float r_normal[3], int *index) { - BVHTreeFromMesh treeData= {NULL}; + BVHTreeFromMesh treeData = {NULL}; - if(ob->derivedFinal==NULL) { + if (ob->derivedFinal == NULL) { BKE_reportf(reports, RPT_ERROR, "object \"%s\" has no mesh data to be used for ray casting", ob->id.name+2); return; } @@ -398,7 +398,7 @@ void rna_Object_ray_cast(Object *ob, ReportList *reports, float ray_start[3], fl /* no need to managing allocation or freeing of the BVH data. this is generated and freed as needed */ bvhtree_from_mesh_faces(&treeData, ob->derivedFinal, 0.0f, 4, 6); - if(treeData.tree==NULL) { + if (treeData.tree == NULL) { BKE_reportf(reports, RPT_ERROR, "object \"%s\" could not create internal data for ray casting", ob->id.name+2); return; } @@ -407,14 +407,14 @@ void rna_Object_ray_cast(Object *ob, ReportList *reports, float ray_start[3], fl float ray_nor[3], dist; sub_v3_v3v3(ray_nor, ray_end, ray_start); - dist= hit.dist = normalize_v3(ray_nor); + dist = hit.dist = normalize_v3(ray_nor); hit.index = -1; - if(BLI_bvhtree_ray_cast(treeData.tree, ray_start, ray_nor, 0.0f, &hit, treeData.raycast_callback, &treeData) != -1) { - if(hit.dist<=dist) { + if (BLI_bvhtree_ray_cast(treeData.tree, ray_start, ray_nor, 0.0f, &hit, treeData.raycast_callback, &treeData) != -1) { + if (hit.dist <= dist) { copy_v3_v3(r_location, hit.co); copy_v3_v3(r_normal, hit.no); - *index= hit.index; + *index = hit.index; return; } } @@ -422,14 +422,14 @@ void rna_Object_ray_cast(Object *ob, ReportList *reports, float ray_start[3], fl zero_v3(r_location); zero_v3(r_normal); - *index= -1; + *index = -1; } void rna_Object_closest_point_on_mesh(Object *ob, ReportList *reports, float point_co[3], float max_dist, float n_location[3], float n_normal[3], int *index) { - BVHTreeFromMesh treeData= {NULL}; + BVHTreeFromMesh treeData = {NULL}; - if(ob->derivedFinal==NULL) { + if (ob->derivedFinal == NULL) { BKE_reportf(reports, RPT_ERROR, "object \"%s\" has no mesh data to be used for finding nearest point", ob->id.name+2); return; } @@ -437,7 +437,7 @@ void rna_Object_closest_point_on_mesh(Object *ob, ReportList *reports, float poi /* no need to managing allocation or freeing of the BVH data. this is generated and freed as needed */ bvhtree_from_mesh_faces(&treeData, ob->derivedFinal, 0.0f, 4, 6); - if(treeData.tree==NULL) { + if (treeData.tree == NULL) { BKE_reportf(reports, RPT_ERROR, "object \"%s\" could not create internal data for finding nearest point", ob->id.name+2); return; } @@ -447,24 +447,24 @@ void rna_Object_closest_point_on_mesh(Object *ob, ReportList *reports, float poi nearest.index = -1; nearest.dist = max_dist * max_dist; - if(BLI_bvhtree_find_nearest(treeData.tree, point_co, &nearest, treeData.nearest_callback, &treeData) != -1) { + if (BLI_bvhtree_find_nearest(treeData.tree, point_co, &nearest, treeData.nearest_callback, &treeData) != -1) { copy_v3_v3(n_location, nearest.co); copy_v3_v3(n_normal, nearest.no); - *index= nearest.index; + *index = nearest.index; return; } } zero_v3(n_location); zero_v3(n_normal); - *index= -1; + *index = -1; } /* ObjectBase */ void rna_ObjectBase_layers_from_view(Base *base, View3D *v3d) { - base->lay= base->object->lay= v3d->lay; + base->lay = base->object->lay = v3d->lay; } int rna_Object_is_modified(Object *ob, Scene *scene, int settings) @@ -481,7 +481,7 @@ void rna_Object_dm_info(struct Object *ob, int type, char *result) result[0] = '\0'; - switch(type) { + switch (type) { case 0: if (ob->type == OB_MESH) { dm = CDDM_from_mesh(ob->data, ob); @@ -533,118 +533,118 @@ void RNA_api_object(StructRNA *srna) #endif /* mesh */ - func= RNA_def_function(srna, "to_mesh", "rna_Object_to_mesh"); + func = RNA_def_function(srna, "to_mesh", "rna_Object_to_mesh"); RNA_def_function_ui_description(func, "Create a Mesh datablock with modifiers applied"); RNA_def_function_flag(func, FUNC_USE_REPORTS); - parm= RNA_def_pointer(func, "scene", "Scene", "", "Scene within which to evaluate modifiers"); + parm = RNA_def_pointer(func, "scene", "Scene", "", "Scene within which to evaluate modifiers"); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); - parm= RNA_def_boolean(func, "apply_modifiers", 0, "", "Apply modifiers"); + parm = RNA_def_boolean(func, "apply_modifiers", 0, "", "Apply modifiers"); RNA_def_property_flag(parm, PROP_REQUIRED); - parm= RNA_def_enum(func, "settings", mesh_type_items, 0, "", "Modifier settings to apply"); + parm = RNA_def_enum(func, "settings", mesh_type_items, 0, "", "Modifier settings to apply"); RNA_def_property_flag(parm, PROP_REQUIRED); - parm= RNA_def_pointer(func, "mesh", "Mesh", "", "Mesh created from object, remove it if it is only used for export"); + parm = RNA_def_pointer(func, "mesh", "Mesh", "", "Mesh created from object, remove it if it is only used for export"); RNA_def_function_return(func, parm); /* duplis */ - func= RNA_def_function(srna, "dupli_list_create", "rna_Object_create_duplilist"); + func = RNA_def_function(srna, "dupli_list_create", "rna_Object_create_duplilist"); RNA_def_function_ui_description(func, "Create a list of dupli objects for this object, needs to " "be freed manually with free_dupli_list to restore the " "objects real matrix and layers"); - parm= RNA_def_pointer(func, "scene", "Scene", "", "Scene within which to evaluate duplis"); + parm = RNA_def_pointer(func, "scene", "Scene", "", "Scene within which to evaluate duplis"); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); RNA_def_function_flag(func, FUNC_USE_REPORTS); - func= RNA_def_function(srna, "dupli_list_clear", "rna_Object_free_duplilist"); + func = RNA_def_function(srna, "dupli_list_clear", "rna_Object_free_duplilist"); RNA_def_function_ui_description(func, "Free the list of dupli objects"); /* Armature */ - func= RNA_def_function(srna, "find_armature", "modifiers_isDeformedByArmature"); + func = RNA_def_function(srna, "find_armature", "modifiers_isDeformedByArmature"); RNA_def_function_ui_description(func, "Find armature influencing this object as a parent or via a modifier"); - parm= RNA_def_pointer(func, "ob_arm", "Object", "", "Armature object influencing this object or NULL"); + parm = RNA_def_pointer(func, "ob_arm", "Object", "", "Armature object influencing this object or NULL"); RNA_def_function_return(func, parm); /* Shape key */ - func= RNA_def_function(srna, "shape_key_add", "rna_Object_shape_key_add"); + func = RNA_def_function(srna, "shape_key_add", "rna_Object_shape_key_add"); RNA_def_function_ui_description(func, "Add shape key to an object"); RNA_def_function_flag(func, FUNC_USE_CONTEXT|FUNC_USE_REPORTS); RNA_def_string(func, "name", "Key", 0, "", "Unique name for the new keylock"); /* optional */ RNA_def_boolean(func, "from_mix", 1, "", "Create new shape from existing mix of shapes"); - parm= RNA_def_pointer(func, "key", "ShapeKey", "", "New shape keyblock"); + parm = RNA_def_pointer(func, "key", "ShapeKey", "", "New shape keyblock"); RNA_def_property_flag(parm, PROP_RNAPTR); RNA_def_function_return(func, parm); /* Ray Cast */ - func= RNA_def_function(srna, "ray_cast", "rna_Object_ray_cast"); + func = RNA_def_function(srna, "ray_cast", "rna_Object_ray_cast"); RNA_def_function_ui_description(func, "Cast a ray onto in object space"); RNA_def_function_flag(func, FUNC_USE_REPORTS); /* ray start and end */ - parm= RNA_def_float_vector(func, "start", 3, NULL, -FLT_MAX, FLT_MAX, "", "", -1e4, 1e4); + parm = RNA_def_float_vector(func, "start", 3, NULL, -FLT_MAX, FLT_MAX, "", "", -1e4, 1e4); RNA_def_property_flag(parm, PROP_REQUIRED); - parm= RNA_def_float_vector(func, "end", 3, NULL, -FLT_MAX, FLT_MAX, "", "", -1e4, 1e4); + parm = RNA_def_float_vector(func, "end", 3, NULL, -FLT_MAX, FLT_MAX, "", "", -1e4, 1e4); RNA_def_property_flag(parm, PROP_REQUIRED); /* return location and normal */ - parm= RNA_def_float_vector(func, "location", 3, NULL, -FLT_MAX, FLT_MAX, "Location", "The hit location of this ray cast", -1e4, 1e4); + parm = RNA_def_float_vector(func, "location", 3, NULL, -FLT_MAX, FLT_MAX, "Location", "The hit location of this ray cast", -1e4, 1e4); RNA_def_property_flag(parm, PROP_THICK_WRAP); RNA_def_function_output(func, parm); - parm= RNA_def_float_vector(func, "normal", 3, NULL, -FLT_MAX, FLT_MAX, "Normal", "The face normal at the ray cast hit location", -1e4, 1e4); + parm = RNA_def_float_vector(func, "normal", 3, NULL, -FLT_MAX, FLT_MAX, "Normal", "The face normal at the ray cast hit location", -1e4, 1e4); RNA_def_property_flag(parm, PROP_THICK_WRAP); RNA_def_function_output(func, parm); - parm= RNA_def_int(func, "index", 0, 0, 0, "", "The face index, -1 when no intersection is found", 0, 0); + parm = RNA_def_int(func, "index", 0, 0, 0, "", "The face index, -1 when no intersection is found", 0, 0); RNA_def_function_output(func, parm); /* Nearest Point */ - func= RNA_def_function(srna, "closest_point_on_mesh", "rna_Object_closest_point_on_mesh"); + func = RNA_def_function(srna, "closest_point_on_mesh", "rna_Object_closest_point_on_mesh"); RNA_def_function_ui_description(func, "Find the nearest point on the object"); RNA_def_function_flag(func, FUNC_USE_REPORTS); /* location of point for test and max distance */ - parm= RNA_def_float_vector(func, "point", 3, NULL, -FLT_MAX, FLT_MAX, "", "", -1e4, 1e4); + parm = RNA_def_float_vector(func, "point", 3, NULL, -FLT_MAX, FLT_MAX, "", "", -1e4, 1e4); RNA_def_property_flag(parm, PROP_REQUIRED); /* default is sqrt(FLT_MAX) */ RNA_def_float(func, "max_dist", 1.844674352395373e+19, 0.0, FLT_MAX, "", "", 0.0, FLT_MAX); /* return location and normal */ - parm= RNA_def_float_vector(func, "location", 3, NULL, -FLT_MAX, FLT_MAX, "Location", "The location on the object closest to the point", -1e4, 1e4); + parm = RNA_def_float_vector(func, "location", 3, NULL, -FLT_MAX, FLT_MAX, "Location", "The location on the object closest to the point", -1e4, 1e4); RNA_def_property_flag(parm, PROP_THICK_WRAP); RNA_def_function_output(func, parm); - parm= RNA_def_float_vector(func, "normal", 3, NULL, -FLT_MAX, FLT_MAX, "Normal", "The face normal at the closest point", -1e4, 1e4); + parm = RNA_def_float_vector(func, "normal", 3, NULL, -FLT_MAX, FLT_MAX, "Normal", "The face normal at the closest point", -1e4, 1e4); RNA_def_property_flag(parm, PROP_THICK_WRAP); RNA_def_function_output(func, parm); - parm= RNA_def_int(func, "index", 0, 0, 0, "", "The face index, -1 when no closest point is found", 0, 0); + parm = RNA_def_int(func, "index", 0, 0, 0, "", "The face index, -1 when no closest point is found", 0, 0); RNA_def_function_output(func, parm); /* View */ - func= RNA_def_function(srna, "is_visible", "rna_Object_is_visible"); + func = RNA_def_function(srna, "is_visible", "rna_Object_is_visible"); RNA_def_function_ui_description(func, "Determine if object is visible in a given scene"); - parm= RNA_def_pointer(func, "scene", "Scene", "", ""); + parm = RNA_def_pointer(func, "scene", "Scene", "", ""); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); - parm= RNA_def_boolean(func, "result", 0, "", "Object visibility"); + parm = RNA_def_boolean(func, "result", 0, "", "Object visibility"); RNA_def_function_return(func, parm); /* utility function for checking if the object is modified */ - func= RNA_def_function(srna, "is_modified", "rna_Object_is_modified"); + func = RNA_def_function(srna, "is_modified", "rna_Object_is_modified"); RNA_def_function_ui_description(func, "Determine if this object is modified from the base mesh data"); - parm= RNA_def_pointer(func, "scene", "Scene", "", ""); + parm = RNA_def_pointer(func, "scene", "Scene", "", ""); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); - parm= RNA_def_enum(func, "settings", mesh_type_items, 0, "", "Modifier settings to apply"); + parm = RNA_def_enum(func, "settings", mesh_type_items, 0, "", "Modifier settings to apply"); RNA_def_property_flag(parm, PROP_REQUIRED); - parm= RNA_def_boolean(func, "result", 0, "", "Object visibility"); + parm = RNA_def_boolean(func, "result", 0, "", "Object visibility"); RNA_def_function_return(func, parm); #ifndef NDEBUG /* mesh */ - func= RNA_def_function(srna, "dm_info", "rna_Object_dm_info"); + func = RNA_def_function(srna, "dm_info", "rna_Object_dm_info"); RNA_def_function_ui_description(func, "Returns a string for derived mesh data"); - parm= RNA_def_enum(func, "type", mesh_dm_info_items, 0, "", "Modifier settings to apply"); + parm = RNA_def_enum(func, "type", mesh_dm_info_items, 0, "", "Modifier settings to apply"); RNA_def_property_flag(parm, PROP_REQUIRED); /* weak!, no way to return dynamic string type */ - parm= RNA_def_string(func, "result", "", 16384, "result", ""); + parm = RNA_def_string(func, "result", "", 16384, "result", ""); RNA_def_property_flag(parm, PROP_THICK_WRAP); /* needed for string return value */ RNA_def_function_output(func, parm); #endif /* NDEBUG */ @@ -656,9 +656,9 @@ void RNA_api_object_base(StructRNA *srna) FunctionRNA *func; PropertyRNA *parm; - func= RNA_def_function(srna, "layers_from_view", "rna_ObjectBase_layers_from_view"); + func = RNA_def_function(srna, "layers_from_view", "rna_ObjectBase_layers_from_view"); RNA_def_function_ui_description(func, "Sets the object layers from a 3D View (use when adding an object in local view)"); - parm= RNA_def_pointer(func, "view", "SpaceView3D", "", ""); + parm = RNA_def_pointer(func, "view", "SpaceView3D", "", ""); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); } |