diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-06-07 17:09:18 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-06-07 17:09:18 +0400 |
commit | 673a39dab1827def82c8b405df6d6704e140c6fe (patch) | |
tree | e9b386aa0dece4a442a825b0149aa2743ab64fcf /source | |
parent | 38e998e022411dd33a211a29650766bdca03bdc7 (diff) |
RNA:
* Accept None as NULL pointers through python function calls.
* Added type callback for pointers back, it's useful still in
some cases. Made Object.data editable using this, the pointer
type varying based on object type.
* Wrap pin ID pointer in buttons space.
* Added subclasses for text and surface curve ID blocks, to
organize data better and get proper icons.
* Added RNA_type_to_ID_code and ID_code_to_RNA_type functions.
* Update RNA_access.h with new RNA types.
Diffstat (limited to 'source')
27 files changed, 466 insertions, 142 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 740b889dccf..072bc5a6feb 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -1457,9 +1457,9 @@ static void ui_rna_ID_collection(bContext *C, uiBut *but, PointerRNA *ptr, Prope /* if it's a collection and has same pointer type, we've got it */ if(RNA_property_type(iprop) == PROP_COLLECTION) { - srna= RNA_property_pointer_type(iprop); + srna= RNA_property_pointer_type(ptr, iprop); - if(RNA_property_pointer_type(but->rnaprop) == srna) { + if(RNA_property_pointer_type(ptr, but->rnaprop) == srna) { *prop= iprop; break; } @@ -1530,7 +1530,7 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str) if(str == NULL || str[0] == '\0') { memset(&rptr, 0, sizeof(rptr)); RNA_property_pointer_set(&but->rnapoin, but->rnaprop, rptr); - return 11; + return 1; } else if(prop && RNA_property_collection_lookup_string(&ptr, prop, str, &rptr)) { RNA_property_pointer_set(&but->rnapoin, but->rnaprop, rptr); diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c index 564ae2c0205..97ae2c01c55 100644 --- a/source/blender/editors/interface/interface_utils.c +++ b/source/blender/editors/interface/interface_utils.c @@ -116,7 +116,7 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind pptr= RNA_property_pointer_get(ptr, prop); if(!pptr.type) - pptr.type= RNA_property_pointer_type(prop); + pptr.type= RNA_property_pointer_type(ptr, prop); icon= RNA_struct_ui_icon(pptr.type); but= uiDefIconTextButR(block, IDPOIN, 0, icon, name, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL); diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index eb355a34f9f..5145522a544 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -43,6 +43,7 @@ struct Main; extern BlenderRNA BLENDER_RNA; extern StructRNA RNA_Action; +extern StructRNA RNA_ActionConstraint; extern StructRNA RNA_ActionGroup; extern StructRNA RNA_Actuator; extern StructRNA RNA_ActuatorSensor; @@ -58,8 +59,8 @@ extern StructRNA RNA_ArrayModifier; extern StructRNA RNA_BackgroundImage; extern StructRNA RNA_BevelModifier; extern StructRNA RNA_BezierCurvePoint; -extern StructRNA RNA_BlenderRNA; extern StructRNA RNA_BlendTexture; +extern StructRNA RNA_BlenderRNA; extern StructRNA RNA_Bone; extern StructRNA RNA_BooleanModifier; extern StructRNA RNA_BooleanProperty; @@ -67,6 +68,9 @@ extern StructRNA RNA_Brush; extern StructRNA RNA_BuildModifier; extern StructRNA RNA_Camera; extern StructRNA RNA_CastModifier; +extern StructRNA RNA_ChildOfConstraint; +extern StructRNA RNA_ChildParticle; +extern StructRNA RNA_ClampToConstraint; extern StructRNA RNA_ClothCollisionSettings; extern StructRNA RNA_ClothModifier; extern StructRNA RNA_ClothSettings; @@ -78,10 +82,73 @@ extern StructRNA RNA_CollisionSettings; extern StructRNA RNA_ColorRamp; extern StructRNA RNA_ColorRampElement; extern StructRNA RNA_ColorSequence; +extern StructRNA RNA_CompositorNode; +extern StructRNA RNA_CompositorNodeAlphaOver; +extern StructRNA RNA_CompositorNodeBilateralblur; +extern StructRNA RNA_CompositorNodeBlur; +extern StructRNA RNA_CompositorNodeBrightContrast; +extern StructRNA RNA_CompositorNodeChannelMatte; +extern StructRNA RNA_CompositorNodeChroma; +extern StructRNA RNA_CompositorNodeColorSpill; +extern StructRNA RNA_CompositorNodeCombHSVA; +extern StructRNA RNA_CompositorNodeCombRGBA; +extern StructRNA RNA_CompositorNodeCombYCCA; +extern StructRNA RNA_CompositorNodeCombYUVA; +extern StructRNA RNA_CompositorNodeComposite; +extern StructRNA RNA_CompositorNodeCrop; +extern StructRNA RNA_CompositorNodeCurveRGB; +extern StructRNA RNA_CompositorNodeCurveVec; +extern StructRNA RNA_CompositorNodeDBlur; +extern StructRNA RNA_CompositorNodeDefocus; +extern StructRNA RNA_CompositorNodeDiffMatte; +extern StructRNA RNA_CompositorNodeDilateErode; +extern StructRNA RNA_CompositorNodeDisplace; +extern StructRNA RNA_CompositorNodeFilter; +extern StructRNA RNA_CompositorNodeFlip; +extern StructRNA RNA_CompositorNodeGamma; +extern StructRNA RNA_CompositorNodeGlare; +extern StructRNA RNA_CompositorNodeHueSat; +extern StructRNA RNA_CompositorNodeIDMask; +extern StructRNA RNA_CompositorNodeImage; +extern StructRNA RNA_CompositorNodeInvert; +extern StructRNA RNA_CompositorNodeLensdist; +extern StructRNA RNA_CompositorNodeLumaMatte; +extern StructRNA RNA_CompositorNodeMapUV; +extern StructRNA RNA_CompositorNodeMapValue; +extern StructRNA RNA_CompositorNodeMath; +extern StructRNA RNA_CompositorNodeMixRGB; +extern StructRNA RNA_CompositorNodeNormal; +extern StructRNA RNA_CompositorNodeNormalize; +extern StructRNA RNA_CompositorNodeOutputFile; +extern StructRNA RNA_CompositorNodePremulKey; +extern StructRNA RNA_CompositorNodeRGB; +extern StructRNA RNA_CompositorNodeRGBToBW; +extern StructRNA RNA_CompositorNodeRLayers; +extern StructRNA RNA_CompositorNodeRotate; +extern StructRNA RNA_CompositorNodeScale; +extern StructRNA RNA_CompositorNodeSepHSVA; +extern StructRNA RNA_CompositorNodeSepRGBA; +extern StructRNA RNA_CompositorNodeSepYCCA; +extern StructRNA RNA_CompositorNodeSepYUVA; +extern StructRNA RNA_CompositorNodeSetAlpha; +extern StructRNA RNA_CompositorNodeSplitViewer; +extern StructRNA RNA_CompositorNodeTexture; +extern StructRNA RNA_CompositorNodeTime; +extern StructRNA RNA_CompositorNodeTonemap; +extern StructRNA RNA_CompositorNodeTranslate; +extern StructRNA RNA_CompositorNodeValToRGB; +extern StructRNA RNA_CompositorNodeValue; +extern StructRNA RNA_CompositorNodeVecBlur; +extern StructRNA RNA_CompositorNodeViewer; +extern StructRNA RNA_CompositorNodeZcombine; extern StructRNA RNA_Constraint; +extern StructRNA RNA_ConstraintTarget; extern StructRNA RNA_Context; extern StructRNA RNA_ControlFluidSettings; extern StructRNA RNA_Controller; +extern StructRNA RNA_CopyLocationConstraint; +extern StructRNA RNA_CopyRotationConstraint; +extern StructRNA RNA_CopyScaleConstraint; extern StructRNA RNA_Curve; extern StructRNA RNA_CurveMap; extern StructRNA RNA_CurveMapPoint; @@ -89,9 +156,6 @@ extern StructRNA RNA_CurveMapping; extern StructRNA RNA_CurveModifier; extern StructRNA RNA_CurvePoint; extern StructRNA RNA_DecimateModifier; -extern StructRNA RNA_DefCollision; -extern StructRNA RNA_DefField; -extern StructRNA RNA_DefPointcache; extern StructRNA RNA_DelaySensor; extern StructRNA RNA_DisplaceModifier; extern StructRNA RNA_DistortedNoiseTexture; @@ -108,11 +172,21 @@ extern StructRNA RNA_ExplodeModifier; extern StructRNA RNA_ExpressionController; extern StructRNA RNA_FCurve; extern StructRNA RNA_FModifier; +extern StructRNA RNA_FModifierCycles; +extern StructRNA RNA_FModifierEnvelope; +extern StructRNA RNA_FModifierGenerator; +extern StructRNA RNA_FModifierGenerator_Function; +extern StructRNA RNA_FModifierGenerator_PolyExpanded; +extern StructRNA RNA_FModifierLimits; +extern StructRNA RNA_FModifierNoise; +extern StructRNA RNA_FModifierPython; extern StructRNA RNA_FieldSettings; extern StructRNA RNA_FloatProperty; +extern StructRNA RNA_FloorConstraint; extern StructRNA RNA_FluidFluidSettings; extern StructRNA RNA_FluidSettings; extern StructRNA RNA_FluidSimulationModifier; +extern StructRNA RNA_FollowPathConstraint; extern StructRNA RNA_Function; extern StructRNA RNA_GameBooleanProperty; extern StructRNA RNA_GameFloatProperty; @@ -124,6 +198,7 @@ extern StructRNA RNA_GameStringProperty; extern StructRNA RNA_GameTimerProperty; extern StructRNA RNA_GlowSequence; extern StructRNA RNA_Group; +extern StructRNA RNA_Header; extern StructRNA RNA_HemiLamp; extern StructRNA RNA_HookModifier; extern StructRNA RNA_ID; @@ -140,6 +215,7 @@ extern StructRNA RNA_Key; extern StructRNA RNA_KeyboardSensor; extern StructRNA RNA_KeyingSet; extern StructRNA RNA_KeyingSetPath; +extern StructRNA RNA_KinematicConstraint; extern StructRNA RNA_Lamp; extern StructRNA RNA_LampSkySettings; extern StructRNA RNA_LampTextureSlot; @@ -147,7 +223,12 @@ extern StructRNA RNA_Lattice; extern StructRNA RNA_LatticeModifier; extern StructRNA RNA_LatticePoint; extern StructRNA RNA_Library; +extern StructRNA RNA_LimitDistanceConstraint; +extern StructRNA RNA_LimitLocationConstraint; +extern StructRNA RNA_LimitRotationConstraint; +extern StructRNA RNA_LimitScaleConstraint; extern StructRNA RNA_LocalLamp; +extern StructRNA RNA_LockedTrackConstraint; extern StructRNA RNA_MagicTexture; extern StructRNA RNA_Main; extern StructRNA RNA_MarbleTexture; @@ -160,6 +241,7 @@ extern StructRNA RNA_MaterialSlot; extern StructRNA RNA_MaterialStrand; extern StructRNA RNA_MaterialSubsurfaceScattering; extern StructRNA RNA_MaterialTextureSlot; +extern StructRNA RNA_Menu; extern StructRNA RNA_Mesh; extern StructRNA RNA_MeshColor; extern StructRNA RNA_MeshColorLayer; @@ -170,7 +252,6 @@ extern StructRNA RNA_MeshFloatProperty; extern StructRNA RNA_MeshFloatPropertyLayer; extern StructRNA RNA_MeshIntProperty; extern StructRNA RNA_MeshIntPropertyLayer; -extern StructRNA RNA_MeshMultires; extern StructRNA RNA_MeshSticky; extern StructRNA RNA_MeshStringProperty; extern StructRNA RNA_MeshStringPropertyLayer; @@ -193,6 +274,7 @@ extern StructRNA RNA_Node; extern StructRNA RNA_NodeTree; extern StructRNA RNA_NoiseTexture; extern StructRNA RNA_NorController; +extern StructRNA RNA_Nurb; extern StructRNA RNA_Object; extern StructRNA RNA_ObstacleFluidSettings; extern StructRNA RNA_Operator; @@ -204,8 +286,11 @@ extern StructRNA RNA_OrController; extern StructRNA RNA_OutflowFluidSettings; extern StructRNA RNA_PackedFile; extern StructRNA RNA_Panel; +extern StructRNA RNA_Particle; extern StructRNA RNA_ParticleFluidSettings; +extern StructRNA RNA_ParticleHairKey; extern StructRNA RNA_ParticleInstanceModifier; +extern StructRNA RNA_ParticleKey; extern StructRNA RNA_ParticleSettings; extern StructRNA RNA_ParticleSystem; extern StructRNA RNA_ParticleSystemModifier; @@ -217,12 +302,14 @@ extern StructRNA RNA_Pose; extern StructRNA RNA_PoseChannel; extern StructRNA RNA_Property; extern StructRNA RNA_PropertySensor; +extern StructRNA RNA_PythonConstraint; extern StructRNA RNA_PythonController; extern StructRNA RNA_RadarSensor; extern StructRNA RNA_Radiosity; extern StructRNA RNA_RandomSensor; extern StructRNA RNA_RaySensor; extern StructRNA RNA_Region; +extern StructRNA RNA_RigidBodyJointConstraint; extern StructRNA RNA_Scene; extern StructRNA RNA_SceneRenderData; extern StructRNA RNA_SceneSequence; @@ -237,10 +324,34 @@ extern StructRNA RNA_SequenceEditor; extern StructRNA RNA_SequenceElement; extern StructRNA RNA_SequenceProxy; extern StructRNA RNA_SequenceTransform; +extern StructRNA RNA_ShaderNode; +extern StructRNA RNA_ShaderNodeCameraData; +extern StructRNA RNA_ShaderNodeCombineRGB; +extern StructRNA RNA_ShaderNodeExtendedMaterial; +extern StructRNA RNA_ShaderNodeGeometry; +extern StructRNA RNA_ShaderNodeHueSaturation; +extern StructRNA RNA_ShaderNodeInvert; +extern StructRNA RNA_ShaderNodeMapping; +extern StructRNA RNA_ShaderNodeMaterial; +extern StructRNA RNA_ShaderNodeMath; +extern StructRNA RNA_ShaderNodeMixRGB; +extern StructRNA RNA_ShaderNodeNormal; +extern StructRNA RNA_ShaderNodeOutput; +extern StructRNA RNA_ShaderNodeRGB; +extern StructRNA RNA_ShaderNodeRGBCurve; +extern StructRNA RNA_ShaderNodeRGBToBW; +extern StructRNA RNA_ShaderNodeSeparateRGB; +extern StructRNA RNA_ShaderNodeSqueeze; +extern StructRNA RNA_ShaderNodeTexture; +extern StructRNA RNA_ShaderNodeValToRGB; +extern StructRNA RNA_ShaderNodeValue; +extern StructRNA RNA_ShaderNodeVectorCurve; +extern StructRNA RNA_ShaderNodeVectorMath; extern StructRNA RNA_ShapeKey; extern StructRNA RNA_ShapeKeyBezierPoint; extern StructRNA RNA_ShapeKeyCurvePoint; extern StructRNA RNA_ShapeKeyPoint; +extern StructRNA RNA_ShrinkwrapConstraint; extern StructRNA RNA_ShrinkwrapModifier; extern StructRNA RNA_SimpleDeformModifier; extern StructRNA RNA_SmoothModifier; @@ -252,53 +363,92 @@ extern StructRNA RNA_Space; extern StructRNA RNA_Space3DView; extern StructRNA RNA_SpaceButtonsWindow; extern StructRNA RNA_SpaceImageEditor; -extern StructRNA RNA_SpaceUVEditor; -extern StructRNA RNA_SpaceTextEditor; extern StructRNA RNA_SpaceOutliner; +extern StructRNA RNA_SpaceTextEditor; +extern StructRNA RNA_SpaceUVEditor; extern StructRNA RNA_SpeedControlSequence; extern StructRNA RNA_SpotLamp; +extern StructRNA RNA_StretchToConstraint; extern StructRNA RNA_StringProperty; extern StructRNA RNA_Struct; extern StructRNA RNA_StucciTexture; extern StructRNA RNA_SubsurfModifier; extern StructRNA RNA_SunLamp; +extern StructRNA RNA_SurfaceCurve; +extern StructRNA RNA_TexMapping; extern StructRNA RNA_Text; extern StructRNA RNA_TextBox; extern StructRNA RNA_TextCharacterFormat; +extern StructRNA RNA_TextCurve; extern StructRNA RNA_TextLine; extern StructRNA RNA_TextMarker; extern StructRNA RNA_Texture; +extern StructRNA RNA_TextureNode; +extern StructRNA RNA_TextureNodeBricks; +extern StructRNA RNA_TextureNodeChecker; +extern StructRNA RNA_TextureNodeCompose; +extern StructRNA RNA_TextureNodeCoordinates; +extern StructRNA RNA_TextureNodeCurveRGB; +extern StructRNA RNA_TextureNodeCurveTime; +extern StructRNA RNA_TextureNodeDecompose; +extern StructRNA RNA_TextureNodeDistance; +extern StructRNA RNA_TextureNodeHueSaturation; +extern StructRNA RNA_TextureNodeImage; +extern StructRNA RNA_TextureNodeInvert; +extern StructRNA RNA_TextureNodeMath; +extern StructRNA RNA_TextureNodeMixRGB; +extern StructRNA RNA_TextureNodeOutput; +extern StructRNA RNA_TextureNodeRGBToBW; +extern StructRNA RNA_TextureNodeRotate; +extern StructRNA RNA_TextureNodeScale; +extern StructRNA RNA_TextureNodeTexture; +extern StructRNA RNA_TextureNodeTranslate; +extern StructRNA RNA_TextureNodeValToNor; +extern StructRNA RNA_TextureNodeValToRGB; +extern StructRNA RNA_TextureNodeViewer; extern StructRNA RNA_TextureSlot; extern StructRNA RNA_Theme; -extern StructRNA RNA_ThemeDopeSheetEditor; extern StructRNA RNA_ThemeAudioWindow; extern StructRNA RNA_ThemeBoneColorSet; extern StructRNA RNA_ThemeButtonsWindow; +extern StructRNA RNA_ThemeDopeSheet; extern StructRNA RNA_ThemeFileBrowser; -extern StructRNA RNA_ThemeImageEditor; +extern StructRNA RNA_ThemeFontStyle; extern StructRNA RNA_ThemeGraphEditor; +extern StructRNA RNA_ThemeImageEditor; extern StructRNA RNA_ThemeNLAEditor; extern StructRNA RNA_ThemeNodeEditor; extern StructRNA RNA_ThemeOutliner; extern StructRNA RNA_ThemeSequenceEditor; +extern StructRNA RNA_ThemeStyle; extern StructRNA RNA_ThemeTextEditor; extern StructRNA RNA_ThemeTimeline; extern StructRNA RNA_ThemeUserInterface; extern StructRNA RNA_ThemeUserPreferences; extern StructRNA RNA_ThemeView3D; +extern StructRNA RNA_ThemeWidgetColors; extern StructRNA RNA_TimelineMarker; extern StructRNA RNA_ToolSettings; extern StructRNA RNA_TouchSensor; +extern StructRNA RNA_TrackToConstraint; +extern StructRNA RNA_TransformConstraint; extern StructRNA RNA_TransformSequence; +extern StructRNA RNA_UILayout; extern StructRNA RNA_UVProjectModifier; extern StructRNA RNA_UnknownType; extern StructRNA RNA_UserPreferences; +extern StructRNA RNA_UserPreferencesAutosave; +extern StructRNA RNA_UserPreferencesEdit; +extern StructRNA RNA_UserPreferencesFilePaths; +extern StructRNA RNA_UserPreferencesLanguage; +extern StructRNA RNA_UserPreferencesSystem; +extern StructRNA RNA_UserPreferencesView; extern StructRNA RNA_UserSolidLight; +extern StructRNA RNA_VPaint; extern StructRNA RNA_VectorFont; extern StructRNA RNA_VertexGroup; -extern StructRNA RNA_VoronoiTexture; -extern StructRNA RNA_VPaint; extern StructRNA RNA_VertexGroupElement; +extern StructRNA RNA_VoronoiTexture; extern StructRNA RNA_WaveModifier; extern StructRNA RNA_WindowManager; extern StructRNA RNA_WipeSequence; @@ -372,7 +522,6 @@ int RNA_property_flag(PropertyRNA *prop); int RNA_property_array_length(PropertyRNA *prop); -StructRNA *RNA_property_pointer_type(PropertyRNA *prop); int RNA_property_string_maxlength(PropertyRNA *prop); const char *RNA_property_ui_name(PropertyRNA *prop); @@ -390,6 +539,8 @@ void RNA_property_enum_items(PointerRNA *ptr, PropertyRNA *prop, const EnumPrope int RNA_property_enum_value(PointerRNA *ptr, PropertyRNA *prop, const char *identifier, int *value); int RNA_property_enum_identifier(PointerRNA *ptr, PropertyRNA *prop, const int value, const char **identifier); +StructRNA *RNA_property_pointer_type(PointerRNA *ptr, PropertyRNA *prop); + int RNA_property_editable(PointerRNA *ptr, PropertyRNA *prop); int RNA_property_animateable(PointerRNA *ptr, PropertyRNA *prop); int RNA_property_animated(PointerRNA *ptr, PropertyRNA *prop); @@ -572,6 +723,11 @@ int RNA_function_call_direct_lookup(PointerRNA *ptr, const char *identifier, con int RNA_function_call_direct_va(PointerRNA *ptr, FunctionRNA *func, const char *format, va_list args); int RNA_function_call_direct_va_lookup(PointerRNA *ptr, const char *identifier, const char *format, va_list args); +/* ID */ + +short RNA_type_to_ID_code(StructRNA *type); +StructRNA *ID_code_to_RNA_type(short idcode); + #ifdef __cplusplus } #endif diff --git a/source/blender/makesrna/RNA_define.h b/source/blender/makesrna/RNA_define.h index 5fcf2a30271..c40f50c34fc 100644 --- a/source/blender/makesrna/RNA_define.h +++ b/source/blender/makesrna/RNA_define.h @@ -145,7 +145,7 @@ void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char * void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range); void RNA_def_property_enum_funcs(PropertyRNA *prop, const char *get, const char *set, const char *item); void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const char *length, const char *set); -void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *set); +void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *set, const char *typef); void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, const char *next, const char *end, const char *get, const char *length, const char *lookupint, const char *lookupstring); /* Function */ diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index 1cfba4286c7..ea587174f54 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -1621,7 +1621,7 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr } case PROP_POINTER: { PointerPropertyRNA *pprop= (PointerPropertyRNA*)prop; - fprintf(f, "\t%s, %s, ", rna_function_string(pprop->get), rna_function_string(pprop->set)); + fprintf(f, "\t%s, %s, %s, ", rna_function_string(pprop->get), rna_function_string(pprop->set), rna_function_string(pprop->typef)); if(pprop->type) fprintf(f, "&RNA_%s\n", (char*)pprop->type); else fprintf(f, "NULL\n"); break; diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index eb57c91a9f7..56eda4eb735 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -25,6 +25,7 @@ #include <stdlib.h> #include <stdio.h> +#include "RNA_access.h" #include "RNA_define.h" #include "RNA_types.h" @@ -57,11 +58,41 @@ void rna_ID_name_set(PointerRNA *ptr, const char *value) test_idbutton(id->name+2); } -StructRNA *rna_ID_refine(PointerRNA *ptr) +short RNA_type_to_ID_code(StructRNA *type) { - ID *id= (ID*)ptr->data; + if(RNA_struct_is_a(type, &RNA_Action)) return ID_AC; + if(RNA_struct_is_a(type, &RNA_Armature)) return ID_AR; + if(RNA_struct_is_a(type, &RNA_Brush)) return ID_BR; + if(RNA_struct_is_a(type, &RNA_Camera)) return ID_CA; + if(RNA_struct_is_a(type, &RNA_Curve)) return ID_CU; + if(RNA_struct_is_a(type, &RNA_Group)) return ID_GR; + if(RNA_struct_is_a(type, &RNA_Image)) return ID_IM; + //if(RNA_struct_is_a(type, &RNA_Ipo)) return case ID_IP; + if(RNA_struct_is_a(type, &RNA_Key)) return ID_KE; + if(RNA_struct_is_a(type, &RNA_Lamp)) return ID_LA; + if(RNA_struct_is_a(type, &RNA_Library)) return ID_LI; + if(RNA_struct_is_a(type, &RNA_Lattice)) return ID_LT; + if(RNA_struct_is_a(type, &RNA_Material)) return ID_MA; + if(RNA_struct_is_a(type, &RNA_MetaBall)) return ID_MB; + if(RNA_struct_is_a(type, &RNA_NodeTree)) return ID_NT; + if(RNA_struct_is_a(type, &RNA_Mesh)) return ID_ME; + if(RNA_struct_is_a(type, &RNA_Object)) return ID_OB; + if(RNA_struct_is_a(type, &RNA_ParticleSettings)) return ID_PA; + if(RNA_struct_is_a(type, &RNA_Scene)) return ID_SCE; + if(RNA_struct_is_a(type, &RNA_Screen)) return ID_SCR; + if(RNA_struct_is_a(type, &RNA_Sound)) return ID_SO; + if(RNA_struct_is_a(type, &RNA_Text)) return ID_TXT; + if(RNA_struct_is_a(type, &RNA_Texture)) return ID_TE; + if(RNA_struct_is_a(type, &RNA_VectorFont)) return ID_VF; + if(RNA_struct_is_a(type, &RNA_World)) return ID_WO; + if(RNA_struct_is_a(type, &RNA_WindowManager)) return ID_WM; + + return 0; +} - switch(GS(id->name)) { +StructRNA *ID_code_to_RNA_type(short idcode) +{ + switch(idcode) { case ID_AC: return &RNA_Action; case ID_AR: return &RNA_Armature; case ID_BR: return &RNA_Brush; @@ -92,6 +123,13 @@ StructRNA *rna_ID_refine(PointerRNA *ptr) } } +StructRNA *rna_ID_refine(PointerRNA *ptr) +{ + ID *id= (ID*)ptr->data; + + return ID_code_to_RNA_type(GS(id->name)); +} + IDProperty *rna_ID_idproperties(PointerRNA *ptr, int create) { return IDP_GetProperties(ptr->data, create); diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 64c826d2c1e..c8037c1553a 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -417,7 +417,7 @@ PropertyRNA *RNA_struct_find_nested(PointerRNA *ptr, StructRNA *srna) for(; iter.valid; RNA_property_collection_next(&iter), i++) { /* This assumes that there can only be one user of this nested struct */ - if (RNA_property_pointer_type(iter.ptr.data) == srna) { + if (RNA_property_pointer_type(ptr, iter.ptr.data) == srna) { prop= iter.ptr.data; break; } @@ -595,14 +595,16 @@ int RNA_property_string_maxlength(PropertyRNA *prop) return sprop->maxlength; } -StructRNA *RNA_property_pointer_type(PropertyRNA *prop) +StructRNA *RNA_property_pointer_type(PointerRNA *ptr, PropertyRNA *prop) { prop= rna_ensure_property(prop); if(prop->type == PROP_POINTER) { PointerPropertyRNA *pprop= (PointerPropertyRNA*)prop; - if(pprop->type) + if(pprop->typef) + return pprop->typef(ptr); + else if(pprop->type) return pprop->type; } else if(prop->type == PROP_COLLECTION) { @@ -2670,7 +2672,7 @@ static int rna_function_parameter_parse(PointerRNA *ptr, PropertyRNA *prop, Prop return -1; } - ptype= RNA_property_pointer_type(prop); + ptype= RNA_property_pointer_type(ptr, prop); if(ptype == &RNA_AnyType) { *((PointerRNA*)dest)= *((PointerRNA*)src); diff --git a/source/blender/makesrna/intern/rna_context.c b/source/blender/makesrna/intern/rna_context.c index e45319a42a6..ed609c48e50 100644 --- a/source/blender/makesrna/intern/rna_context.c +++ b/source/blender/makesrna/intern/rna_context.c @@ -103,48 +103,48 @@ void RNA_def_context(BlenderRNA *brna) prop= RNA_def_property(srna, "manager", PROP_POINTER, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "WindowManager"); - RNA_def_property_pointer_funcs(prop, "rna_Context_manager_get", NULL); + RNA_def_property_pointer_funcs(prop, "rna_Context_manager_get", NULL, NULL); /* prop= RNA_def_property(srna, "window", PROP_POINTER, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "Window"); - RNA_def_property_pointer_funcs(prop, "rna_Context_window_get", NULL); */ + RNA_def_property_pointer_funcs(prop, "rna_Context_window_get", NULL, NULL); */ prop= RNA_def_property(srna, "screen", PROP_POINTER, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "Screen"); - RNA_def_property_pointer_funcs(prop, "rna_Context_screen_get", NULL); + RNA_def_property_pointer_funcs(prop, "rna_Context_screen_get", NULL, NULL); prop= RNA_def_property(srna, "area", PROP_POINTER, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "Area"); - RNA_def_property_pointer_funcs(prop, "rna_Context_area_get", NULL); + RNA_def_property_pointer_funcs(prop, "rna_Context_area_get", NULL, NULL); prop= RNA_def_property(srna, "space_data", PROP_POINTER, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "Space"); - RNA_def_property_pointer_funcs(prop, "rna_Context_space_data_get", NULL); + RNA_def_property_pointer_funcs(prop, "rna_Context_space_data_get", NULL, NULL); prop= RNA_def_property(srna, "region", PROP_POINTER, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "Region"); - RNA_def_property_pointer_funcs(prop, "rna_Context_region_get", NULL); + RNA_def_property_pointer_funcs(prop, "rna_Context_region_get", NULL, NULL); /*prop= RNA_def_property(srna, "region_data", PROP_POINTER, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "RegionData"); - RNA_def_property_pointer_funcs(prop, "rna_Context_region_data_get", NULL);*/ + RNA_def_property_pointer_funcs(prop, "rna_Context_region_data_get", NULL, NULL);*/ /* Data */ prop= RNA_def_property(srna, "main", PROP_POINTER, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "Main"); - RNA_def_property_pointer_funcs(prop, "rna_Context_main_get", NULL); + RNA_def_property_pointer_funcs(prop, "rna_Context_main_get", NULL, NULL); prop= RNA_def_property(srna, "scene", PROP_POINTER, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "Scene"); - RNA_def_property_pointer_funcs(prop, "rna_Context_scene_get", NULL); + RNA_def_property_pointer_funcs(prop, "rna_Context_scene_get", NULL, NULL); } #endif diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index c0b75c3c65f..aac9d75c6a6 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -39,6 +39,7 @@ EnumPropertyItem beztriple_handle_type_items[] = { {HD_ALIGN, "ALIGNED", "Aligned", ""}, {HD_AUTO_ANIM, "AUTO_CLAMPED", "Auto Clamped", ""}, {0, NULL, NULL, NULL}}; + EnumPropertyItem beztriple_interpolation_mode_items[] = { {BEZT_IPO_CONST, "CONSTANT", "Constant", ""}, {BEZT_IPO_LIN, "LINEAR", "Linear", ""}, @@ -47,6 +48,20 @@ EnumPropertyItem beztriple_interpolation_mode_items[] = { #ifdef RNA_RUNTIME +#include "DNA_object_types.h" + +#include "BKE_curve.h" + +StructRNA *rna_Curve_refine(PointerRNA *ptr) +{ + Curve *cu= (Curve*)ptr->data; + short obtype= curve_type(cu); + + if(obtype == OB_FONT) return &RNA_TextCurve; + else if(obtype == OB_SURF) return &RNA_SurfaceCurve; + else return &RNA_Curve; +} + static void rna_BezTriple_handle1_get(PointerRNA *ptr, float *values) { BezTriple *bt= (BezTriple*)ptr->data; @@ -391,7 +406,7 @@ static void rna_def_font(BlenderRNA *brna, StructRNA *srna) RNA_def_property_ui_text(prop, "Fast", "Don't fill polygons while editing."); } -void rna_def_textbox(BlenderRNA *brna) +static void rna_def_textbox(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; @@ -421,7 +436,7 @@ void rna_def_textbox(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Textbox Height", ""); } -void rna_def_charinfo(BlenderRNA *brna) +static void rna_def_charinfo(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; @@ -452,7 +467,32 @@ void rna_def_charinfo(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Wrap", ""); } -void rna_def_curve(BlenderRNA *brna) +static void rna_def_surface(BlenderRNA *brna) +{ + StructRNA *srna; + + srna= RNA_def_struct(brna, "SurfaceCurve", "Curve"); + RNA_def_struct_sdna(srna, "Curve"); + RNA_def_struct_ui_text(srna, "Surface Curve", "Curve datablock used for storing surfaces."); + RNA_def_struct_ui_icon(srna, ICON_SURFACE_DATA); + + rna_def_nurbs(brna, srna); +} + +static void rna_def_text(BlenderRNA *brna) +{ + StructRNA *srna; + + srna= RNA_def_struct(brna, "TextCurve", "Curve"); + RNA_def_struct_sdna(srna, "Curve"); + RNA_def_struct_ui_text(srna, "Text Curve", "Curve datablock used for storing text."); + RNA_def_struct_ui_icon(srna, ICON_FONT_DATA); + + rna_def_font(brna, srna); + rna_def_nurbs(brna, srna); +} + +static void rna_def_curve(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; @@ -460,6 +500,7 @@ void rna_def_curve(BlenderRNA *brna) srna= RNA_def_struct(brna, "Curve", "ID"); RNA_def_struct_ui_text(srna, "Curve", "Curve datablock storing curves, splines and NURBS."); RNA_def_struct_ui_icon(srna, ICON_CURVE_DATA); + RNA_def_struct_refine_func(srna, "rna_Curve_refine"); rna_def_animdata_common(srna); rna_def_texmat_common(srna, "rna_Curve_texspace_editable"); @@ -474,8 +515,6 @@ void rna_def_curve(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Curves", "Collection of curves in this curve data object."); rna_def_path(brna, srna); - rna_def_nurbs(brna, srna); - rna_def_font(brna, srna); /* Number values */ prop= RNA_def_property(srna, "bevel_resolution", PROP_INT, PROP_NONE); @@ -548,8 +587,7 @@ void rna_def_curve(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Retopo", "Turn on the re-topology tool."); } - -void rna_def_curve_nurb(BlenderRNA *brna) +static void rna_def_curve_nurb(BlenderRNA *brna) { static EnumPropertyItem spline_interpolation_items[] = { {BEZT_IPO_CONST, "LINEAR", "Linear", ""}, @@ -666,11 +704,11 @@ void rna_def_curve_nurb(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Character Index", "the location of this character in the text data (only for text curves)"); } - - void RNA_def_curve(BlenderRNA *brna) { rna_def_curve(brna); + rna_def_surface(brna); + rna_def_text(brna); rna_def_textbox(brna); rna_def_charinfo(brna); rna_def_bpoint(brna); diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index 12d96965e36..33d94e800d1 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -621,7 +621,7 @@ StructRNA *RNA_def_struct(BlenderRNA *brna, const char *identifier, const char * if(DefRNA.preprocess) { RNA_def_property_struct_type(prop, "Struct"); - RNA_def_property_pointer_funcs(prop, "rna_builtin_type_get", NULL); + RNA_def_property_pointer_funcs(prop, "rna_builtin_type_get", NULL, NULL); } else { #ifdef RNA_RUNTIME @@ -1744,7 +1744,7 @@ void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const cha } } -void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *set) +void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *set, const char *typef) { StructRNA *srna= DefRNA.laststruct; @@ -1759,6 +1759,7 @@ void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const ch if(get) pprop->get= (PropPointerGetFunc)get; if(set) pprop->set= (PropPointerSetFunc)set; + if(typef) pprop->typef= (PropPointerTypeFunc)typef; break; } default: diff --git a/source/blender/makesrna/intern/rna_internal_types.h b/source/blender/makesrna/intern/rna_internal_types.h index 60f057efa63..d690251f503 100644 --- a/source/blender/makesrna/intern/rna_internal_types.h +++ b/source/blender/makesrna/intern/rna_internal_types.h @@ -69,6 +69,7 @@ typedef int (*PropEnumGetFunc)(struct PointerRNA *ptr); typedef void (*PropEnumSetFunc)(struct PointerRNA *ptr, int value); typedef EnumPropertyItem *(*PropEnumItemFunc)(struct PointerRNA *ptr); typedef PointerRNA (*PropPointerGetFunc)(struct PointerRNA *ptr); +typedef StructRNA* (*PropPointerTypeFunc)(struct PointerRNA *ptr); typedef void (*PropPointerSetFunc)(struct PointerRNA *ptr, const PointerRNA value); typedef void (*PropCollectionBeginFunc)(struct CollectionPropertyIterator *iter, struct PointerRNA *ptr); typedef void (*PropCollectionNextFunc)(struct CollectionPropertyIterator *iter); @@ -227,6 +228,7 @@ typedef struct PointerPropertyRNA { PropPointerGetFunc get; PropPointerSetFunc set; + PropPointerTypeFunc typef; struct StructRNA *type; } PointerPropertyRNA; diff --git a/source/blender/makesrna/intern/rna_key.c b/source/blender/makesrna/intern/rna_key.c index d5f28503e4a..ae03cca74c2 100644 --- a/source/blender/makesrna/intern/rna_key.c +++ b/source/blender/makesrna/intern/rna_key.c @@ -315,7 +315,7 @@ static void rna_def_keyblock(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "ShapeKey"); RNA_def_property_ui_text(prop, "Relative Key", "Shape used as a relative key."); - RNA_def_property_pointer_funcs(prop, "rna_ShapeKey_relative_key_get", NULL); + RNA_def_property_pointer_funcs(prop, "rna_ShapeKey_relative_key_get", NULL, NULL); prop= RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", KEYBLOCK_MUTE); diff --git a/source/blender/makesrna/intern/rna_lamp.c b/source/blender/makesrna/intern/rna_lamp.c index 77ac4de814e..97ad5b7f6a4 100644 --- a/source/blender/makesrna/intern/rna_lamp.c +++ b/source/blender/makesrna/intern/rna_lamp.c @@ -651,7 +651,7 @@ static void rna_def_sun_lamp(BlenderRNA *brna) /* sky */ prop= RNA_def_property(srna, "sky", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_struct_type(prop, "LampSkySettings"); - RNA_def_property_pointer_funcs(prop, "rna_Lamp_sky_settings_get", NULL); + RNA_def_property_pointer_funcs(prop, "rna_Lamp_sky_settings_get", NULL, NULL); RNA_def_property_ui_text(prop, "Sky Settings", "Sky related settings for sun lamps."); rna_def_lamp_sky_settings(brna); diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index 780f4aae2e3..8c6fdc71cc6 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -891,27 +891,27 @@ void RNA_def_material(BlenderRNA *brna) /* nested structs */ prop= RNA_def_property(srna, "raytrace_mirror", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_struct_type(prop, "MaterialRaytraceMirror"); - RNA_def_property_pointer_funcs(prop, "rna_Material_mirror_get", NULL); + RNA_def_property_pointer_funcs(prop, "rna_Material_mirror_get", NULL, NULL); RNA_def_property_ui_text(prop, "Raytrace Mirror", "Raytraced reflection settings for the material."); prop= RNA_def_property(srna, "raytrace_transparency", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_struct_type(prop, "MaterialRaytraceTransparency"); - RNA_def_property_pointer_funcs(prop, "rna_Material_transp_get", NULL); + RNA_def_property_pointer_funcs(prop, "rna_Material_transp_get", NULL, NULL); RNA_def_property_ui_text(prop, "Raytrace Transparency", "Raytraced reflection settings for the material."); prop= RNA_def_property(srna, "halo", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_struct_type(prop, "MaterialHalo"); - RNA_def_property_pointer_funcs(prop, "rna_Material_halo_get", NULL); + RNA_def_property_pointer_funcs(prop, "rna_Material_halo_get", NULL, NULL); RNA_def_property_ui_text(prop, "Halo", "Halo settings for the material."); prop= RNA_def_property(srna, "subsurface_scattering", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_struct_type(prop, "MaterialSubsurfaceScattering"); - RNA_def_property_pointer_funcs(prop, "rna_Material_sss_get", NULL); + RNA_def_property_pointer_funcs(prop, "rna_Material_sss_get", NULL, NULL); RNA_def_property_ui_text(prop, "Subsurface Scattering", "Subsurface scattering settings for the material."); prop= RNA_def_property(srna, "strand", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_struct_type(prop, "MaterialStrand"); - RNA_def_property_pointer_funcs(prop, "rna_Material_strand_get", NULL); + RNA_def_property_pointer_funcs(prop, "rna_Material_strand_get", NULL, NULL); RNA_def_property_ui_text(prop, "Strand", "Strand settings for the material."); /* nodetree */ @@ -956,7 +956,7 @@ void rna_def_mtex_common(StructRNA *srna, const char *begin, const char *activeg prop= RNA_def_property(srna, "active_texture", PROP_POINTER, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, structname); - RNA_def_property_pointer_funcs(prop, activeget, NULL); + RNA_def_property_pointer_funcs(prop, activeget, NULL, NULL); RNA_def_property_ui_text(prop, "Active Texture", "Active texture slot being displayed."); prop= RNA_def_property(srna, "active_texture_index", PROP_INT, PROP_UNSIGNED); diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index 92e53cf7606..e58b3c51fec 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -771,7 +771,7 @@ static void rna_def_mtface(BlenderRNA *brna) prop= RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "tpage"); - RNA_def_property_pointer_funcs(prop, NULL, "rna_TextureFace_image_set"); + RNA_def_property_pointer_funcs(prop, NULL, "rna_TextureFace_image_set", NULL); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Image", ""); diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 6673b8d43f7..be1e6a317a2 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -431,7 +431,7 @@ static void rna_def_modifier_lattice(BlenderRNA *brna) prop= RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); RNA_def_property_ui_text(prop, "Object", "Lattice object to deform with."); - RNA_def_property_pointer_funcs(prop, NULL, "rna_LatticeModifier_object_set"); + RNA_def_property_pointer_funcs(prop, NULL, "rna_LatticeModifier_object_set", NULL); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_dependency_update"); @@ -463,7 +463,7 @@ static void rna_def_modifier_curve(BlenderRNA *brna) prop= RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); RNA_def_property_ui_text(prop, "Object", "Curve object to deform with."); - RNA_def_property_pointer_funcs(prop, NULL, "rna_CurveModifier_object_set"); + RNA_def_property_pointer_funcs(prop, NULL, "rna_CurveModifier_object_set", NULL); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_dependency_update"); @@ -754,7 +754,7 @@ static void rna_def_modifier_armature(BlenderRNA *brna) prop= RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); RNA_def_property_ui_text(prop, "Object", "Armature object to deform with."); - RNA_def_property_pointer_funcs(prop, NULL, "rna_ArmatureModifier_object_set"); + RNA_def_property_pointer_funcs(prop, NULL, "rna_ArmatureModifier_object_set", NULL); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_dependency_update"); @@ -856,7 +856,7 @@ static void rna_def_modifier_boolean(BlenderRNA *brna) prop= RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); RNA_def_property_ui_text(prop, "Object", "Mesh object to use for boolean operation."); - RNA_def_property_pointer_funcs(prop, NULL, "rna_BooleanModifier_object_set"); + RNA_def_property_pointer_funcs(prop, NULL, "rna_BooleanModifier_object_set", NULL); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_dependency_update"); @@ -903,7 +903,7 @@ static void rna_def_modifier_array(BlenderRNA *brna) prop= RNA_def_property(srna, "curve", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "curve_ob"); RNA_def_property_ui_text(prop, "Curve", "Curve object to fit array length to."); - RNA_def_property_pointer_funcs(prop, NULL, "rna_ArrayModifier_curve_set"); + RNA_def_property_pointer_funcs(prop, NULL, "rna_ArrayModifier_curve_set", NULL); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_dependency_update"); @@ -961,13 +961,13 @@ static void rna_def_modifier_array(BlenderRNA *brna) /* Caps */ prop= RNA_def_property(srna, "start_cap", PROP_POINTER, PROP_NONE); RNA_def_property_ui_text(prop, "Start Cap", "Mesh object to use as a start cap."); - RNA_def_property_pointer_funcs(prop, NULL, "rna_ArrayModifier_start_cap_set"); + RNA_def_property_pointer_funcs(prop, NULL, "rna_ArrayModifier_start_cap_set", NULL); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); prop= RNA_def_property(srna, "end_cap", PROP_POINTER, PROP_NONE); RNA_def_property_ui_text(prop, "End Cap", "Mesh object to use as an end cap."); - RNA_def_property_pointer_funcs(prop, NULL, "rna_ArrayModifier_end_cap_set"); + RNA_def_property_pointer_funcs(prop, NULL, "rna_ArrayModifier_end_cap_set", NULL); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_dependency_update"); } @@ -1236,7 +1236,7 @@ static void rna_def_modifier_meshdeform(BlenderRNA *brna) prop= RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); RNA_def_property_ui_text(prop, "Object", "Mesh object to deform with."); - RNA_def_property_pointer_funcs(prop, NULL, "rna_MeshDeformModifier_object_set"); + RNA_def_property_pointer_funcs(prop, NULL, "rna_MeshDeformModifier_object_set", NULL); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_dependency_update"); @@ -1483,14 +1483,14 @@ static void rna_def_modifier_shrinkwrap(BlenderRNA *brna) prop= RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE); RNA_def_property_ui_text(prop, "Target", "Mesh target to shrink to."); - RNA_def_property_pointer_funcs(prop, NULL, "rna_ShrinkwrapModifier_target_set"); + RNA_def_property_pointer_funcs(prop, NULL, "rna_ShrinkwrapModifier_target_set", NULL); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_dependency_update"); prop= RNA_def_property(srna, "auxiliary_target", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "auxTarget"); RNA_def_property_ui_text(prop, "Auxiliary Target", "Additional mesh target to shrink to."); - RNA_def_property_pointer_funcs(prop, NULL, "rna_ShrinkwrapModifier_auxiliary_target_set"); + RNA_def_property_pointer_funcs(prop, NULL, "rna_ShrinkwrapModifier_auxiliary_target_set", NULL); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_dependency_update"); @@ -1593,7 +1593,7 @@ static void rna_def_modifier_mask(BlenderRNA *brna) prop= RNA_def_property(srna, "armature", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "ob_arm"); RNA_def_property_ui_text(prop, "Armature", "Armature to use as source of bones to mask."); - RNA_def_property_pointer_funcs(prop, NULL, "rna_MaskModifier_armature_set"); + RNA_def_property_pointer_funcs(prop, NULL, "rna_MaskModifier_armature_set", NULL); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_dependency_update"); diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 96249b062f6..8a90af69641 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -549,13 +549,13 @@ static void def_cmp_image(StructRNA *srna) { PropertyRNA *prop; - static EnumPropertyItem type_items[] = { + /*static EnumPropertyItem type_items[] = { {IMA_SRC_FILE, "IMAGE", "Image", ""}, {IMA_SRC_MOVIE, "MOVIE", "Movie", ""}, {IMA_SRC_SEQUENCE, "SEQUENCE", "Sequence", ""}, {IMA_SRC_GENERATED, "GENERATED", "Generated", ""}, {0, NULL, NULL, NULL} - }; + };*/ prop = RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "id"); @@ -1109,12 +1109,12 @@ static void def_cmp_glare(StructRNA *srna) {0, NULL, NULL, NULL} }; - static EnumPropertyItem quality_items[] = { + /*static EnumPropertyItem quality_items[] = { {0, "HIGH", "High", ""}, {1, "MEDIUM", "Medium", ""}, {2, "LOW", "Low", ""}, {0, NULL, NULL, NULL} - }; + };*/ RNA_def_struct_sdna_from(srna, "NodeGlare", "storage"); diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index d945fb26982..dcdd749be6e 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -41,9 +41,12 @@ #ifdef RNA_RUNTIME +#include "BKE_armature.h" #include "BKE_context.h" +#include "BKE_curve.h" #include "BKE_depsgraph.h" #include "BKE_material.h" +#include "BKE_mesh.h" #include "BKE_particle.h" static void rna_Object_update(bContext *C, PointerRNA *ptr) @@ -51,12 +54,69 @@ static void rna_Object_update(bContext *C, PointerRNA *ptr) DAG_object_flush_update(CTX_data_scene(C), ptr->id.data, OB_RECALC_OB); } +static void rna_Object_update_data(bContext *C, PointerRNA *ptr) +{ + DAG_object_flush_update(CTX_data_scene(C), ptr->id.data, OB_RECALC_DATA); +} + static void rna_Object_dependency_update(bContext *C, PointerRNA *ptr) { DAG_object_flush_update(CTX_data_scene(C), ptr->id.data, OB_RECALC_OB); DAG_scene_sort(CTX_data_scene(C)); } +static int rna_Object_data_editable(PointerRNA *ptr) +{ + Object *ob= (Object*)ptr->data; + + return (ob->type == OB_EMPTY)? 0: PROP_EDITABLE; +} + +static void rna_Object_data_set(PointerRNA *ptr, PointerRNA value) +{ + Object *ob= (Object*)ptr->data; + ID *id= value.data; + + if(ob->type == OB_EMPTY || id == NULL) + return; + + if(ob->type == OB_MESH) { + set_mesh(ob, (Mesh*)id); + } + else { + if(ob->data) + id_us_min((ID*)ob->data); + if(id) + id_us_plus(id); + + ob->data= id; + test_object_materials(id); + + if(GS(id->name)==ID_CU ) + test_curve_type(ob); + else if(ob->type==OB_ARMATURE) + armature_rebuild_pose(ob, ob->data); + } +} + +static StructRNA *rna_Object_data_typef(PointerRNA *ptr) +{ + Object *ob= (Object*)ptr->data; + + switch(ob->type) { + case OB_MESH: return &RNA_Mesh; + case OB_CURVE: return &RNA_Curve; + case OB_SURF: return &RNA_Curve; + case OB_FONT: return &RNA_Curve; + case OB_MBALL: return &RNA_MetaBall; + case OB_LAMP: return &RNA_Lamp; + case OB_CAMERA: return &RNA_Camera; + case OB_LATTICE: return &RNA_Lattice; + case OB_ARMATURE: return &RNA_Armature; + default: return &RNA_ID; + } +} + static int rna_VertexGroup_index_get(PointerRNA *ptr) { Object *ob= (Object*)ptr->id.data; @@ -170,8 +230,8 @@ void rna_object_vcollayer_name_set(PointerRNA *ptr, const char *value, char *res static void rna_Object_active_material_index_range(PointerRNA *ptr, int *min, int *max) { Object *ob= (Object*)ptr->id.data; - *min= 0; - *max= ob->totcol-1; + *min= 1; + *max= ob->totcol; } static PointerRNA rna_Object_active_material_get(PointerRNA *ptr) @@ -235,9 +295,9 @@ static int rna_MaterialSlot_name_length(PointerRNA *ptr) ma= give_current_material(ob, index+1); if(ma) - return strlen(ma->id.name+2) + 10; + return strlen(ma->id.name+2); - return 10; + return 0; } static void rna_MaterialSlot_name_get(PointerRNA *ptr, char *str) @@ -246,11 +306,12 @@ static void rna_MaterialSlot_name_get(PointerRNA *ptr, char *str) Material *ma; int index= (Material**)ptr->data - ob->mat; - sprintf(str, "%d: ", index+1); - ma= give_current_material(ob, index+1); + if(ma) - strcat(str, ma->id.name+2); + strcpy(str, ma->id.name+2); + else + strcpy(str, ""); } static PointerRNA rna_Object_active_particle_system_get(PointerRNA *ptr) @@ -289,7 +350,7 @@ static void rna_GameObjectSettings_state_set(PointerRNA *ptr, const int *values) Object *ob= (Object*)ptr->data; int i, tot= 0; - /* ensure we always have some stateer selected */ + /* ensure we always have some state selected */ for(i=0; i<20; i++) if(values[i]) tot++; @@ -346,7 +407,7 @@ static void rna_def_material_slot(BlenderRNA *brna) prop= RNA_def_property(srna, "material", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "Material"); RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_pointer_funcs(prop, "rna_MaterialSlot_material_get", "rna_MaterialSlot_material_set"); + RNA_def_property_pointer_funcs(prop, "rna_MaterialSlot_material_get", "rna_MaterialSlot_material_set", NULL); RNA_def_property_ui_text(prop, "Material", "Material datablock used by this material slot."); prop= RNA_def_property(srna, "link", PROP_ENUM, PROP_NONE); @@ -609,7 +670,11 @@ static StructRNA *rna_def_object(BlenderRNA *brna) prop= RNA_def_property(srna, "data", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "ID"); + RNA_def_property_pointer_funcs(prop, NULL, "rna_Object_data_set", "rna_Object_data_typef"); + RNA_def_property_editable_func(prop, "rna_Object_data_editable"); + RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Data", "Object data."); + RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_update_data"); prop= RNA_def_property(srna, "layers", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "lay", 1); @@ -679,7 +744,7 @@ static StructRNA *rna_def_object(BlenderRNA *brna) prop= RNA_def_property(srna, "active_material", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "MaterialSlot"); - RNA_def_property_pointer_funcs(prop, "rna_Object_active_material_get", NULL); + RNA_def_property_pointer_funcs(prop, "rna_Object_active_material_get", NULL, NULL); RNA_def_property_ui_text(prop, "Active Material", "Active material being displayed."); prop= RNA_def_property(srna, "active_material_index", PROP_INT, PROP_UNSIGNED); @@ -747,7 +812,7 @@ static StructRNA *rna_def_object(BlenderRNA *brna) prop= RNA_def_property(srna, "game", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_struct_type(prop, "GameObjectSettings"); - RNA_def_property_pointer_funcs(prop, "rna_Object_game_settings_get", NULL); + RNA_def_property_pointer_funcs(prop, "rna_Object_game_settings_get", NULL, NULL); RNA_def_property_ui_text(prop, "Game Settings", "Game engine related settings for the object."); /* vertex groups */ @@ -759,7 +824,7 @@ static StructRNA *rna_def_object(BlenderRNA *brna) prop= RNA_def_property(srna, "active_vertex_group", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "VertexGroup"); - RNA_def_property_pointer_funcs(prop, "rna_Object_active_vertex_group_get", NULL); + RNA_def_property_pointer_funcs(prop, "rna_Object_active_vertex_group_get", NULL, NULL); RNA_def_property_ui_text(prop, "Active Vertex Group", "Vertex groups of the object."); /* empty */ @@ -809,7 +874,7 @@ static StructRNA *rna_def_object(BlenderRNA *brna) prop= RNA_def_property(srna, "active_particle_system", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "ParticleSystem"); - RNA_def_property_pointer_funcs(prop, "rna_Object_active_particle_system_get", NULL); + RNA_def_property_pointer_funcs(prop, "rna_Object_active_particle_system_get", NULL, NULL); RNA_def_property_ui_text(prop, "Active Particle System", "Active particle system being displayed"); /* restrict */ diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index 7c4f4eba27f..8d23f9538a5 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -144,21 +144,19 @@ static int rna_ParticleSystem_name_length(PointerRNA *ptr) ParticleSystem *psys= ptr->data; if(psys->part) - return strlen(psys->part->id.name+2) + 10; + return strlen(psys->part->id.name+2); - return 10; + return 0; } static void rna_ParticleSystem_name_get(PointerRNA *ptr, char *str) { - Object *ob= ptr->id.data; ParticleSystem *psys= ptr->data; - int index= BLI_findindex(&ob->particlesystem, psys); - - sprintf(str, "%d: ", index+1); if(psys->part) - strcat(str, psys->part->id.name+2); + strcpy(str, psys->part->id.name+2); + else + strcpy(str, ""); } static EnumPropertyItem from_items[] = { diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c index 75bdbebb474..8ea8844c65f 100644 --- a/source/blender/makesrna/intern/rna_rna.c +++ b/source/blender/makesrna/intern/rna_rna.c @@ -593,19 +593,19 @@ static void rna_def_struct(BlenderRNA *brna) prop= RNA_def_property(srna, "base", PROP_POINTER, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "Struct"); - RNA_def_property_pointer_funcs(prop, "rna_Struct_base_get", NULL); + RNA_def_property_pointer_funcs(prop, "rna_Struct_base_get", NULL, NULL); RNA_def_property_ui_text(prop, "Base", "Struct definition this is derived from."); prop= RNA_def_property(srna, "nested", PROP_POINTER, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "Struct"); - RNA_def_property_pointer_funcs(prop, "rna_Struct_nested_get", NULL); + RNA_def_property_pointer_funcs(prop, "rna_Struct_nested_get", NULL, NULL); RNA_def_property_ui_text(prop, "Nested", "Struct in which this struct is always nested, and to which it logically belongs."); prop= RNA_def_property(srna, "name_property", PROP_POINTER, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "StringProperty"); - RNA_def_property_pointer_funcs(prop, "rna_Struct_name_property_get", NULL); + RNA_def_property_pointer_funcs(prop, "rna_Struct_name_property_get", NULL, NULL); RNA_def_property_ui_text(prop, "Name Property", "Property that gives the name of the struct."); prop= RNA_def_property(srna, "properties", PROP_COLLECTION, PROP_NONE); @@ -832,9 +832,9 @@ static void rna_def_pointer_property(StructRNA *srna, PropertyType type) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "Struct"); if(type == PROP_POINTER) - RNA_def_property_pointer_funcs(prop, "rna_PointerProperty_fixed_type_get", NULL); + RNA_def_property_pointer_funcs(prop, "rna_PointerProperty_fixed_type_get", NULL, NULL); else - RNA_def_property_pointer_funcs(prop, "rna_CollectionProperty_fixed_type_get", NULL); + RNA_def_property_pointer_funcs(prop, "rna_CollectionProperty_fixed_type_get", NULL, NULL); RNA_def_property_ui_text(prop, "Pointer Type", "Fixed pointer type, empty if variable type."); } diff --git a/source/blender/makesrna/intern/rna_sequence.c b/source/blender/makesrna/intern/rna_sequence.c index 92043af420a..da8a6aa43fc 100644 --- a/source/blender/makesrna/intern/rna_sequence.c +++ b/source/blender/makesrna/intern/rna_sequence.c @@ -36,6 +36,16 @@ #ifdef RNA_RUNTIME +static int rna_SequenceEditor_name_length(PointerRNA *ptr) +{ + return strlen("Sequence Editor"); +} + +static void rna_SequenceEditor_name_get(PointerRNA *ptr, char *str) +{ + strcpy(str, "Sequence Editor"); +} + /* name functions that ignore the first two characters */ static void rna_Sequence_name_get(PointerRNA *ptr, char *value) { @@ -365,8 +375,15 @@ void rna_def_editor(BlenderRNA *brna) srna = RNA_def_struct(brna, "SequenceEditor", NULL); RNA_def_struct_ui_text(srna, "Sequence Editor", "Sequence editing data for a Scene datablock."); + RNA_def_struct_ui_icon(srna, ICON_SEQUENCE); RNA_def_struct_sdna(srna, "Editing"); + prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); + RNA_def_property_string_funcs(prop, "rna_SequenceEditor_name_get", "rna_SequenceEditor_name_length", NULL); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Name", ""); + RNA_def_struct_name_property(srna, prop); + prop= RNA_def_property(srna, "sequences", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "seqbase", NULL); RNA_def_property_struct_type(prop, "Sequence"); diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index e9c6ce8156f..24091ac8b7d 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -24,6 +24,7 @@ #include <stdlib.h> +#include "RNA_access.h" #include "RNA_define.h" #include "RNA_types.h" @@ -134,6 +135,16 @@ void rna_SpaceTextEditor_text_set(PointerRNA *ptr, PointerRNA value) st->top= 0; } +StructRNA *rna_SpaceButtonsWindow_pin_id_typef(PointerRNA *ptr) +{ + SpaceButs *sbuts= (SpaceButs*)(ptr->data); + + if(sbuts->pinid) + return ID_code_to_RNA_type(GS(sbuts->pinid->name)); + + return &RNA_ID; +} + #else static void rna_def_space(BlenderRNA *brna) @@ -510,6 +521,13 @@ static void rna_def_space_buttons(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "align"); RNA_def_property_enum_items(prop, panel_alignment_items); RNA_def_property_ui_text(prop, "Panel Alignment", "Arrangement of the panels within the buttons window"); + + /* pinned data */ + prop= RNA_def_property(srna, "pin_id", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "pinid"); + RNA_def_property_struct_type(prop, "ID"); + RNA_def_property_pointer_funcs(prop, NULL, NULL, "rna_SpaceButtonsWindow_pin_id_typef"); + RNA_def_property_flag(prop, PROP_EDITABLE); } static void rna_def_space_image(BlenderRNA *brna) @@ -558,7 +576,7 @@ static void rna_def_space_image(BlenderRNA *brna) /* uv */ prop= RNA_def_property(srna, "uv_editor", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_struct_type(prop, "SpaceUVEditor"); - RNA_def_property_pointer_funcs(prop, "rna_SpaceImage_uvedit_get", NULL); + RNA_def_property_pointer_funcs(prop, "rna_SpaceImage_uvedit_get", NULL, NULL); RNA_def_property_ui_text(prop, "UV Editor", "UV editor settings."); /* paint */ @@ -603,7 +621,7 @@ static void rna_def_space_text(BlenderRNA *brna) prop= RNA_def_property(srna, "text", PROP_POINTER, PROP_NONE); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Text", "Text displayed and edited in this space."); - RNA_def_property_pointer_funcs(prop, NULL, "rna_SpaceTextEditor_text_set"); + RNA_def_property_pointer_funcs(prop, NULL, "rna_SpaceTextEditor_text_set", NULL); RNA_def_property_update(prop, NC_TEXT|NA_EDITED, NULL); /* display */ diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c index 57f44017450..360a0938bb2 100644 --- a/source/blender/makesrna/intern/rna_texture.c +++ b/source/blender/makesrna/intern/rna_texture.c @@ -77,48 +77,24 @@ StructRNA *rna_Texture_refine(struct PointerRNA *ptr) } } -static int rna_texture_slot_index(PointerRNA *ptr) -{ - ID *id= ptr->id.data; - MTex **mtex; - int a; - - if(id) { - switch(GS(id->name)) { - case ID_MA: mtex= ((Material*)id)->mtex; break; - case ID_WO: mtex= ((World*)id)->mtex; break; - case ID_LA: mtex= ((Lamp*)id)->mtex; break; - case ID_BR: mtex= ((Brush*)id)->mtex; break; - default: return 0; - } - - for(a=0; a<MAX_MTEX; a++) - if(mtex[a] == ptr->data) - return a; - } - - return 0; -} - static int rna_TextureSlot_name_length(PointerRNA *ptr) { MTex *mtex= ptr->data; if(mtex->tex) - return strlen(mtex->tex->id.name+2) + 10; + return strlen(mtex->tex->id.name+2); - return 10; + return 0; } static void rna_TextureSlot_name_get(PointerRNA *ptr, char *str) { MTex *mtex= ptr->data; - int index= rna_texture_slot_index(ptr); - - sprintf(str, "%d: ", index+1); if(mtex->tex) - strcat(str, mtex->tex->id.name+2); + strcpy(str, mtex->tex->id.name+2); + else + strcpy(str, ""); } #else diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 6376a3029ad..e0d3201a5e7 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -2078,32 +2078,32 @@ void RNA_def_userdef(BlenderRNA *brna) /* nested structs */ prop= RNA_def_property(srna, "view", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_struct_type(prop, "UserPreferencesView"); - RNA_def_property_pointer_funcs(prop, "rna_UserDef_view_get", NULL); + RNA_def_property_pointer_funcs(prop, "rna_UserDef_view_get", NULL, NULL); RNA_def_property_ui_text(prop, "View & Controls", "Preferences related to viewing data."); prop= RNA_def_property(srna, "edit", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_struct_type(prop, "UserPreferencesEdit"); - RNA_def_property_pointer_funcs(prop, "rna_UserDef_edit_get", NULL); + RNA_def_property_pointer_funcs(prop, "rna_UserDef_edit_get", NULL, NULL); RNA_def_property_ui_text(prop, "Edit Methods", "Settings for interacting with Blender data."); prop= RNA_def_property(srna, "autosave", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_struct_type(prop, "UserPreferencesAutosave"); - RNA_def_property_pointer_funcs(prop, "rna_UserDef_autosave_get", NULL); + RNA_def_property_pointer_funcs(prop, "rna_UserDef_autosave_get", NULL, NULL); RNA_def_property_ui_text(prop, "Auto Save", "Automatic backup file settings."); prop= RNA_def_property(srna, "language", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_struct_type(prop, "UserPreferencesLanguage"); - RNA_def_property_pointer_funcs(prop, "rna_UserDef_language_get", NULL); + RNA_def_property_pointer_funcs(prop, "rna_UserDef_language_get", NULL, NULL); RNA_def_property_ui_text(prop, "Language & Font", "User interface translation settings."); prop= RNA_def_property(srna, "filepaths", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_struct_type(prop, "UserPreferencesFilePaths"); - RNA_def_property_pointer_funcs(prop, "rna_UserDef_filepaths_get", NULL); + RNA_def_property_pointer_funcs(prop, "rna_UserDef_filepaths_get", NULL, NULL); RNA_def_property_ui_text(prop, "File Paths", "Default paths for external files."); prop= RNA_def_property(srna, "system", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_struct_type(prop, "UserPreferencesSystem"); - RNA_def_property_pointer_funcs(prop, "rna_UserDef_system_get", NULL); + RNA_def_property_pointer_funcs(prop, "rna_UserDef_system_get", NULL, NULL); RNA_def_property_ui_text(prop, "System & OpenGL", "Graphics driver and operating system settings."); rna_def_userdef_view(brna); diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index b4d2cb35121..22ce207c6a9 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -107,7 +107,7 @@ static void rna_def_operator(BlenderRNA *brna) prop= RNA_def_property(srna, "properties", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_struct_type(prop, "OperatorProperties"); RNA_def_property_ui_text(prop, "Properties", ""); - RNA_def_property_pointer_funcs(prop, "rna_Operator_properties_get", NULL); + RNA_def_property_pointer_funcs(prop, "rna_Operator_properties_get", NULL, NULL); srna= RNA_def_struct(brna, "OperatorProperties", NULL); RNA_def_struct_ui_text(srna, "Operator Properties", "Input properties of an Operator."); diff --git a/source/blender/makesrna/intern/rna_world.c b/source/blender/makesrna/intern/rna_world.c index 4c7e085512d..ac14be25e85 100644 --- a/source/blender/makesrna/intern/rna_world.c +++ b/source/blender/makesrna/intern/rna_world.c @@ -403,17 +403,17 @@ void RNA_def_world(BlenderRNA *brna) /* nested structs */ prop= RNA_def_property(srna, "ambient_occlusion", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_struct_type(prop, "WorldAmbientOcclusion"); - RNA_def_property_pointer_funcs(prop, "rna_World_ambient_occlusion_get", NULL); + RNA_def_property_pointer_funcs(prop, "rna_World_ambient_occlusion_get", NULL, NULL); RNA_def_property_ui_text(prop, "Ambient Occlusion", "World ambient occlusion settings."); prop= RNA_def_property(srna, "mist", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_struct_type(prop, "WorldMistSettings"); - RNA_def_property_pointer_funcs(prop, "rna_World_mist_get", NULL); + RNA_def_property_pointer_funcs(prop, "rna_World_mist_get", NULL, NULL); RNA_def_property_ui_text(prop, "Mist", "World mist settings."); prop= RNA_def_property(srna, "stars", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_struct_type(prop, "WorldStarsSettings"); - RNA_def_property_pointer_funcs(prop, "rna_World_stars_get", NULL); + RNA_def_property_pointer_funcs(prop, "rna_World_stars_get", NULL, NULL); RNA_def_property_ui_text(prop, "Stars", "World stars settings."); prop= RNA_def_property(srna, "script_link", PROP_POINTER, PROP_NEVER_NULL); diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index d9a0d9408c7..983e69845bd 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -470,9 +470,9 @@ int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyObject *v } case PROP_POINTER: { - StructRNA *ptype= RNA_property_pointer_type(prop); + StructRNA *ptype= RNA_property_pointer_type(ptr, prop); - if(!BPy_StructRNA_Check(value)) { + if(!BPy_StructRNA_Check(value) && value != Py_None) { PointerRNA tmp; RNA_pointer_create(NULL, ptype, NULL, &tmp); PyErr_Format(PyExc_TypeError, "expected a %s type", RNA_struct_identifier(tmp.type)); @@ -482,19 +482,32 @@ int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyObject *v int raise_error= 0; if(data) { if(ptype == &RNA_AnyType) { - *((PointerRNA*)data)= param->ptr; + if(value == Py_None) + memset(data, 0, sizeof(PointerRNA)); + else + *((PointerRNA*)data)= param->ptr; + } + else if(value == Py_None) { + *((void**)data)= NULL; } else if(RNA_struct_is_a(param->ptr.type, ptype)) { *((void**)data)= param->ptr.data; - } else { + } + else { raise_error= 1; } } else { /* data==NULL, assign to RNA */ - if(RNA_struct_is_a(param->ptr.type, ptype)) { + if(value == Py_None) { + PointerRNA valueptr; + memset(&valueptr, 0, sizeof(valueptr)); + RNA_property_pointer_set(ptr, prop, valueptr); + } + else if(RNA_struct_is_a(param->ptr.type, ptype)) { RNA_property_pointer_set(ptr, prop, param->ptr); - } else { + } + else { PointerRNA tmp; RNA_pointer_create(NULL, ptype, NULL, &tmp); PyErr_Format(PyExc_TypeError, "expected a %s type", RNA_struct_identifier(tmp.type)); @@ -1162,7 +1175,7 @@ PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *data) case PROP_POINTER: { PointerRNA newptr; - StructRNA *type= RNA_property_pointer_type(prop); + StructRNA *type= RNA_property_pointer_type(ptr, prop); if(type == &RNA_AnyType) { /* in this case we get the full ptr */ |