From 9f06ed1b367fed6cea55d829ea62ff613b902c87 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Fri, 12 Dec 2008 23:30:23 +0000 Subject: RNA: start of wrapping for Constraints Still need to find out how to get the variable struct-type for constraint->data to work correctly. Any ideas brecht? --- source/blender/makesrna/RNA_access.h | 2 + source/blender/makesrna/intern/makesrna.c | 1 + source/blender/makesrna/intern/rna_constraint.c | 137 ++++++++++++++++++++++++ source/blender/makesrna/intern/rna_internal.h | 1 + source/blender/makesrna/intern/rna_object.c | 6 +- 5 files changed, 146 insertions(+), 1 deletion(-) create mode 100644 source/blender/makesrna/intern/rna_constraint.c diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index efe458837fd..020f01197ab 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -47,6 +47,8 @@ extern StructRNA RNA_Camera; extern StructRNA RNA_CharInfo; extern StructRNA RNA_CollectionProperty; extern StructRNA RNA_CollisionSensor; +extern StructRNA RNA_Constraint; +// ... constraint types... extern StructRNA RNA_Controller; extern StructRNA RNA_Curve; extern StructRNA RNA_CurveMap; diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index c3b01cb50d9..37af9abc08b 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -898,6 +898,7 @@ RNAProcessItem PROCESS_ITEMS[]= { {"rna_brush.c", RNA_def_brush}, {"rna_camera.c", RNA_def_camera}, {"rna_color.c", RNA_def_color}, + {"rna_constraint.c", RNA_def_constraint}, {"rna_controller.c", RNA_def_controller}, {"rna_curve.c", RNA_def_curve}, {"rna_group.c", RNA_def_group}, diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c new file mode 100644 index 00000000000..5e1f2ed53e3 --- /dev/null +++ b/source/blender/makesrna/intern/rna_constraint.c @@ -0,0 +1,137 @@ +/** + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * Contributor(s): Blender Foundation (2008), Juho Vepsäläinen + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include + +#include "RNA_define.h" +#include "RNA_types.h" + +#include "rna_internal.h" + +#include "DNA_constraint_types.h" + +#ifdef RNA_RUNTIME + +#else + +/* base struct for constraints */ +void rna_def_constraint_basedata(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + static EnumPropertyItem type_items[] ={ + {CONSTRAINT_TYPE_NULL, "NULL", "Null", ""}, + {CONSTRAINT_TYPE_CHILDOF, "CHILDOF", "Child Of", ""}, + {CONSTRAINT_TYPE_TRACKTO, "TRACKTO", "Track To", ""}, + {CONSTRAINT_TYPE_KINEMATIC, "IK", "IK", ""}, + {CONSTRAINT_TYPE_FOLLOWPATH, "FOLLOWPATH", "Follow Path", ""}, + {CONSTRAINT_TYPE_ROTLIMIT, "LIMITROT", "Limit Rotation", ""}, + {CONSTRAINT_TYPE_LOCLIMIT, "LIMITLOC", "Limit Location", ""}, + {CONSTRAINT_TYPE_SIZELIMIT, "LIMITSCALE", "Limit Scale", ""}, + {CONSTRAINT_TYPE_ROTLIKE, "COPYROT", "Copy Rotation", ""}, + {CONSTRAINT_TYPE_LOCLIKE, "COPYLOC", "Copy Location", ""}, + {CONSTRAINT_TYPE_SIZELIKE, "COPYSCALE", "Copy Scale", ""}, + {CONSTRAINT_TYPE_PYTHON, "SCRIPT", "Script", ""}, + {CONSTRAINT_TYPE_ACTION, "ACTION", "Action", ""}, + {CONSTRAINT_TYPE_LOCKTRACK, "LOCKTRACK", "Locked Track", ""}, + {CONSTRAINT_TYPE_DISTLIMIT, "LIMITDIST", "Limit Distance", ""}, + {CONSTRAINT_TYPE_STRETCHTO, "STRETCHTO", "Stretch To", ""}, + {CONSTRAINT_TYPE_MINMAX, "FLOOR", "Floor", ""}, + {CONSTRAINT_TYPE_RIGIDBODYJOINT, "RIGIDBODYJOINT", "Rigid Body Joint", ""}, + {CONSTRAINT_TYPE_CLAMPTO, "CLAMPTO", "Clamp To", ""}, + {CONSTRAINT_TYPE_TRANSFORM, "TRANSFORM", "Transformation", ""}, + {0, NULL, NULL, NULL}}; + static EnumPropertyItem space_items[] ={ + {CONSTRAINT_SPACE_WORLD, "WORLD", "World Space", "World/Global space."}, + {CONSTRAINT_SPACE_LOCAL, "LOCAL", "Local", "For objects (relative to parent/without parent influence). | For bones (along normals of bone, without parent/restpositions)."}, + {CONSTRAINT_SPACE_POSE, "POSE", "Pose", "Pose/Armature space (only for Pose Channels)."}, + {CONSTRAINT_SPACE_PARLOCAL, "PARLOCAL", "Local With Parent", "'Local' space with Parent transform taken into account (only for Pose Channels)."}, + {0, NULL, NULL, NULL}}; + + /* data */ + srna= RNA_def_struct(brna, "Constraint", NULL , "Constraint"); + RNA_def_struct_sdna(srna, "bConstraint"); + + /* strings */ + prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); + RNA_def_property_ui_text(prop, "Name", ""); + RNA_def_struct_name_property(srna, prop); + + /* enums */ + prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); + RNA_def_property_flag(prop, PROP_NOT_EDITABLE); + RNA_def_property_enum_sdna(prop, NULL, "type"); + RNA_def_property_enum_items(prop, type_items); + RNA_def_property_ui_text(prop, "Type", ""); + + /* flags */ + // XXX do we want to wrap this? + prop= RNA_def_property(srna, "expanded", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_EXPAND); + RNA_def_property_ui_text(prop, "Expanded", "Constraint's panel is expanded in UI."); + + // XXX this is really an internal flag, but it may be useful for some tools to be able to access this... + prop= RNA_def_property(srna, "disabled", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_flag(prop, PROP_NOT_EDITABLE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_DISABLE); + RNA_def_property_ui_text(prop, "Disabled", "Constraint has invalid settings and will not be evaluated."); + + // TODO: setting this to true must ensure that all others in stack are turned off too... + prop= RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_ACTIVE); + RNA_def_property_ui_text(prop, "Active", "Constraint is the one being edited "); + + prop= RNA_def_property(srna, "own_ipo", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_OWN_IPO); + RNA_def_property_ui_text(prop, "Local IPO", "Constraint has its own IPO data."); + + prop= RNA_def_property(srna, "proxy_local", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_PROXY_LOCAL); + RNA_def_property_ui_text(prop, "Proxy Local", "Constraint was added in this proxy instance (i.e. did not belong to source Armature)."); + + + /* pointers */ + // err... how to enable this to work, since data pointer can be of various types? + //prop= RNA_def_property(srna, "data", PROP_POINTER, PROP_NONE); + //RNA_def_property_ui_text(prop, "Settings", "Settings specific to this constraint type."); + + prop= RNA_def_property(srna, "ipo", PROP_POINTER, PROP_NONE); + RNA_def_property_ui_text(prop, "IPO", "Local IPO data."); +} + +/* ---- */ + +/* ---- */ + +void RNA_def_constraint(BlenderRNA *brna) +{ + /* basic constraint struct (inherited data) */ + rna_def_constraint_basedata(brna); + + /* add data for specific constraint struct types here... */ + +} + +#endif diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index 4d50b2d2943..7ac44a34ed0 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -100,6 +100,7 @@ void RNA_def_brush(struct BlenderRNA *brna); void RNA_def_brushclone(struct BlenderRNA *brna); void RNA_def_camera(struct BlenderRNA *brna); void RNA_def_color(struct BlenderRNA *brna); +void RNA_def_constraint(struct BlenderRNA *brna); void RNA_def_controller(struct BlenderRNA *brna); void RNA_def_curve(struct BlenderRNA *brna); void RNA_def_gameproperty(struct BlenderRNA *brna); diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 1d012f7e48b..430ae57d87a 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -64,7 +64,11 @@ void RNA_def_object(BlenderRNA *brna) prop= RNA_def_property(srna, "size", PROP_FLOAT, PROP_VECTOR); RNA_def_property_ui_text(prop, "Scale", ""); - + + prop= RNA_def_property(srna, "constraints", PROP_COLLECTION, PROP_NONE); + RNA_def_property_struct_type(prop, "Constraint"); + RNA_def_property_ui_text(prop, "Constraints", ""); + prop= RNA_def_property(srna, "modifiers", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, "Modifier"); RNA_def_property_ui_text(prop, "Modifiers", ""); -- cgit v1.2.3