Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2010-09-03 18:53:54 +0400
committerCampbell Barton <ideasman42@gmail.com>2010-09-03 18:53:54 +0400
commit0cf0f5a62225f9f9cc2ed9715274e94dc09ad8b0 (patch)
treef89e9ebe84dc32179532ab8fc269c46b8b6e8b8a /source/blender
parent52cefa4bc1104231cf6c6ef5b12124df135e2914 (diff)
rna api
- move: material.add_texture(tex, coords, mapto) --> material.texture_slots.add() - added material.texture_slots.create(index), material.texture_slots.clear(index) - texture slot functions also work for lamp and world now. Other minor changes - allow rna functions to set FUNC_NO_SELF and FUNC_USE_SELF_ID at once. - [#23317] Changed some operators' RNA to accept lengths, a modification I made to this patch made it not work as intended, removed this edit so unit buttons appier in the UI for certain operators. - Sphinx doc gen, 2 columns rather then 3, didnt quite fit in some cases.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/BKE_texture.h1
-rw-r--r--source/blender/blenkernel/intern/texture.c43
-rw-r--r--source/blender/makesrna/intern/makesrna.c33
-rw-r--r--source/blender/makesrna/intern/rna_define.c2
-rw-r--r--source/blender/makesrna/intern/rna_internal.h6
-rw-r--r--source/blender/makesrna/intern/rna_lamp.c4
-rw-r--r--source/blender/makesrna/intern/rna_material.c93
-rw-r--r--source/blender/makesrna/intern/rna_material_api.c85
-rw-r--r--source/blender/makesrna/intern/rna_world.c4
-rw-r--r--source/blender/python/doc/sphinx_doc_gen.py8
10 files changed, 170 insertions, 109 deletions
diff --git a/source/blender/blenkernel/BKE_texture.h b/source/blender/blenkernel/BKE_texture.h
index 380672dae04..99bb8db44ed 100644
--- a/source/blender/blenkernel/BKE_texture.h
+++ b/source/blender/blenkernel/BKE_texture.h
@@ -70,6 +70,7 @@ struct Tex *add_texture(const char *name);
void tex_set_type(struct Tex *tex, int type);
void default_mtex(struct MTex *mtex);
struct MTex *add_mtex(void);
+struct MTex *add_mtex_id(struct ID *id, int slot);
struct Tex *copy_texture(struct Tex *tex);
void make_local_texture(struct Tex *tex);
void autotexname(struct Tex *tex);
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index 9075c64d286..77416f4dd12 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -689,6 +689,49 @@ MTex *add_mtex()
return mtex;
}
+/* slot -1 for first free ID */
+MTex *add_mtex_id(ID *id, int slot)
+{
+ MTex **mtex_ar;
+ short act;
+
+ give_active_mtex(id, &mtex_ar, &act);
+
+ if(mtex_ar==NULL) {
+ return NULL;
+ }
+
+ if(slot==-1) {
+ /* find first free */
+ int i;
+ for (i= 0; i < MAX_MTEX; i++) {
+ if (!mtex_ar[i]) {
+ slot= i;
+ break;
+ }
+ }
+ if(slot == -1) {
+ return NULL;
+ }
+ }
+ else {
+ /* make sure slot is valid */
+ if(slot < 0 || slot >= MAX_MTEX) {
+ return NULL;
+ }
+ }
+
+ if (mtex_ar[slot]) {
+ id_us_min((ID *)mtex_ar[slot]->tex);
+ MEM_freeN(mtex_ar[slot]);
+ mtex_ar[slot]= NULL;
+ }
+
+ mtex_ar[slot]= add_mtex();
+
+ return mtex_ar[slot];
+}
+
/* ------------------------------------------------------------------------- */
Tex *copy_texture(Tex *tex)
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
index 9ebf625946c..8a68c460573 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -1413,10 +1413,12 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA
fprintf(f, "\n{\n");
/* variable definitions */
- if((func->flag & FUNC_NO_SELF)==0) {
- if(func->flag & FUNC_USE_SELF_ID)
- fprintf(f, "\tstruct ID *_selfid;\n");
+
+ if(func->flag & FUNC_USE_SELF_ID) {
+ fprintf(f, "\tstruct ID *_selfid;\n");
+ }
+ if((func->flag & FUNC_NO_SELF)==0) {
if(dsrna->dnaname) fprintf(f, "\tstruct %s *_self;\n", dsrna->dnaname);
else fprintf(f, "\tstruct %s *_self;\n", srna->identifier);
}
@@ -1455,10 +1457,11 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA
fprintf(f, "\t\n");
/* assign self */
+ if(func->flag & FUNC_USE_SELF_ID) {
+ fprintf(f, "\t_selfid= (struct ID*)_ptr->id.data;\n");
+ }
+
if((func->flag & FUNC_NO_SELF)==0) {
- if(func->flag & FUNC_USE_SELF_ID)
- fprintf(f, "\t_selfid= (struct ID*)_ptr->id.data;\n");
-
if(dsrna->dnaname) fprintf(f, "\t_self= (struct %s *)_ptr->data;\n", dsrna->dnaname);
else fprintf(f, "\t_self= (struct %s *)_ptr->data;\n", srna->identifier);
}
@@ -1521,10 +1524,13 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA
first= 1;
- if((func->flag & FUNC_NO_SELF)==0) {
- if(func->flag & FUNC_USE_SELF_ID)
- fprintf(f, "_selfid, ");
+ if(func->flag & FUNC_USE_SELF_ID) {
+ fprintf(f, "_selfid");
+ first= 0;
+ }
+ if((func->flag & FUNC_NO_SELF)==0) {
+ if(!first) fprintf(f, ", ");
fprintf(f, "_self");
first= 0;
}
@@ -1826,10 +1832,13 @@ static void rna_generate_static_parameter_prototypes(BlenderRNA *brna, StructRNA
first= 1;
/* self, context and reports parameters */
+ if(func->flag & FUNC_USE_SELF_ID) {
+ fprintf(f, "struct ID *_selfid");
+ first= 0;
+ }
+
if((func->flag & FUNC_NO_SELF)==0) {
- if(func->flag & FUNC_USE_SELF_ID)
- fprintf(f, "struct ID *_selfid, ");
-
+ if(!first) fprintf(f, ", ");
if(dsrna->dnaname) fprintf(f, "struct %s *_self", dsrna->dnaname);
else fprintf(f, "struct %s *_self", srna->identifier);
first= 0;
diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c
index a1c17ff02c9..750b1eef2a9 100644
--- a/source/blender/makesrna/intern/rna_define.c
+++ b/source/blender/makesrna/intern/rna_define.c
@@ -2207,7 +2207,7 @@ PropertyRNA *RNA_def_float_vector_xyz(StructOrFunctionRNA *cont_, const char *id
PropertyRNA *prop;
prop= RNA_def_float_vector(cont_, identifier, len, default_value, hardmin, hardmax, ui_name, ui_description, softmin, softmax);
- prop->subtype = PROP_XYZ;
+ prop->subtype = PROP_XYZ_LENGTH;
return prop;
}
diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h
index 669fc5d3871..401f9de92d4 100644
--- a/source/blender/makesrna/intern/rna_internal.h
+++ b/source/blender/makesrna/intern/rna_internal.h
@@ -182,7 +182,7 @@ void rna_def_animviz_common(struct StructRNA *srna);
void rna_def_motionpath_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 *activeset, const char *structname, const char *update);
+void rna_def_mtex_common(struct BlenderRNA *brna, struct StructRNA *srna, const char *begin, const char *activeget, const char *activeset, const char *structname, const char *structname_slots, const char *update);
void rna_def_render_layer_common(struct StructRNA *srna, int scene);
void rna_ID_name_get(struct PointerRNA *ptr, char *value);
@@ -352,6 +352,10 @@ PointerRNA rna_pointer_inherit_refine(struct PointerRNA *ptr, struct StructRNA *
int rna_parameter_size(struct PropertyRNA *parm);
int rna_parameter_size_alloc(struct PropertyRNA *parm);
+// XXX, these should not need to be defined here~!
+struct MTex *rna_mtex_texture_slots_add(struct ID *self, struct ReportList *reports);
+struct MTex *rna_mtex_texture_slots_create(struct ID *self, struct ReportList *reports, int index);
+void rna_mtex_texture_slots_clear(struct ID *self, struct ReportList *reports, int index);
#endif /* RNA_INTERNAL_H */
diff --git a/source/blender/makesrna/intern/rna_lamp.c b/source/blender/makesrna/intern/rna_lamp.c
index c6660450914..fb7bb4a9194 100644
--- a/source/blender/makesrna/intern/rna_lamp.c
+++ b/source/blender/makesrna/intern/rna_lamp.c
@@ -386,8 +386,8 @@ static void rna_def_lamp(BlenderRNA *brna)
rna_def_animdata_common(srna);
/* textures */
- rna_def_mtex_common(srna, "rna_Lamp_mtex_begin", "rna_Lamp_active_texture_get",
- "rna_Lamp_active_texture_set", "LampTextureSlot", "rna_Lamp_update");
+ rna_def_mtex_common(brna, srna, "rna_Lamp_mtex_begin", "rna_Lamp_active_texture_get",
+ "rna_Lamp_active_texture_set", "LampTextureSlot", "LampTextureSlots", "rna_Lamp_update");
}
static void rna_def_lamp_falloff(StructRNA *srna)
diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c
index f2ef6a0f3e1..f564c52933b 100644
--- a/source/blender/makesrna/intern/rna_material.c
+++ b/source/blender/makesrna/intern/rna_material.c
@@ -276,6 +276,54 @@ static EnumPropertyItem *rna_Material_texture_coordinates_itemf(bContext *C, Poi
return item;
}
+MTex *rna_mtex_texture_slots_add(ID *self_id, ReportList *reports)
+{
+ MTex *mtex= add_mtex_id(self_id, -1);
+ if (mtex == NULL) {
+ BKE_reportf(reports, RPT_ERROR, "maximum number of textures added %d", MAX_MTEX);
+ return NULL;
+ }
+
+ return mtex;
+}
+
+MTex *rna_mtex_texture_slots_create(ID *self_id, ReportList *reports, int index)
+{
+ MTex *mtex;
+
+ if(index < 0 || index >= MAX_MTEX) {
+ BKE_reportf(reports, RPT_ERROR, "index %d is invalid", index);
+ return NULL;
+ }
+
+ mtex= add_mtex_id(self_id, index);
+
+ return mtex;
+}
+
+void rna_mtex_texture_slots_clear(ID *self_id, ReportList *reports, int index)
+{
+ MTex **mtex_ar;
+ short act;
+
+ give_active_mtex(self_id, &mtex_ar, &act);
+
+ if (mtex_ar == NULL) {
+ BKE_report(reports, RPT_ERROR, "mtex not found for this type");
+ return;
+ }
+
+ if(index < 0 || index >= MAX_MTEX) {
+ BKE_reportf(reports, RPT_ERROR, "index %d is invalid", index);
+ return;
+ }
+
+ if(mtex_ar[index]) {
+ id_us_min((ID *)mtex_ar[index]->tex);
+ MEM_freeN(mtex_ar[index]);
+ mtex_ar[index]= NULL;
+ }
+}
#else
@@ -1741,9 +1789,9 @@ 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",
- "rna_Material_active_texture_set", "MaterialTextureSlot", "rna_Material_update");
-
+ rna_def_mtex_common(brna, srna, "rna_Material_mtex_begin", "rna_Material_active_texture_get",
+ "rna_Material_active_texture_set", "MaterialTextureSlot", "MaterialTextureSlots", "rna_Material_update");
+
/* only material has this one */
prop= RNA_def_property(srna, "use_textures", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "septex", 1);
@@ -1768,7 +1816,43 @@ void RNA_def_material(BlenderRNA *brna)
RNA_api_material(srna);
}
-void rna_def_mtex_common(StructRNA *srna, const char *begin, const char *activeget, const char *activeset, const char *structname, const char *update)
+
+/* curve.splines */
+static void rna_def_texture_slots(BlenderRNA *brna, PropertyRNA *cprop, const char *structname, const char *structname_slots)
+{
+ StructRNA *srna;
+
+ FunctionRNA *func;
+ PropertyRNA *parm;
+
+ RNA_def_property_srna(cprop, structname_slots);
+ srna= RNA_def_struct(brna, structname_slots, NULL);
+ RNA_def_struct_sdna(srna, "ID");
+ RNA_def_struct_ui_text(srna, "Texture Slots", "Collection of texture slots");
+
+ /* functions */
+ func= RNA_def_function(srna, "add", "rna_mtex_texture_slots_add");
+ RNA_def_function_ui_description(func, "Add a number of points to this spline.");
+ RNA_def_function_flag(func, FUNC_USE_SELF_ID|FUNC_NO_SELF|FUNC_USE_REPORTS);
+ parm= RNA_def_pointer(func, "mtex", structname, "", "The newly initialized mtex.");
+ RNA_def_function_return(func, parm);
+
+ func= RNA_def_function(srna, "create", "rna_mtex_texture_slots_create");
+ RNA_def_function_ui_description(func, "Add a number of points to this spline.");
+ RNA_def_function_flag(func, FUNC_USE_SELF_ID|FUNC_NO_SELF|FUNC_USE_REPORTS);
+ parm= RNA_def_int(func, "index", 0, 0, INT_MAX, "Index", "Slot index to initialize.", 0, INT_MAX);
+ RNA_def_property_flag(parm, PROP_REQUIRED);
+ parm= RNA_def_pointer(func, "mtex", structname, "", "The newly initialized mtex.");
+ RNA_def_function_return(func, parm);
+
+ func= RNA_def_function(srna, "clear", "rna_mtex_texture_slots_clear");
+ RNA_def_function_ui_description(func, "Add a number of points to this spline.");
+ RNA_def_function_flag(func, FUNC_USE_SELF_ID|FUNC_NO_SELF|FUNC_USE_REPORTS);
+ parm= RNA_def_int(func, "index", 0, 0, INT_MAX, "Index", "Slot index to clar.", 0, INT_MAX);
+ RNA_def_property_flag(parm, PROP_REQUIRED);
+}
+
+void rna_def_mtex_common(BlenderRNA *brna, StructRNA *srna, const char *begin, const char *activeget, const char *activeset, const char *structname, const char *structname_slots, const char *update)
{
PropertyRNA *prop;
@@ -1777,6 +1861,7 @@ void rna_def_mtex_common(StructRNA *srna, const char *begin, const char *activeg
RNA_def_property_struct_type(prop, structname);
RNA_def_property_collection_funcs(prop, begin, "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_dereference_get", 0, 0, 0);
RNA_def_property_ui_text(prop, "Textures", "Texture slots defining the mapping and influence of textures");
+ rna_def_texture_slots(brna, prop, structname, structname_slots);
prop= RNA_def_property(srna, "active_texture", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "Texture");
diff --git a/source/blender/makesrna/intern/rna_material_api.c b/source/blender/makesrna/intern/rna_material_api.c
index d271b3b374c..22eb537f24a 100644
--- a/source/blender/makesrna/intern/rna_material_api.c
+++ b/source/blender/makesrna/intern/rna_material_api.c
@@ -35,93 +35,12 @@
#ifdef RNA_RUNTIME
-#include "BKE_material.h"
-#include "BKE_texture.h"
-
-/*
- Adds material to the first free texture slot.
- If all slots are busy, replaces the first.
-*/
-static void rna_Material_add_texture(Material *ma, Tex *tex, int texco, int mapto)
-{
- int i;
- MTex *mtex;
- int slot= -1;
-
- for (i= 0; i < MAX_MTEX; i++) {
- if (!ma->mtex[i]) {
- slot= i;
- break;
- }
- }
-
- if (slot == -1)
- slot= 0;
-
- if (ma->mtex[slot]) {
- ma->mtex[slot]->tex->id.us--;
- }
- else {
- ma->mtex[slot]= add_mtex();
- }
-
- mtex= ma->mtex[slot];
-
- mtex->tex= tex;
- if (tex)
- id_us_plus(&tex->id);
-
- mtex->texco= texco;
- mtex->mapto= mapto;
-}
-
#else
void RNA_api_material(StructRNA *srna)
{
- FunctionRNA *func;
- PropertyRNA *parm;
-
- /* copied from rna_def_material_mtex (rna_material.c) */
- static EnumPropertyItem prop_texture_coordinates_items[] = {
- {TEXCO_GLOB, "GLOBAL", 0, "Global", "Uses global coordinates for the texture coordinates"},
- {TEXCO_OBJECT, "OBJECT", 0, "Object", "Uses linked object's coordinates for texture coordinates"},
- {TEXCO_UV, "UV", 0, "UV", "Uses UV coordinates for texture coordinates"},
- {TEXCO_ORCO, "ORCO", 0, "Generated", "Uses the original undeformed coordinates of the object"},
- {TEXCO_STRAND, "STRAND", 0, "Strand", "Uses normalized strand texture coordinate (1D)"},
- {TEXCO_STICKY, "STICKY", 0, "Sticky", "Uses mesh's sticky coordinates for the texture coordinates"},
- {TEXCO_WINDOW, "WINDOW", 0, "Window", "Uses screen coordinates as texture coordinates"},
- {TEXCO_NORM, "NORMAL", 0, "Normal", "Uses normal vector as texture coordinates"},
- {TEXCO_REFL, "REFLECTION", 0, "Reflection", "Uses reflection vector as texture coordinates"},
- {TEXCO_STRESS, "STRESS", 0, "Stress", "Uses the difference of edge lengths compared to original coordinates of the mesh"},
- {TEXCO_TANGENT, "TANGENT", 0, "Tangent", "Uses the optional tangent vector as texture coordinates"},
-
- {0, NULL, 0, NULL, NULL}};
-
- static EnumPropertyItem prop_texture_mapto_items[] = {
- {MAP_COL, "COLOR", 0, "Color", "Causes the texture to affect basic color of the material"},
- {MAP_NORM, "NORMAL", 0, "Normal", "Causes the texture to affect the rendered normal"},
- {MAP_COLSPEC, "SPECULAR_COLOR", 0, "Specularity Color", "Causes the texture to affect the specularity color"},
- {MAP_COLMIR, "MIRROR", 0, "Mirror", "Causes the texture to affect the mirror color"},
- {MAP_REF, "REFLECTION", 0, "Reflection", "Causes the texture to affect the value of the materials reflectivity"},
- {MAP_SPEC, "SPECULARITY", 0, "Specularity", "Causes the texture to affect the value of specularity"},
- {MAP_EMIT, "EMIT", 0, "Emit", "Causes the texture to affect the emit value"},
- {MAP_ALPHA, "ALPHA", 0, "Alpha", "Causes the texture to affect the alpha value"},
- {MAP_HAR, "HARDNESS", 0, "Hardness", "Causes the texture to affect the hardness value"},
- {MAP_RAYMIRR, "RAY_MIRROR", 0, "Ray-Mirror", "Causes the texture to affect the ray-mirror value"},
- {MAP_TRANSLU, "TRANSLUCENCY", 0, "Translucency", "Causes the texture to affect the translucency value"},
- {MAP_AMB, "AMBIENT", 0, "Ambient", "Causes the texture to affect the value of ambient"},
- {MAP_DISPLACE, "DISPLACEMENT", 0, "Displacement", "Let the texture displace the surface"},
- {MAP_WARP, "WARP", 0, "Warp", "Let the texture warp texture coordinates of next channels"},
- {0, NULL, 0, NULL, NULL}};
-
- func= RNA_def_function(srna, "add_texture", "rna_Material_add_texture");
- RNA_def_function_ui_description(func, "Add a texture to material's free texture slot.");
- parm= RNA_def_pointer(func, "texture", "Texture", "Texture", "Texture to add.");
- RNA_def_property_flag(parm, PROP_REQUIRED);
- parm= RNA_def_enum(func, "texture_coords", prop_texture_coordinates_items, TEXCO_UV, "", "Source of texture coordinate information."); /* optional */
- parm= RNA_def_enum(func, "map_to", prop_texture_mapto_items, MAP_COL, "", "Controls which material property the texture affects."); /* optional */
- RNA_def_property_flag(parm, PROP_ENUM_FLAG);
+ // FunctionRNA *func;
+ // PropertyRNA *parm;
}
#endif
diff --git a/source/blender/makesrna/intern/rna_world.c b/source/blender/makesrna/intern/rna_world.c
index 907042e7453..ecf253acbce 100644
--- a/source/blender/makesrna/intern/rna_world.c
+++ b/source/blender/makesrna/intern/rna_world.c
@@ -469,8 +469,8 @@ 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",
- "rna_World_active_texture_set", "WorldTextureSlot", "rna_World_update");
+ rna_def_mtex_common(brna, srna, "rna_World_mtex_begin", "rna_World_active_texture_get",
+ "rna_World_active_texture_set", "WorldTextureSlot", "WorldTextureSlots", "rna_World_update");
/* colors */
prop= RNA_def_property(srna, "horizon_color", PROP_FLOAT, PROP_COLOR);
diff --git a/source/blender/python/doc/sphinx_doc_gen.py b/source/blender/python/doc/sphinx_doc_gen.py
index 5d70e62dde8..789a39e2328 100644
--- a/source/blender/python/doc/sphinx_doc_gen.py
+++ b/source/blender/python/doc/sphinx_doc_gen.py
@@ -443,7 +443,7 @@ def rna2sphinx(BASEPATH):
fw("\n")
fw(" Access to blenders internal data\n")
fw("\n")
- fw(" :type: :class:`bpy.types.Main`\n")
+ fw(" :type: :class:`bpy.types.BlendData`\n")
file.close()
EXAMPLE_SET_USED.add("bpy.data")
@@ -655,7 +655,7 @@ def rna2sphinx(BASEPATH):
fw(".. rubric:: Inherited Properties\n\n")
fw(".. hlist::\n")
- fw(" :columns: 3\n\n")
+ fw(" :columns: 2\n\n")
for line in lines:
fw(line)
@@ -680,7 +680,7 @@ def rna2sphinx(BASEPATH):
fw(".. rubric:: Inherited Functions\n\n")
fw(".. hlist::\n")
- fw(" :columns: 3\n\n")
+ fw(" :columns: 2\n\n")
for line in lines:
fw(line)
@@ -694,7 +694,7 @@ def rna2sphinx(BASEPATH):
fw(".. rubric:: References\n\n")
fw(".. hlist::\n")
- fw(" :columns: 3\n\n")
+ fw(" :columns: 2\n\n")
for ref in struct.references:
ref_split = ref.split(".")