Blender  V2.59
rna_object_api.c
Go to the documentation of this file.
00001 /*
00002  * $Id: rna_object_api.c 39018 2011-08-04 13:22:38Z campbellbarton $
00003  *
00004  * ***** BEGIN GPL LICENSE BLOCK *****
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version. 
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software Foundation,
00018  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  *
00020  * The Original Code is Copyright (C) 2009 Blender Foundation.
00021  * All rights reserved.
00022  *
00023  * 
00024  * Contributor(s): Blender Foundation
00025  *
00026  * ***** END GPL LICENSE BLOCK *****
00027  */
00028 
00034 #include <stdlib.h>
00035 #include <stdio.h>
00036 #include <string.h>
00037 #include <time.h>
00038 
00039 #include "RNA_define.h"
00040 
00041 #include "DNA_object_types.h"
00042 #include "DNA_modifier_types.h"
00043 
00044 // #include "BLO_sys_types.h" /* needed for intptr_t used in ED_mesh.h */
00045 
00046 // #include "ED_mesh.h"
00047 
00048 
00049 #ifdef RNA_RUNTIME
00050 #include "BLI_math.h"
00051 
00052 #include "BKE_main.h"
00053 #include "BKE_global.h"
00054 #include "BKE_context.h"
00055 #include "BKE_report.h"
00056 #include "BKE_object.h"
00057 #include "BKE_mesh.h"
00058 #include "BKE_DerivedMesh.h"
00059 #include "BKE_bvhutils.h"
00060 
00061 #include "BKE_customdata.h"
00062 #include "BKE_anim.h"
00063 #include "BKE_depsgraph.h"
00064 #include "BKE_displist.h"
00065 #include "BKE_font.h"
00066 #include "BKE_mball.h"
00067 #include "BKE_modifier.h"
00068 
00069 #include "DNA_mesh_types.h"
00070 #include "DNA_scene_types.h"
00071 #include "DNA_meshdata_types.h"
00072 #include "DNA_curve_types.h"
00073 #include "DNA_modifier_types.h"
00074 #include "DNA_constraint_types.h"
00075 #include "DNA_view3d_types.h"
00076 
00077 #include "MEM_guardedalloc.h"
00078 
00079 /* copied from Mesh_getFromObject and adapted to RNA interface */
00080 /* settings: 0 - preview, 1 - render */
00081 static Mesh *rna_Object_to_mesh(Object *ob, ReportList *reports, Scene *sce, int apply_modifiers, int settings)
00082 {
00083         Mesh *tmpmesh;
00084         Curve *tmpcu = NULL;
00085         Object *tmpobj = NULL;
00086         int render = settings == eModifierMode_Render, i;
00087         int cage = !apply_modifiers;
00088 
00089         /* perform the mesh extraction based on type */
00090         switch (ob->type) {
00091         case OB_FONT:
00092         case OB_CURVE:
00093         case OB_SURF:
00094 
00095                 /* copies object and modifiers (but not the data) */
00096                 tmpobj= copy_object(ob);
00097                 tmpcu = (Curve *)tmpobj->data;
00098                 tmpcu->id.us--;
00099 
00100                 /* if getting the original caged mesh, delete object modifiers */
00101                 if( cage )
00102                         object_free_modifiers(tmpobj);
00103 
00104                 /* copies the data */
00105                 tmpobj->data = copy_curve( (Curve *) ob->data );
00106 
00107 #if 0
00108                 /* copy_curve() sets disp.first null, so currently not need */
00109                 {
00110                         Curve *cu;
00111                         cu = (Curve *)tmpobj->data;
00112                         if( cu->disp.first )
00113                                 MEM_freeN( cu->disp.first );
00114                         cu->disp.first = NULL;
00115                 }
00116         
00117 #endif
00118 
00119                 /* get updated display list, and convert to a mesh */
00120                 makeDispListCurveTypes( sce, tmpobj, 0 );
00121                 nurbs_to_mesh( tmpobj );
00122                 
00123                 /* nurbs_to_mesh changes the type to a mesh, check it worked */
00124                 if (tmpobj->type != OB_MESH) {
00125                         free_libblock_us( &(G.main->object), tmpobj );
00126                         BKE_report(reports, RPT_ERROR, "cant convert curve to mesh. Does the curve have any segments?");
00127                         return NULL;
00128                 }
00129                 tmpmesh = tmpobj->data;
00130                 free_libblock_us( &G.main->object, tmpobj );
00131                 break;
00132 
00133         case OB_MBALL:
00134                 /* metaballs don't have modifiers, so just convert to mesh */
00135                 ob = find_basis_mball( sce, ob );
00136                 /* todo, re-generatre for render-res */
00137                 /* metaball_polygonize(scene, ob) */
00138 
00139                 tmpmesh = add_mesh("Mesh");
00140                 mball_to_mesh( &ob->disp, tmpmesh );
00141                 break;
00142 
00143         case OB_MESH:
00144                 /* copies object and modifiers (but not the data) */
00145                 if (cage) {
00146                         /* copies the data */
00147                         tmpmesh = copy_mesh( ob->data );
00148                 /* if not getting the original caged mesh, get final derived mesh */
00149                 } else {
00150                         /* Make a dummy mesh, saves copying */
00151                         DerivedMesh *dm;
00152                         /* CustomDataMask mask = CD_MASK_BAREMESH|CD_MASK_MTFACE|CD_MASK_MCOL; */
00153                         CustomDataMask mask = CD_MASK_MESH; /* this seems more suitable, exporter,
00154                                                                                                    for example, needs CD_MASK_MDEFORMVERT */
00155                         
00156                         /* Write the display mesh into the dummy mesh */
00157                         if (render)
00158                                 dm = mesh_create_derived_render( sce, ob, mask );
00159                         else
00160                                 dm = mesh_create_derived_view( sce, ob, mask );
00161                         
00162                         tmpmesh = add_mesh( "Mesh" );
00163                         DM_to_mesh( dm, tmpmesh );
00164                         dm->release( dm );
00165                 }
00166                 
00167                 break;
00168         default:
00169                 BKE_report(reports, RPT_ERROR, "Object does not have geometry data");
00170                 return NULL;
00171         }
00172 
00173         /* Copy materials to new mesh */
00174         switch (ob->type) {
00175         case OB_SURF:
00176         case OB_FONT:
00177         case OB_CURVE:
00178                 tmpmesh->totcol = tmpcu->totcol;                
00179                 
00180                 /* free old material list (if it exists) and adjust user counts */
00181                 if( tmpcu->mat ) {
00182                         for( i = tmpcu->totcol; i-- > 0; ) {
00183                                 /* are we an object material or data based? */
00184                                 if (ob->colbits & 1<<i) 
00185                                         tmpmesh->mat[i] = ob->mat[i];
00186                                 else 
00187                                         tmpmesh->mat[i] = tmpcu->mat[i];
00188 
00189                                 if (tmpmesh->mat[i]) 
00190                                         tmpmesh->mat[i]->id.us++;
00191                         }
00192                 }
00193                 break;
00194 
00195 #if 0
00196         /* Crashes when assigning the new material, not sure why */
00197         case OB_MBALL:
00198                 tmpmb = (MetaBall *)ob->data;
00199                 tmpmesh->totcol = tmpmb->totcol;
00200                 
00201                 /* free old material list (if it exists) and adjust user counts */
00202                 if( tmpmb->mat ) {
00203                         for( i = tmpmb->totcol; i-- > 0; ) {
00204                                 tmpmesh->mat[i] = tmpmb->mat[i]; /* CRASH HERE ??? */
00205                                 if (tmpmesh->mat[i]) {
00206                                         tmpmb->mat[i]->id.us++;
00207                                 }
00208                         }
00209                 }
00210                 break;
00211 #endif
00212 
00213         case OB_MESH:
00214                 if (!cage) {
00215                         Mesh *origmesh= ob->data;
00216                         tmpmesh->flag= origmesh->flag;
00217                         tmpmesh->mat = MEM_dupallocN(origmesh->mat);
00218                         tmpmesh->totcol = origmesh->totcol;
00219                         tmpmesh->smoothresh= origmesh->smoothresh;
00220                         if( origmesh->mat ) {
00221                                 for( i = origmesh->totcol; i-- > 0; ) {
00222                                         /* are we an object material or data based? */
00223                                         if (ob->colbits & 1<<i)
00224                                                 tmpmesh->mat[i] = ob->mat[i];
00225                                         else
00226                                                 tmpmesh->mat[i] = origmesh->mat[i];
00227                                         if (tmpmesh->mat[i])
00228                                                 tmpmesh->mat[i]->id.us++;
00229                                 }
00230                         }
00231                 }
00232                 break;
00233         } /* end copy materials */
00234 
00235         /* we don't assign it to anything */
00236         tmpmesh->id.us--;
00237         
00238         /* make sure materials get updated in objects */
00239         test_object_materials( ( ID * ) tmpmesh );
00240 
00241         return tmpmesh;
00242 }
00243 
00244 /* mostly a copy from convertblender.c */
00245 static void dupli_render_particle_set(Scene *scene, Object *ob, int level, int enable)
00246 {
00247         /* ugly function, but we need to set particle systems to their render
00248          * settings before calling object_duplilist, to get render level duplis */
00249         Group *group;
00250         GroupObject *go;
00251         ParticleSystem *psys;
00252         DerivedMesh *dm;
00253         float mat[4][4];
00254 
00255         unit_m4(mat);
00256 
00257         if(level >= MAX_DUPLI_RECUR)
00258                 return;
00259         
00260         if(ob->transflag & OB_DUPLIPARTS) {
00261                 for(psys=ob->particlesystem.first; psys; psys=psys->next) {
00262                         if(ELEM(psys->part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) {
00263                                 if(enable)
00264                                         psys_render_set(ob, psys, mat, mat, 1, 1, 0.f);
00265                                 else
00266                                         psys_render_restore(ob, psys);
00267                         }
00268                 }
00269 
00270                 if(level == 0 && enable) {
00271                         /* this is to make sure we get render level duplis in groups:
00272                         * the derivedmesh must be created before init_render_mesh,
00273                         * since object_duplilist does dupliparticles before that */
00274                         dm = mesh_create_derived_render(scene, ob, CD_MASK_BAREMESH|CD_MASK_MTFACE|CD_MASK_MCOL);
00275                         dm->release(dm);
00276 
00277                         for(psys=ob->particlesystem.first; psys; psys=psys->next)
00278                                 psys_get_modifier(ob, psys)->flag &= ~eParticleSystemFlag_psys_updated;
00279                 }
00280         }
00281 
00282         if(ob->dup_group==NULL) return;
00283         group= ob->dup_group;
00284 
00285         for(go= group->gobject.first; go; go= go->next)
00286                 dupli_render_particle_set(scene, go->ob, level+1, enable);
00287 }
00288 /* When no longer needed, duplilist should be freed with Object.free_duplilist */
00289 static void rna_Object_create_duplilist(Object *ob, ReportList *reports, Scene *sce)
00290 {
00291         if (!(ob->transflag & OB_DUPLI)) {
00292                 BKE_report(reports, RPT_ERROR, "Object does not have duplis.");
00293                 return;
00294         }
00295 
00296         /* free duplilist if a user forgets to */
00297         if (ob->duplilist) {
00298                 BKE_reportf(reports, RPT_WARNING, "Object.dupli_list has not been freed.");
00299 
00300                 free_object_duplilist(ob->duplilist);
00301                 ob->duplilist= NULL;
00302         }
00303         if(G.rendering)
00304                 dupli_render_particle_set(sce, ob, 0, 1);
00305         ob->duplilist= object_duplilist(sce, ob);
00306         if(G.rendering)
00307                 dupli_render_particle_set(sce, ob, 0, 0);
00308         /* ob->duplilist should now be freed with Object.free_duplilist */
00309 }
00310 
00311 static void rna_Object_free_duplilist(Object *ob)
00312 {
00313         if (ob->duplilist) {
00314                 free_object_duplilist(ob->duplilist);
00315                 ob->duplilist= NULL;
00316         }
00317 }
00318 
00319 static PointerRNA rna_Object_shape_key_add(Object *ob, bContext *C, ReportList *reports, const char *name, int from_mix)
00320 {
00321         Scene *scene= CTX_data_scene(C);
00322         KeyBlock *kb= NULL;
00323 
00324         if((kb=object_insert_shape_key(scene, ob, name, from_mix))) {
00325                 PointerRNA keyptr;
00326 
00327                 RNA_pointer_create((ID *)ob->data, &RNA_ShapeKey, kb, &keyptr);
00328                 WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
00329                 
00330                 return keyptr;
00331         }
00332         else {
00333                 BKE_reportf(reports, RPT_ERROR, "Object \"%s\"does not support shapes.", ob->id.name+2);
00334                 return PointerRNA_NULL;
00335         }
00336 }
00337 
00338 int rna_Object_is_visible(Object *ob, Scene *sce)
00339 {
00340         return !(ob->restrictflag & OB_RESTRICT_VIEW) && (ob->lay & sce->lay);
00341 }
00342 
00343 /*
00344 static void rna_Mesh_assign_verts_to_group(Object *ob, bDeformGroup *group, int *indices, int totindex, float weight, int assignmode)
00345 {
00346         if (ob->type != OB_MESH) {
00347                 BKE_report(reports, RPT_ERROR, "Object should be of MESH type.");
00348                 return;
00349         }
00350 
00351         Mesh *me = (Mesh*)ob->data;
00352         int group_index = defgroup_find_index(ob, group);
00353         if (group_index == -1) {
00354                 BKE_report(reports, RPT_ERROR, "No deform groups assigned to mesh.");
00355                 return;
00356         }
00357 
00358         if (assignmode != WEIGHT_REPLACE && assignmode != WEIGHT_ADD && assignmode != WEIGHT_SUBTRACT) {
00359                 BKE_report(reports, RPT_ERROR, "Bad assignment mode." );
00360                 return;
00361         }
00362 
00363         // makes a set of dVerts corresponding to the mVerts
00364         if (!me->dvert) 
00365                 create_dverts(&me->id);
00366 
00367         // loop list adding verts to group 
00368         for (i= 0; i < totindex; i++) {
00369                 if(i < 0 || i >= me->totvert) {
00370                         BKE_report(reports, RPT_ERROR, "Bad vertex index in list.");
00371                         return;
00372                 }
00373 
00374                 add_vert_defnr(ob, group_index, i, weight, assignmode);
00375         }
00376 }
00377 */
00378 
00379 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)
00380 {
00381         BVHTreeFromMesh treeData= {NULL};
00382         
00383         if(ob->derivedFinal==NULL) {
00384                 BKE_reportf(reports, RPT_ERROR, "object \"%s\" has no mesh data to be used for ray casting.", ob->id.name+2);
00385                 return;
00386         }
00387 
00388         /* no need to managing allocation or freeing of the BVH data. this is generated and freed as needed */
00389         bvhtree_from_mesh_faces(&treeData, ob->derivedFinal, 0.0f, 4, 6);
00390 
00391         if(treeData.tree==NULL) {
00392                 BKE_reportf(reports, RPT_ERROR, "object \"%s\" could not create internal data for ray casting.", ob->id.name+2);
00393                 return;
00394         }
00395         else {
00396                 BVHTreeRayHit hit;
00397                 float ray_nor[3], dist;
00398                 sub_v3_v3v3(ray_nor, ray_end, ray_start);
00399 
00400                 dist= hit.dist = normalize_v3(ray_nor);
00401                 hit.index = -1;
00402                 
00403                 if(BLI_bvhtree_ray_cast(treeData.tree, ray_start, ray_nor, 0.0f, &hit, treeData.raycast_callback, &treeData) != -1) {
00404                         if(hit.dist<=dist) {
00405                                 copy_v3_v3(r_location, hit.co);
00406                                 copy_v3_v3(r_normal, hit.no);
00407                                 *index= hit.index;
00408                                 return;
00409                         }
00410                 }
00411         }
00412 
00413         zero_v3(r_location);
00414         zero_v3(r_normal);
00415         *index= -1;
00416 }
00417 
00418 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)
00419 {
00420         BVHTreeFromMesh treeData= {NULL};
00421         
00422         if(ob->derivedFinal==NULL) {
00423                 BKE_reportf(reports, RPT_ERROR, "object \"%s\" has no mesh data to be used for finding nearest point.", ob->id.name+2);
00424                 return;
00425         }
00426 
00427         /* no need to managing allocation or freeing of the BVH data. this is generated and freed as needed */
00428         bvhtree_from_mesh_faces(&treeData, ob->derivedFinal, 0.0f, 4, 6);
00429 
00430         if(treeData.tree==NULL) {
00431                 BKE_reportf(reports, RPT_ERROR, "object \"%s\" could not create internal data for finding nearest point", ob->id.name+2);
00432                 return;
00433         }
00434         else {
00435                 BVHTreeNearest nearest;
00436 
00437                 nearest.index = -1;
00438                 nearest.dist = max_dist * max_dist;
00439 
00440                 if(BLI_bvhtree_find_nearest(treeData.tree, point_co, &nearest, treeData.nearest_callback, &treeData) != -1) {
00441                         copy_v3_v3(n_location, nearest.co);
00442                         copy_v3_v3(n_normal, nearest.no);
00443                         *index= nearest.index;
00444                         return;
00445                 }
00446         }
00447 
00448         zero_v3(n_location);
00449         zero_v3(n_normal);
00450         *index= -1;
00451 }
00452 
00453 /* ObjectBase */
00454 
00455 void rna_ObjectBase_layers_from_view(Base *base, View3D *v3d)
00456 {
00457         base->lay= base->object->lay= v3d->lay;
00458 }
00459 
00460 int rna_Object_is_modified(Object *ob, Scene *scene, int settings)
00461 {
00462         return object_is_modified(scene, ob) & settings;
00463 }
00464 
00465 #else
00466 
00467 void RNA_api_object(StructRNA *srna)
00468 {
00469         FunctionRNA *func;
00470         PropertyRNA *parm;
00471 
00472         static EnumPropertyItem mesh_type_items[] = {
00473                 {eModifierMode_Realtime, "PREVIEW", 0, "Preview", "Apply modifier preview settings"},
00474                 {eModifierMode_Render, "RENDER", 0, "Render", "Apply modifier render settings"},
00475                 {0, NULL, 0, NULL, NULL}
00476         };
00477 
00478         /* mesh */
00479         func= RNA_def_function(srna, "to_mesh", "rna_Object_to_mesh");
00480         RNA_def_function_ui_description(func, "Create a Mesh datablock with modifiers applied.");
00481         RNA_def_function_flag(func, FUNC_USE_REPORTS);
00482         parm= RNA_def_pointer(func, "scene", "Scene", "", "Scene within which to evaluate modifiers.");
00483         RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL);
00484         parm= RNA_def_boolean(func, "apply_modifiers", 0, "", "Apply modifiers.");
00485         RNA_def_property_flag(parm, PROP_REQUIRED);
00486         parm= RNA_def_enum(func, "settings", mesh_type_items, 0, "", "Modifier settings to apply.");
00487         RNA_def_property_flag(parm, PROP_REQUIRED);
00488         parm= RNA_def_pointer(func, "mesh", "Mesh", "", "Mesh created from object, remove it if it is only used for export.");
00489         RNA_def_function_return(func, parm);
00490 
00491         /* duplis */
00492         func= RNA_def_function(srna, "dupli_list_create", "rna_Object_create_duplilist");
00493         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.");
00494         parm= RNA_def_pointer(func, "scene", "Scene", "", "Scene within which to evaluate duplis.");
00495         RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL);
00496         RNA_def_function_flag(func, FUNC_USE_REPORTS);
00497 
00498         func= RNA_def_function(srna, "dupli_list_clear", "rna_Object_free_duplilist");
00499         RNA_def_function_ui_description(func, "Free the list of dupli objects.");
00500 
00501         /* Armature */
00502         func= RNA_def_function(srna, "find_armature", "modifiers_isDeformedByArmature");
00503         RNA_def_function_ui_description(func, "Find armature influencing this object as a parent or via a modifier.");
00504         parm= RNA_def_pointer(func, "ob_arm", "Object", "", "Armature object influencing this object or NULL.");
00505         RNA_def_function_return(func, parm);
00506 
00507         /* Shape key */
00508         func= RNA_def_function(srna, "shape_key_add", "rna_Object_shape_key_add");
00509         RNA_def_function_ui_description(func, "Add shape key to an object.");
00510         RNA_def_function_flag(func, FUNC_USE_CONTEXT|FUNC_USE_REPORTS);
00511         RNA_def_string(func, "name", "Key", 0, "", "Unique name for the new keylock."); /* optional */
00512         RNA_def_boolean(func, "from_mix", 1, "", "Create new shape from existing mix of shapes.");
00513         parm= RNA_def_pointer(func, "key", "ShapeKey", "", "New shape keyblock.");
00514         RNA_def_property_flag(parm, PROP_RNAPTR);
00515         RNA_def_function_return(func, parm);
00516 
00517         /* Ray Cast */
00518         func= RNA_def_function(srna, "ray_cast", "rna_Object_ray_cast");
00519         RNA_def_function_ui_description(func, "Cast a ray onto in object space.");
00520         RNA_def_function_flag(func, FUNC_USE_REPORTS);
00521         
00522         /* ray start and end */
00523         parm= RNA_def_float_vector(func, "start", 3, NULL, -FLT_MAX, FLT_MAX, "", "", -1e4, 1e4);
00524         RNA_def_property_flag(parm, PROP_REQUIRED);
00525         parm= RNA_def_float_vector(func, "end", 3, NULL, -FLT_MAX, FLT_MAX, "", "", -1e4, 1e4);
00526         RNA_def_property_flag(parm, PROP_REQUIRED);
00527 
00528         /* return location and normal */
00529         parm= RNA_def_float_vector(func, "location", 3, NULL, -FLT_MAX, FLT_MAX, "Location", "The hit location of this ray cast", -1e4, 1e4);
00530         RNA_def_property_flag(parm, PROP_THICK_WRAP);
00531         RNA_def_function_output(func, parm);
00532         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);
00533         RNA_def_property_flag(parm, PROP_THICK_WRAP);
00534         RNA_def_function_output(func, parm);
00535         
00536         parm= RNA_def_int(func, "index", 0, 0, 0, "", "The face index, -1 when no intersection is found.", 0, 0);
00537         RNA_def_function_output(func, parm);
00538 
00539         /* Nearest Point */
00540         func= RNA_def_function(srna, "closest_point_on_mesh", "rna_Object_closest_point_on_mesh");
00541         RNA_def_function_ui_description(func, "Find the nearest point on the object.");
00542         RNA_def_function_flag(func, FUNC_USE_REPORTS);
00543 
00544         /* location of point for test and max distance */
00545         parm= RNA_def_float_vector(func, "point", 3, NULL, -FLT_MAX, FLT_MAX, "", "", -1e4, 1e4);
00546         RNA_def_property_flag(parm, PROP_REQUIRED);
00547         /* default is sqrt(FLT_MAX) */
00548         RNA_def_float(func, "max_dist", 1.844674352395373e+19, 0.0, FLT_MAX, "", "", 0.0, FLT_MAX);
00549 
00550         /* return location and normal */
00551         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);
00552         RNA_def_property_flag(parm, PROP_THICK_WRAP);
00553         RNA_def_function_output(func, parm);
00554         parm= RNA_def_float_vector(func, "normal", 3, NULL, -FLT_MAX, FLT_MAX, "Normal", "The face normal at the closest point", -1e4, 1e4);
00555         RNA_def_property_flag(parm, PROP_THICK_WRAP);
00556         RNA_def_function_output(func, parm);
00557 
00558         parm= RNA_def_int(func, "index", 0, 0, 0, "", "The face index, -1 when no closest point is found.", 0, 0);
00559         RNA_def_function_output(func, parm);
00560 
00561         /* View */
00562         func= RNA_def_function(srna, "is_visible", "rna_Object_is_visible");
00563         RNA_def_function_ui_description(func, "Determine if object is visible in a given scene.");
00564         parm= RNA_def_pointer(func, "scene", "Scene", "", "");
00565         RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL);
00566         parm= RNA_def_boolean(func, "result", 0, "", "Object visibility.");
00567         RNA_def_function_return(func, parm);
00568 
00569         /* utility function for checking if the object is modified */
00570         func= RNA_def_function(srna, "is_modified", "rna_Object_is_modified");
00571         RNA_def_function_ui_description(func, "Determine if this object is modified from the base mesh data.");
00572         parm= RNA_def_pointer(func, "scene", "Scene", "", "");
00573         RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL);
00574         parm= RNA_def_enum(func, "settings", mesh_type_items, 0, "", "Modifier settings to apply.");
00575         RNA_def_property_flag(parm, PROP_REQUIRED);
00576         parm= RNA_def_boolean(func, "result", 0, "", "Object visibility.");
00577         RNA_def_function_return(func, parm);
00578 }
00579 
00580 
00581 void RNA_api_object_base(StructRNA *srna)
00582 {
00583         FunctionRNA *func;
00584         PropertyRNA *parm;
00585 
00586         func= RNA_def_function(srna, "layers_from_view", "rna_ObjectBase_layers_from_view");
00587         RNA_def_function_ui_description(func, "Sets the object layers from a 3D View (use when adding an object in local view).");
00588         parm= RNA_def_pointer(func, "view", "SpaceView3D", "", "");
00589         RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL);
00590 }
00591 
00592 #endif
00593