[Bf-blender-cvs] [2d39952] depsgraph_refactor: Utility math classes, to provide easier type wrappers around basic BLI float arrays.

Lukas Tönne noreply at git.blender.org
Fri Jun 13 08:54:34 CEST 2014


Commit: 2d3995202884527fb72652f17bdf37458902a522
Author: Lukas Tönne
Date:   Thu Jun 12 10:05:48 2014 +0200
https://developer.blender.org/rB2d3995202884527fb72652f17bdf37458902a522

Utility math classes, to provide easier type wrappers around basic
BLI float arrays.

Not used currently, but could come in handy later.

===================================================================

M	source/blender/depsgraph/CMakeLists.txt
A	source/blender/depsgraph/util/depsgraph_util_math.cpp
A	source/blender/depsgraph/util/depsgraph_util_math.h

===================================================================

diff --git a/source/blender/depsgraph/CMakeLists.txt b/source/blender/depsgraph/CMakeLists.txt
index a0d533d..7015521 100644
--- a/source/blender/depsgraph/CMakeLists.txt
+++ b/source/blender/depsgraph/CMakeLists.txt
@@ -76,6 +76,8 @@ set(SRC
 	util/depsgraph_util_hash.h
 	util/depsgraph_util_id.h
 	util/depsgraph_util_map.h
+	util/depsgraph_util_math.h
+	util/depsgraph_util_math.cpp
 	util/depsgraph_util_priority_queue.h
 	util/depsgraph_util_rna.h
 	util/depsgraph_util_set.h
diff --git a/source/blender/depsgraph/util/depsgraph_util_math.cpp b/source/blender/depsgraph/util/depsgraph_util_math.cpp
new file mode 100644
index 0000000..4839c0b
--- /dev/null
+++ b/source/blender/depsgraph/util/depsgraph_util_math.cpp
@@ -0,0 +1,36 @@
+/*
+ * ***** 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2014 Blender Foundation.
+ * All rights reserved.
+ *
+ * Original Author: Lukas Toenne
+ * Contributor(s): 
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include "depsgraph_util_math.h"
+
+const Transform3 Transform3::identity({{1.0f, 0.0f, 0.0f},
+                                       {0.0f, 1.0f, 0.0f},
+                                       {0.0f, 0.0f, 1.0f}});
+
+const Transform4 Transform4::identity({{1.0f, 0.0f, 0.0f, 0.0f},
+                                       {0.0f, 1.0f, 0.0f, 0.0f},
+                                       {0.0f, 0.0f, 1.0f, 0.0f},
+                                       {0.0f, 0.0f, 0.0f, 1.0f}});
diff --git a/source/blender/depsgraph/util/depsgraph_util_math.h b/source/blender/depsgraph/util/depsgraph_util_math.h
new file mode 100644
index 0000000..31b5e1f
--- /dev/null
+++ b/source/blender/depsgraph/util/depsgraph_util_math.h
@@ -0,0 +1,92 @@
+/*
+ * ***** 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2014 Blender Foundation.
+ * All rights reserved.
+ *
+ * Original Author: Brecht van Lommel
+ * Contributor(s): Lukas Toenne
+ */
+
+#ifndef __DEPSGRAPH_UTIL_STRING_H__
+#define __DEPSGRAPH_UTIL_STRING_H__
+
+extern "C" {
+#include "BLI_math.h"
+}
+
+struct Transform3 {
+	typedef float (*data_ptr)[3];
+	typedef const float (*const_data_ptr)[3];
+	typedef float (&data_ref)[3][3];
+	typedef const float (&const_data_ref)[3][3];
+	
+	static const Transform3 identity;
+	
+	Transform3()
+	{
+		zero_m3(data);
+	}
+
+	Transform3(const_data_ref copy)
+	{
+		copy_m3_m3(data, (data_ptr)copy);
+	}
+	
+	Transform3 &operator = (const_data_ref copy)
+	{
+		copy_m3_m3(data, (data_ptr)copy);
+		return *this;
+	}
+	
+	operator data_ref() { return data; }
+	operator const_data_ref() const { return data; }
+	
+	float data[3][3];
+};
+
+struct Transform4 {
+	typedef float (*data_ptr)[4];
+	typedef const float (*const_data_ptr)[4];
+	typedef float (&data_ref)[4][4];
+	typedef const float (&const_data_ref)[4][4];
+	
+	static const Transform4 identity;
+	
+	Transform4()
+	{
+		zero_m4(data);
+	}
+
+	Transform4(const_data_ref copy)
+	{
+		copy_m4_m4(data, (data_ptr)copy);
+	}
+	
+	Transform4 &operator = (const_data_ref copy)
+	{
+		copy_m4_m4(data, (data_ptr)copy);
+		return *this;
+	}
+	
+	operator data_ref() { return data; }
+	operator const_data_ref() const { return data; }
+	
+	float data[4][4];
+};
+
+#endif /* __DEPSGRAPH_UTIL_STRING_H__ */




More information about the Bf-blender-cvs mailing list