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