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

rna_constraint.c « intern « makesrna « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 761e2b89a6213cf7a8269d2defc7cf3a747ffb76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/**
 * $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), Joshua Leung
 *
 * ***** END GPL LICENSE BLOCK *****
 */

#include <stdlib.h>

#include "RNA_define.h"
#include "RNA_types.h"

#include "rna_internal.h"

#include "DNA_constraint_types.h"

#ifdef RNA_RUNTIME

static StructRNA* rna_Constraint_refine(struct PointerRNA *ptr)
{
	bConstraint *con= (bConstraint*)ptr->data;

	switch(con->type) {
		// FIXME: add constraint types
		default:
			return &RNA_Constraint;
	}
}

#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 );
	RNA_def_struct_ui_text(srna, "Constraint", "alter the transformation of 'Objects' or 'Bones' from a number of predefined constraints");
	//RNA_def_struct_refine_func(srna, "rna_Constraint_refine");  // XXX or should this go down below with the data?
	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 */
	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