Changeset View
Changeset View
Standalone View
Standalone View
source/blender/makesrna/intern/rna_curves.c
| Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | |||||
| # include "BLI_math_vector.h" | # include "BLI_math_vector.h" | ||||
| # include "BKE_attribute.h" | # include "BKE_attribute.h" | ||||
| # include "BKE_curves.h" | # include "BKE_curves.h" | ||||
| # include "DEG_depsgraph.h" | # include "DEG_depsgraph.h" | ||||
| # include "ED_curves.h" | |||||
| # include "WM_api.h" | # include "WM_api.h" | ||||
| # include "WM_types.h" | # include "WM_types.h" | ||||
| static Curves *rna_curves(const PointerRNA *ptr) | static Curves *rna_curves(const PointerRNA *ptr) | ||||
| { | { | ||||
| return (Curves *)ptr->owner_id; | return (Curves *)ptr->owner_id; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 151 Lines • ▼ Show 20 Lines | static void rna_CurveSlice_points_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) | ||||
| Curves *curves = rna_curves(ptr); | Curves *curves = rna_curves(ptr); | ||||
| const int offset = rna_CurveSlice_first_point_index_get(ptr); | const int offset = rna_CurveSlice_first_point_index_get(ptr); | ||||
| const int size = rna_CurveSlice_points_length_get(ptr); | const int size = rna_CurveSlice_points_length_get(ptr); | ||||
| float(*positions)[3] = get_curves_positions(curves); | float(*positions)[3] = get_curves_positions(curves); | ||||
| float(*co)[3] = positions + offset; | float(*co)[3] = positions + offset; | ||||
| rna_iterator_array_begin(iter, co, sizeof(float[3]), size, 0, NULL); | rna_iterator_array_begin(iter, co, sizeof(float[3]), size, 0, NULL); | ||||
| } | } | ||||
| static void rna_Curves_normals_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) | |||||
| { | |||||
| Curves *curves = rna_curves(ptr); | |||||
| float(*positions)[3] = ED_curves_point_normals_array_create(curves); | |||||
| const int size = curves->geometry.point_num; | |||||
| rna_iterator_array_begin(iter, positions, sizeof(float[3]), size, true, NULL); | |||||
| } | |||||
| static void rna_Curves_update_data(struct Main *UNUSED(bmain), | static void rna_Curves_update_data(struct Main *UNUSED(bmain), | ||||
| struct Scene *UNUSED(scene), | struct Scene *UNUSED(scene), | ||||
| PointerRNA *ptr) | PointerRNA *ptr) | ||||
| { | { | ||||
| ID *id = ptr->owner_id; | ID *id = ptr->owner_id; | ||||
| /* Avoid updates for importers creating curves. */ | /* Avoid updates for importers creating curves. */ | ||||
| if (id->us > 0) { | if (id->us > 0) { | ||||
| DEG_id_tag_update(id, 0); | DEG_id_tag_update(id, 0); | ||||
| Show All 35 Lines | static void rna_def_curves_point(BlenderRNA *brna) | ||||
| RNA_def_property_update(prop, 0, "rna_Curves_update_data"); | RNA_def_property_update(prop, 0, "rna_Curves_update_data"); | ||||
| prop = RNA_def_property(srna, "index", PROP_INT, PROP_UNSIGNED); | prop = RNA_def_property(srna, "index", PROP_INT, PROP_UNSIGNED); | ||||
| RNA_def_property_clear_flag(prop, PROP_EDITABLE); | RNA_def_property_clear_flag(prop, PROP_EDITABLE); | ||||
| RNA_def_property_int_funcs(prop, "rna_CurvePoint_index_get", NULL, NULL); | RNA_def_property_int_funcs(prop, "rna_CurvePoint_index_get", NULL, NULL); | ||||
| RNA_def_property_ui_text(prop, "Index", "Index of this points"); | RNA_def_property_ui_text(prop, "Index", "Index of this points"); | ||||
| } | } | ||||
| /* Defines a read-only vector type since normals can not be modified manually. */ | |||||
JacquesLucke: `should` -> `can` | |||||
| static void rna_def_read_only_float_vector(BlenderRNA *brna) | |||||
| { | |||||
| StructRNA *srna = RNA_def_struct(brna, "FloatVectorValueReadOnly", NULL); | |||||
| RNA_def_struct_sdna(srna, "vec3f"); | |||||
| RNA_def_struct_ui_text(srna, "Read-Only Vector", ""); | |||||
| PropertyRNA *prop = RNA_def_property(srna, "vector", PROP_FLOAT, PROP_DIRECTION); | |||||
| RNA_def_property_ui_text(prop, "Vector", "3D vector"); | |||||
| RNA_def_property_float_sdna(prop, NULL, "x"); | |||||
| RNA_def_property_array(prop, 3); | |||||
| RNA_def_property_clear_flag(prop, PROP_EDITABLE); | |||||
| } | |||||
| static void rna_def_curves_curve(BlenderRNA *brna) | static void rna_def_curves_curve(BlenderRNA *brna) | ||||
| { | { | ||||
| StructRNA *srna; | StructRNA *srna; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| srna = RNA_def_struct(brna, "CurveSlice", NULL); | srna = RNA_def_struct(brna, "CurveSlice", NULL); | ||||
| RNA_def_struct_ui_text(srna, "Curve Slice", "A single curve from a curves data-block"); | RNA_def_struct_ui_text(srna, "Curve Slice", "A single curve from a curves data-block"); | ||||
| RNA_def_struct_path_func(srna, "rna_CurveSlice_path"); | RNA_def_struct_path_func(srna, "rna_CurveSlice_path"); | ||||
| ▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | RNA_def_property_collection_funcs(prop, | ||||
| "rna_iterator_array_end", | "rna_iterator_array_end", | ||||
| "rna_iterator_array_get", | "rna_iterator_array_get", | ||||
| "rna_Curves_curve_offset_data_length", | "rna_Curves_curve_offset_data_length", | ||||
| NULL, | NULL, | ||||
| NULL, | NULL, | ||||
| NULL); | NULL); | ||||
| RNA_def_property_update(prop, 0, "rna_Curves_update_data"); | RNA_def_property_update(prop, 0, "rna_Curves_update_data"); | ||||
| rna_def_read_only_float_vector(brna); | |||||
| prop = RNA_def_property(srna, "normals", PROP_COLLECTION, PROP_NONE); | |||||
| RNA_def_property_struct_type(prop, "FloatVectorValueReadOnly"); | |||||
| /* `lookup_int` isn't provided since the entire normals array is allocated and calculated when | |||||
| * it's accessed. */ | |||||
weizhenUnsubmitted Not Done Inline ActionsDoes this mean that the elements can't be accessed via indices, but only iterator? weizhen: Does this mean that the elements can't be accessed via indices, but only iterator? | |||||
| RNA_def_property_collection_funcs(prop, | |||||
| "rna_Curves_normals_begin", | |||||
| "rna_iterator_array_next", | |||||
| "rna_iterator_array_end", | |||||
| "rna_iterator_array_get", | |||||
| "rna_Curves_position_data_length", | |||||
| NULL, | |||||
| NULL, | |||||
| NULL); | |||||
| RNA_def_property_ui_text( | |||||
| prop, "Normals", "The curve normal value at each of the curve's control points"); | |||||
| /* materials */ | /* materials */ | ||||
| prop = RNA_def_property(srna, "materials", PROP_COLLECTION, PROP_NONE); | prop = RNA_def_property(srna, "materials", PROP_COLLECTION, PROP_NONE); | ||||
| RNA_def_property_collection_sdna(prop, NULL, "mat", "totcol"); | RNA_def_property_collection_sdna(prop, NULL, "mat", "totcol"); | ||||
| RNA_def_property_struct_type(prop, "Material"); | RNA_def_property_struct_type(prop, "Material"); | ||||
| RNA_def_property_ui_text(prop, "Materials", ""); | RNA_def_property_ui_text(prop, "Materials", ""); | ||||
| RNA_def_property_srna(prop, "IDMaterials"); /* see rna_ID.c */ | RNA_def_property_srna(prop, "IDMaterials"); /* see rna_ID.c */ | ||||
| RNA_def_property_collection_funcs( | RNA_def_property_collection_funcs( | ||||
| prop, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "rna_IDMaterials_assign_int"); | prop, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "rna_IDMaterials_assign_int"); | ||||
| ▲ Show 20 Lines • Show All 53 Lines • Show Last 20 Lines | |||||
should -> can