[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18322] branches/blender2.5/blender/source /blender: RNA
Brecht Van Lommel
brecht at blender.org
Sun Jan 4 20:25:24 CET 2009
Revision: 18322
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18322
Author: blendix
Date: 2009-01-04 20:25:24 +0100 (Sun, 04 Jan 2009)
Log Message:
-----------
RNA
* DNA_cloth_types.h, patch by Roelf de Kock. The gravity[3] member
is not being parsed correct by makesdna.c and will give issues
even when trying to fix it. Worked around it for now in RNA by
wrapping it manually, but this should really be fixed in the DNA
genetics code, added a comment about it in DNA_cloth_types.h.
* Handle vertex groups and uv layers more consistent now. They are
all exposed as strings now. Reason is that indices don't really
say much, and a direct pointer is not always possible because for
example a uv layer in a material can be used for multiple objects
and so there is no single pointer. In python it is not too hard
to use either since the strings works as a key for lookups.
For the user interface we can later think of some method to
generate popup menus in a way that works for vertex groups,
uv layers, bones etc.
* This also fixes the XXX's in rna_modifier.c, I think that can be
marked done.
Modified Paths:
--------------
branches/blender2.5/blender/source/blender/gpu/GPU_draw.h
branches/blender2.5/blender/source/blender/makesdna/DNA_cloth_types.h
branches/blender2.5/blender/source/blender/makesrna/RNA_access.h
branches/blender2.5/blender/source/blender/makesrna/intern/CMakeLists.txt
branches/blender2.5/blender/source/blender/makesrna/intern/makesrna.c
branches/blender2.5/blender/source/blender/makesrna/intern/rna_define.c
branches/blender2.5/blender/source/blender/makesrna/intern/rna_internal.h
branches/blender2.5/blender/source/blender/makesrna/intern/rna_material.c
branches/blender2.5/blender/source/blender/makesrna/intern/rna_modifier.c
branches/blender2.5/blender/source/blender/makesrna/intern/rna_object.c
branches/blender2.5/blender/source/blender/makesrna/intern/rna_texture.c
Added Paths:
-----------
branches/blender2.5/blender/source/blender/makesrna/intern/rna_cloth.c
Modified: branches/blender2.5/blender/source/blender/gpu/GPU_draw.h
===================================================================
--- branches/blender2.5/blender/source/blender/gpu/GPU_draw.h 2009-01-04 19:17:34 UTC (rev 18321)
+++ branches/blender2.5/blender/source/blender/gpu/GPU_draw.h 2009-01-04 19:25:24 UTC (rev 18322)
@@ -41,7 +41,7 @@
struct MTFace;
struct Object;
struct Scene;
-struct View3d;
+struct View3D;
/* OpenGL drawing functions related to shading. These are also
* shared with the game engine, where there were previously
Modified: branches/blender2.5/blender/source/blender/makesdna/DNA_cloth_types.h
===================================================================
--- branches/blender2.5/blender/source/blender/makesdna/DNA_cloth_types.h 2009-01-04 19:17:34 UTC (rev 18321)
+++ branches/blender2.5/blender/source/blender/makesdna/DNA_cloth_types.h 2009-01-04 19:25:24 UTC (rev 18322)
@@ -47,6 +47,9 @@
float mingoal; /* see SB */
float Cdis; /* Mechanical damping of springs. */
float Cvi; /* Viscous/fluid damping. */
+ /* XXX the extra space here results in wrong DNA parsing,
+ * and reconstruct fails and gives corrupt settings when
+ * removing it because the old dna is wrong ... */
float gravity [3]; /* Gravity/external force vector. */
float dt; /* This is the duration of our time step, computed. */
float mass; /* The mass of the entire cloth. */
@@ -74,8 +77,8 @@
short vgroup_mass; /* optional vertexgroup name for assigning weight.*/
short vgroup_struct; /* vertex group for scaling structural stiffness */
short presets; /* used for presets on GUI */
- short pad;
- int pad2;
+ short pad;
+ int pad2;
} ClothSimSettings;
Modified: branches/blender2.5/blender/source/blender/makesrna/RNA_access.h
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/RNA_access.h 2009-01-04 19:17:34 UTC (rev 18321)
+++ branches/blender2.5/blender/source/blender/makesrna/RNA_access.h 2009-01-04 19:25:24 UTC (rev 18322)
@@ -55,6 +55,8 @@
extern StructRNA RNA_CastModifier;
extern StructRNA RNA_CharInfo;
extern StructRNA RNA_ClothModifier;
+extern StructRNA RNA_ClothCollisionSettings;
+extern StructRNA RNA_ClothSettings;
extern StructRNA RNA_CollectionProperty;
extern StructRNA RNA_CollisionModifier;
extern StructRNA RNA_CollisionSensor;
Modified: branches/blender2.5/blender/source/blender/makesrna/intern/CMakeLists.txt
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/CMakeLists.txt 2009-01-04 19:17:34 UTC (rev 18321)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/CMakeLists.txt 2009-01-04 19:25:24 UTC (rev 18322)
@@ -30,6 +30,7 @@
rna_armature.c
rna_brush.c
rna_camera.c
+ rna_cloth.c
rna_color.c
rna_constraint.c
rna_controller.c
Modified: branches/blender2.5/blender/source/blender/makesrna/intern/makesrna.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/makesrna.c 2009-01-04 19:17:34 UTC (rev 18321)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/makesrna.c 2009-01-04 19:25:24 UTC (rev 18322)
@@ -902,6 +902,7 @@
{"rna_armature.c", RNA_def_armature},
{"rna_brush.c", RNA_def_brush},
{"rna_camera.c", RNA_def_camera},
+ {"rna_cloth.c", RNA_def_cloth},
{"rna_color.c", RNA_def_color},
{"rna_constraint.c", RNA_def_constraint},
{"rna_controller.c", RNA_def_controller},
Added: branches/blender2.5/blender/source/blender/makesrna/intern/rna_cloth.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/rna_cloth.c (rev 0)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/rna_cloth.c 2009-01-04 19:25:24 UTC (rev 18322)
@@ -0,0 +1,343 @@
+/**
+ * $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)
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <stdlib.h>
+#include <limits.h>
+
+#include "RNA_define.h"
+#include "RNA_types.h"
+
+#include "rna_internal.h"
+
+#include "BKE_cloth.h"
+#include "DNA_cloth_types.h"
+
+#ifdef RNA_RUNTIME
+
+static void rna_ClothSettings_max_bend_set(struct PointerRNA *ptr, float value)
+{
+ ClothSimSettings *settings = (ClothSimSettings*)ptr->data;
+
+ /* check for clipping */
+ if(value < settings->bending)
+ value = settings->bending;
+
+ settings->max_bend = value;
+}
+
+static void rna_ClothSettings_max_struct_set(struct PointerRNA *ptr, float value)
+{
+ ClothSimSettings *settings = (ClothSimSettings*)ptr->data;
+
+ /* check for clipping */
+ if(value < settings->structural)
+ value = settings->structural;
+
+ settings->max_struct = value;
+}
+
+static void rna_ClothSettings_mass_vgroup_get(PointerRNA *ptr, char *value)
+{
+ ClothSimSettings *sim= (ClothSimSettings*)ptr->data;
+ rna_object_vgroup_name_index_get(ptr, value, sim->vgroup_mass);
+}
+
+static int rna_ClothSettings_mass_vgroup_length(PointerRNA *ptr)
+{
+ ClothSimSettings *sim= (ClothSimSettings*)ptr->data;
+ return rna_object_vgroup_name_index_length(ptr, sim->vgroup_mass);
+}
+
+static void rna_ClothSettings_mass_vgroup_set(PointerRNA *ptr, const char *value)
+{
+ ClothSimSettings *sim= (ClothSimSettings*)ptr->data;
+ rna_object_vgroup_name_index_set(ptr, value, &sim->vgroup_mass);
+}
+
+static void rna_ClothSettings_struct_vgroup_get(PointerRNA *ptr, char *value)
+{
+ ClothSimSettings *sim= (ClothSimSettings*)ptr->data;
+ rna_object_vgroup_name_index_get(ptr, value, sim->vgroup_struct);
+}
+
+static int rna_ClothSettings_struct_vgroup_length(PointerRNA *ptr)
+{
+ ClothSimSettings *sim= (ClothSimSettings*)ptr->data;
+ return rna_object_vgroup_name_index_length(ptr, sim->vgroup_struct);
+}
+
+static void rna_ClothSettings_struct_vgroup_set(PointerRNA *ptr, const char *value)
+{
+ ClothSimSettings *sim= (ClothSimSettings*)ptr->data;
+ rna_object_vgroup_name_index_set(ptr, value, &sim->vgroup_struct);
+}
+
+static void rna_ClothSettings_bend_vgroup_get(PointerRNA *ptr, char *value)
+{
+ ClothSimSettings *sim= (ClothSimSettings*)ptr->data;
+ rna_object_vgroup_name_index_get(ptr, value, sim->vgroup_bend);
+}
+
+static int rna_ClothSettings_bend_vgroup_length(PointerRNA *ptr)
+{
+ ClothSimSettings *sim= (ClothSimSettings*)ptr->data;
+ return rna_object_vgroup_name_index_length(ptr, sim->vgroup_bend);
+}
+
+static void rna_ClothSettings_bend_vgroup_set(PointerRNA *ptr, const char *value)
+{
+ ClothSimSettings *sim= (ClothSimSettings*)ptr->data;
+ rna_object_vgroup_name_index_set(ptr, value, &sim->vgroup_bend);
+}
+
+static float rna_ClothSettings_gravity_get(PointerRNA *ptr, int index)
+{
+ ClothSimSettings *sim= (ClothSimSettings*)ptr->data;
+ return sim->gravity[index];
+}
+
+static void rna_ClothSettings_gravity_set(PointerRNA *ptr, int index, float value)
+{
+ ClothSimSettings *sim= (ClothSimSettings*)ptr->data;
+ sim->gravity[index]= value;
+}
+
+#else
+
+static void rna_def_cloth_sim_settings(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ srna = RNA_def_struct(brna, "ClothSettings", NULL);
+ RNA_def_struct_ui_text(srna, "Cloth Settings", "Cloth simulation settings for an object.");
+ RNA_def_struct_sdna(srna, "ClothSimSettings");
+
+ /* goal */
+
+ prop= RNA_def_property(srna, "goal_minimum", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "mingoal");
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_ui_text(prop, "Goal Minimum", "Goal minimum, vertex group weights are scaled to match this range.");
+
+ prop= RNA_def_property(srna, "goal_maximum", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "maxgoal");
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_ui_text(prop, "Goal Maximum", "Goal maximum, vertex group weights are scaled to match this range.");
+
+ prop= RNA_def_property(srna, "goal_default", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "defgoal");
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_ui_text(prop, "Goal Default", "Default Goal (vertex target position) value, when no Vertex Group used.");
+
+ prop= RNA_def_property(srna, "goal_spring", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "goalspring");
+ RNA_def_property_range(prop, 0.0f, 0.999f);
+ RNA_def_property_ui_text(prop, "Goal Stiffness", "Goal (vertex target position) spring stiffness.");
+
+ prop= RNA_def_property(srna, "goal_friction", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "goalfrict");
+ RNA_def_property_range(prop, 0.0f, 50.0f);
+ RNA_def_property_ui_text(prop, "Goal Damping", "Goal (vertex target position) friction.");
+
+ /* mass */
+
+ prop= RNA_def_property(srna, "mass", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_range(prop, 0.0f, 10.0f);
+ RNA_def_property_ui_text(prop, "Mass", "Mass of cloth material.");
+
+ prop= RNA_def_property(srna, "mass_vertex_group", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_funcs(prop, "rna_ClothSettings_mass_vgroup_get", "rna_ClothSettings_mass_vgroup_length", "rna_ClothSettings_mass_vgroup_set");
+ RNA_def_property_ui_text(prop, "Mass Vertex Group", "Vertex group for fine control over mass distribution.");
+
+ prop= RNA_def_property(srna, "gravity", PROP_FLOAT, PROP_VECTOR);
+ RNA_def_property_array(prop, 3);
+ RNA_def_property_range(prop, -100.0, 100.0);
+ RNA_def_property_float_funcs(prop, "rna_ClothSettings_gravity_get", "rna_ClothSettings_gravity_set", NULL);
+ RNA_def_property_ui_text(prop, "Gravity", "Gravity or external force vector.");
+
+ /* various */
+
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list