diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-07-15 23:20:59 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-07-15 23:20:59 +0400 |
commit | d4504aa891c38333089da6bba50f66ca588cca1e (patch) | |
tree | cd98ee9da93dd78cc7a6c7dd1ec0ea956489d685 /source/blender/makesrna/intern | |
parent | 4df1836325bd2847f3c88eb6fafa98e7bafea81c (diff) |
2.5
* Some changes to make lamp and world textures editing work.
You may have to click on another texture slot once before
being able to add a texture, and the layout is messy. Added
this so lightenv project isn't blocked by this being missing.
* Adding a new material slot now doesn't create a new material
anymore, to avoid creating unused materials.
* Tiny changes to scene/object buttons.
Diffstat (limited to 'source/blender/makesrna/intern')
-rw-r--r-- | source/blender/makesrna/intern/rna_brush.c | 27 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_internal.h | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_lamp.c | 37 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_material.c | 34 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_world.c | 49 |
5 files changed, 129 insertions, 20 deletions
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index 3b7df3aa948..954c20e211c 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -34,6 +34,10 @@ #ifdef RNA_RUNTIME +#include "MEM_guardedalloc.h" + +#include "BKE_texture.h" + static void rna_Brush_mtex_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { Brush *brush= (Brush*)ptr->data; @@ -46,6 +50,27 @@ static PointerRNA rna_Brush_active_texture_get(PointerRNA *ptr) return rna_pointer_inherit_refine(ptr, &RNA_TextureSlot, brush->mtex[(int)brush->texact]); } +static void rna_Brush_active_texture_index_set(PointerRNA *ptr, int value) +{ + Brush *brush= (Brush*)ptr->data; + int act= brush->texact; + + if(value == act || value < 0 || value >= MAX_MTEX) + return; + + /* auto create/free mtex on activate/deactive, so we can edit + * the texture pointer in the buttons UI. */ + if(brush->mtex[act] && !brush->mtex[act]->tex) { + MEM_freeN(brush->mtex[act]); + brush->mtex[act]= NULL; + } + + brush->texact= value; + + if(!brush->mtex[value]) + brush->mtex[value]= add_mtex(); +} + static float rna_Brush_rotation_get(PointerRNA *ptr) { Brush *brush= (Brush*)ptr->data; @@ -198,7 +223,7 @@ void rna_def_brush(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Curve", "Editable falloff curve."); /* texture */ - rna_def_mtex_common(srna, "rna_Brush_mtex_begin", "rna_Brush_active_texture_get", "TextureSlot"); + rna_def_mtex_common(srna, "rna_Brush_mtex_begin", "rna_Brush_active_texture_get", "rna_Brush_active_texture_index_set", "TextureSlot"); /* clone tool */ prop= RNA_def_property(srna, "clone_image", PROP_POINTER, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index ad0e05b91a6..3e92c606e53 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -169,7 +169,7 @@ void RNA_def_world(struct BlenderRNA *brna); void rna_def_animdata_common(struct StructRNA *srna); void rna_def_texmat_common(struct StructRNA *srna, const char *texspace_editable); -void rna_def_mtex_common(struct StructRNA *srna, const char *begin, const char *activeget, const char *structname); +void rna_def_mtex_common(struct StructRNA *srna, const char *begin, const char *activeget, const char *activeset, const char *structname); void rna_ID_name_get(struct PointerRNA *ptr, char *value); int rna_ID_name_length(struct PointerRNA *ptr); diff --git a/source/blender/makesrna/intern/rna_lamp.c b/source/blender/makesrna/intern/rna_lamp.c index e592cb38693..61d4a3a8ac6 100644 --- a/source/blender/makesrna/intern/rna_lamp.c +++ b/source/blender/makesrna/intern/rna_lamp.c @@ -37,6 +37,10 @@ #ifdef RNA_RUNTIME +#include "MEM_guardedalloc.h" + +#include "BKE_texture.h" + static void rna_Lamp_buffer_size_set(PointerRNA *ptr, int value) { Lamp *la= (Lamp*)ptr->data; @@ -63,6 +67,29 @@ static PointerRNA rna_Lamp_active_texture_get(PointerRNA *ptr) return rna_pointer_inherit_refine(ptr, &RNA_TextureSlot, la->mtex[(int)la->texact]); } +static void rna_Lamp_active_texture_index_set(PointerRNA *ptr, int value) +{ + Lamp *la= (Lamp*)ptr->data; + int act= la->texact; + + if(value == act || value < 0 || value >= MAX_MTEX) + return; + + /* auto create/free mtex on activate/deactive, so we can edit + * the texture pointer in the buttons UI. */ + if(la->mtex[act] && !la->mtex[act]->tex) { + MEM_freeN(la->mtex[act]); + la->mtex[act]= NULL; + } + + la->texact= value; + + if(!la->mtex[value]) { + la->mtex[value]= add_mtex(); + la->mtex[value]->texco= TEXCO_GLOB; + } +} + static StructRNA* rna_Lamp_refine(struct PointerRNA *ptr) { Lamp *la= (Lamp*)ptr->data; @@ -111,13 +138,13 @@ static void rna_def_lamp_mtex(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Object", "Object to use for mapping with Object texture coordinates."); - prop= RNA_def_property(srna, "map_to_color", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "map_color", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mapto", LAMAP_COL); - RNA_def_property_ui_text(prop, "Map To Color", "Lets the texture affect the basic color of the lamp."); + RNA_def_property_ui_text(prop, "Color", "Lets the texture affect the basic color of the lamp."); - prop= RNA_def_property(srna, "map_to_shadow", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "map_shadow", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mapto", LAMAP_SHAD); - RNA_def_property_ui_text(prop, "Map To Shadow", "Lets the texture affect the shadow color of the lamp."); + RNA_def_property_ui_text(prop, "Shadow", "Lets the texture affect the shadow color of the lamp."); } static void rna_def_lamp_sky_settings(BlenderRNA *brna) @@ -308,7 +335,7 @@ static void rna_def_lamp(BlenderRNA *brna) RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING, NULL); /* textures */ - rna_def_mtex_common(srna, "rna_Lamp_mtex_begin", "rna_Lamp_active_texture_get", "LampTextureSlot"); + rna_def_mtex_common(srna, "rna_Lamp_mtex_begin", "rna_Lamp_active_texture_get", "rna_Lamp_active_texture_index_set", "LampTextureSlot"); /* script link */ prop= RNA_def_property(srna, "script_link", PROP_POINTER, PROP_NEVER_NULL); diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index b0164bda27c..c8ee0479f61 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -37,6 +37,10 @@ #ifdef RNA_RUNTIME +#include "MEM_guardedalloc.h" + +#include "BKE_texture.h" + static PointerRNA rna_Material_mirror_get(PointerRNA *ptr) { return rna_pointer_inherit_refine(ptr, &RNA_MaterialRaytraceMirror, ptr->id.data); @@ -84,6 +88,27 @@ static PointerRNA rna_Material_active_texture_get(PointerRNA *ptr) return rna_pointer_inherit_refine(ptr, &RNA_TextureSlot, ma->mtex[(int)ma->texact]); } +static void rna_Material_active_texture_index_set(PointerRNA *ptr, int value) +{ + Material *ma= (Material*)ptr->data; + int act= ma->texact; + + if(value == act || value < 0 || value >= MAX_MTEX) + return; + + /* auto create/free mtex on activate/deactive, so we can edit + * the texture pointer in the buttons UI. */ + if(ma->mtex[act] && !ma->mtex[act]->tex) { + MEM_freeN(ma->mtex[act]); + ma->mtex[act]= NULL; + } + + ma->texact= value; + + if(!ma->mtex[value]) + ma->mtex[value]= add_mtex(); +} + static void rna_MaterialStrand_start_size_range(PointerRNA *ptr, float *min, float *max) { Material *ma= (Material*)ptr->id.data; @@ -221,6 +246,10 @@ static void rna_def_material_mtex(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "texflag", MTEX_DUPLI_MAPTO); RNA_def_property_ui_text(prop, "From Dupli", "Dupli's instanced from verts, faces or particles, inherit texture coordinate from their parent (only for UV and Orco texture coordinates)."); + prop= RNA_def_property(srna, "from_original", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "texflag", MTEX_OB_DUPLI_ORIG); + RNA_def_property_ui_text(prop, "From Original", "Dupli's derive their object coordinates from the original objects transformation."); + prop= RNA_def_property(srna, "map_color", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_COL); RNA_def_property_ui_text(prop, "Color", "Causes the texture to affect basic color of the material"); @@ -1116,7 +1145,7 @@ void RNA_def_material(BlenderRNA *brna) /* common */ rna_def_animdata_common(srna); - rna_def_mtex_common(srna, "rna_Material_mtex_begin", "rna_Material_active_texture_get", "MaterialTextureSlot"); + rna_def_mtex_common(srna, "rna_Material_mtex_begin", "rna_Material_active_texture_get", "rna_Material_active_texture_index_set", "MaterialTextureSlot"); prop= RNA_def_property(srna, "script_link", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_pointer_sdna(prop, NULL, "scriptlink"); @@ -1136,7 +1165,7 @@ void RNA_def_material(BlenderRNA *brna) rna_def_material_strand(brna); } -void rna_def_mtex_common(StructRNA *srna, const char *begin, const char *activeget, const char *structname) +void rna_def_mtex_common(StructRNA *srna, const char *begin, const char *activeget, const char *activeset, const char *structname) { PropertyRNA *prop; @@ -1154,6 +1183,7 @@ void rna_def_mtex_common(StructRNA *srna, const char *begin, const char *activeg prop= RNA_def_property(srna, "active_texture_index", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "texact"); + RNA_def_property_int_funcs(prop, NULL, activeset, NULL); RNA_def_property_range(prop, 0, MAX_MTEX-1); RNA_def_property_ui_text(prop, "Active Texture Index", "Index of active texture slot."); } diff --git a/source/blender/makesrna/intern/rna_world.c b/source/blender/makesrna/intern/rna_world.c index 9ff474b82b0..c93d18d4017 100644 --- a/source/blender/makesrna/intern/rna_world.c +++ b/source/blender/makesrna/intern/rna_world.c @@ -38,6 +38,10 @@ #ifdef RNA_RUNTIME +#include "MEM_guardedalloc.h" + +#include "BKE_texture.h" + static PointerRNA rna_World_ambient_occlusion_get(PointerRNA *ptr) { return rna_pointer_inherit_refine(ptr, &RNA_WorldAmbientOcclusion, ptr->id.data); @@ -66,6 +70,29 @@ static PointerRNA rna_World_active_texture_get(PointerRNA *ptr) return rna_pointer_inherit_refine(ptr, &RNA_TextureSlot, wo->mtex[(int)wo->texact]); } +static void rna_World_active_texture_index_set(PointerRNA *ptr, int value) +{ + World *wo= (World*)ptr->data; + int act= wo->texact; + + if(value == act || value < 0 || value >= MAX_MTEX) + return; + + /* auto create/free mtex on activate/deactive, so we can edit + * the texture pointer in the buttons UI. */ + if(wo->mtex[act] && !wo->mtex[act]->tex) { + MEM_freeN(wo->mtex[act]); + wo->mtex[act]= NULL; + } + + wo->texact= value; + + if(!wo->mtex[value]) { + wo->mtex[value]= add_mtex(); + wo->mtex[value]->texco= TEXCO_VIEW; + } +} + #else static void rna_def_world_mtex(BlenderRNA *brna) @@ -87,26 +114,26 @@ static void rna_def_world_mtex(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "World Texture Slot", "Texture slot for textures in a World datablock."); /* map to */ - prop= RNA_def_property(srna, "map_to_blend", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "map_blend", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mapto", WOMAP_BLEND); - RNA_def_property_ui_text(prop, "Map To Blend", "Affect the color progression of the background."); + RNA_def_property_ui_text(prop, "Blend", "Affect the color progression of the background."); - prop= RNA_def_property(srna, "map_to_horizon", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "map_horizon", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mapto", WOMAP_HORIZ); - RNA_def_property_ui_text(prop, "Map To Horizon", "Affect the color of the horizon."); + RNA_def_property_ui_text(prop, "Horizon", "Affect the color of the horizon."); - prop= RNA_def_property(srna, "map_to_zenith_up", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "map_zenith_up", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mapto", WOMAP_ZENUP); - RNA_def_property_ui_text(prop, "Map To Zenith Up", "Affect the color of the zenith above."); + RNA_def_property_ui_text(prop, "Zenith Up", "Affect the color of the zenith above."); - prop= RNA_def_property(srna, "map_to_zenith_down", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "map_zenith_down", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mapto", WOMAP_ZENDOWN); - RNA_def_property_ui_text(prop, "Map To Zenith Down", "Affect the color of the zenith below."); + RNA_def_property_ui_text(prop, "Zenith Down", "Affect the color of the zenith below."); /* unused - prop= RNA_def_property(srna, "map_to_mist", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "map_mist", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mapto", WOMAP_MIST); - RNA_def_property_ui_text(prop, "Map To Mist", "Causes the texture to affect the intensity of the mist.");*/ + RNA_def_property_ui_text(prop, "Mist", "Causes the texture to affect the intensity of the mist.");*/ prop= RNA_def_property(srna, "texture_coordinates", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "texco"); @@ -348,7 +375,7 @@ void RNA_def_world(BlenderRNA *brna) RNA_def_struct_ui_icon(srna, ICON_WORLD_DATA); rna_def_animdata_common(srna); - rna_def_mtex_common(srna, "rna_World_mtex_begin", "rna_World_active_texture_get", "WorldTextureSlot"); + rna_def_mtex_common(srna, "rna_World_mtex_begin", "rna_World_active_texture_get", "rna_World_active_texture_index_set", "WorldTextureSlot"); /* colors */ prop= RNA_def_property(srna, "horizon_color", PROP_FLOAT, PROP_COLOR); |