Commit: dc9917a80a7cbbfdb600f590a655bded07288584
Author: Lukas Tönne
Date:   Mon Mar 3 10:59:36 2014 +0100
Branches: hair_system
https://developer.blender.org/rBdc9917a80a7cbbfdb600f590a655bded07288584

Skeleton code for sampling meshes.

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

A       source/blender/blenkernel/BKE_mesh_sample.h
M       source/blender/blenkernel/CMakeLists.txt
A       source/blender/blenkernel/intern/mesh_sample.c
M       source/blender/makesdna/DNA_meshdata_types.h

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

diff --git a/source/blender/blenkernel/BKE_mesh_sample.h 
b/source/blender/blenkernel/BKE_mesh_sample.h
new file mode 100644
index 0000000..a58e892
--- /dev/null
+++ b/source/blender/blenkernel/BKE_mesh_sample.h
@@ -0,0 +1,73 @@
+/*
+ * ***** 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __BKE_MESH_SAMPLE_H__
+#define __BKE_MESH_SAMPLE_H__
+
+/** \file BKE_mesh_sample.h
+ *  \ingroup bke
+ */
+
+struct MSurfaceSample;
+
+/* Evaluate */
+
+
+/* Iterators */
+
+#if 0
+struct MSampleIterator;
+
+typedef void (*MSampleIteratorNextFunc)(MSampleIterator *iter);
+typedef bool (*MSampleIteratorValidFunc)(MSampleIterator *iter);
+typedef void (*MSampleIteratorFreeFunc)(MSampleIterator *iter);
+
+typedef struct MSampleIterator {
+       MSampleIteratorNextFunc next;
+       MSampleIteratorValidFunc valid;
+       MSampleIteratorFreeFunc free;
+} MSampleIterator;
+
+typedef struct MSampleArrayIterator {
+       MSampleIterator base;
+       
+       MSurfaceSample *cur;
+       int remaining;
+} MSampleArrayIterator;
+
+void BKE_mesh_sample_surface_array_begin(MSurfaceSampleArrayIterator *iter, 
MSurfaceSample *array, int totarray);
+#endif
+
+/* Sampling */
+
+typedef enum eMSurfaceSampleRNG {
+       MSS_RNG_UNIFORM
+} eMSurfaceSampleRNG;
+
+typedef struct MSurfaceSampleInfo {
+       struct DerivedMesh *dm;
+       
+       eMSurfaceSampleRNG rng;
+       unsigned int seed;
+} MSurfaceSampleInfo;
+
+void BKE_mesh_sample_surface_array(const struct MSurfaceSampleInfo *info, 
struct MSurfaceSample *samples, int totsample);
+
+#endif  /* __BKE_MESH_SAMPLE_H__ */
diff --git a/source/blender/blenkernel/CMakeLists.txt 
b/source/blender/blenkernel/CMakeLists.txt
index a6de5d4..60d177c 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -119,6 +119,7 @@ set(SRC
        intern/mesh.c
        intern/mesh_evaluate.c
        intern/mesh_mapping.c
+       intern/mesh_sample.c
        intern/mesh_validate.c
        intern/modifier.c
        intern/modifiers_bmesh.c
@@ -227,6 +228,7 @@ set(SRC
        BKE_mball.h
        BKE_mesh.h
        BKE_mesh_mapping.h
+       BKE_mesh_sample.h
        BKE_modifier.h
        BKE_movieclip.h
        BKE_multires.h
diff --git a/source/blender/blenkernel/intern/mesh_sample.c 
b/source/blender/blenkernel/intern/mesh_sample.c
new file mode 100644
index 0000000..ddb35e2
--- /dev/null
+++ b/source/blender/blenkernel/intern/mesh_sample.c
@@ -0,0 +1,85 @@
+/*
+ * ***** 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/blenkernel/intern/mesh_sample.c
+ *  \ingroup bke
+ *
+ * Sample a mesh surface or volume and evaluate samples on deformed meshes.
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+
+#include "BLI_utildefines.h"
+#include "BLI_math.h"
+#include "BLI_rand.h"
+
+#include "BKE_mesh_sample.h"
+#include "BKE_customdata.h"
+#include "BKE_DerivedMesh.h"
+
+#include "BLI_strict_flags.h"
+
+/* Evaluate */
+
+
+/* Iterators */
+
+#if 0
+static void 
mesh_sample_surface_array_iterator_next(MSurfaceSampleArrayIterator *iter)
+{
+       ++iter->cur;
+       --iter->remaining;
+}
+
+static bool 
mesh_sample_surface_array_iterator_valid(MSurfaceSampleArrayIterator *iter)
+{
+       return (iter->remaining > 0);
+}
+
+static void 
mesh_sample_surface_array_iterator_free(MSurfaceSampleArrayIterator *iter)
+{
+}
+
+void BKE_mesh_sample_surface_array_begin(MSurfaceSampleArrayIterator *iter, 
MSurfaceSample *array, int totarray)
+{
+       iter->cur = array;
+       iter->remaining = totarray;
+       
+       iter->base.next = 
+}
+#endif
+
+
+/* Sampling */
+
+static mesh_sample_surface_uniform(const MSurfaceSampleInfo *info, 
MSurfaceSample *sample, RNG *rng)
+{
+       sample->orig_face = BLI_rng_get_int(rng) % 
info->dm->getNumTessFaces(info->dm);
+       sample->orig_weights = 
+}
+
+void BKE_mesh_sample_surface_array(const MSurfaceSampleInfo *info, 
MSurfaceSample *samples, int totsample)
+{
+       RNG *rng = BLI_rng_new(info->seed);
+       
+}
diff --git a/source/blender/makesdna/DNA_meshdata_types.h 
b/source/blender/makesdna/DNA_meshdata_types.h
index 3304980..97afcb0 100644
--- a/source/blender/makesdna/DNA_meshdata_types.h
+++ b/source/blender/makesdna/DNA_meshdata_types.h
@@ -300,6 +300,12 @@ enum {
        FREESTYLE_FACE_MARK = 1,
 };
 
+typedef struct MSurfaceSample {
+       int orig_face;
+       int pad;
+       float orig_weights[4];
+} MSurfaceSample;
+
 /* mvert->flag */
 enum {
 /*     SELECT              = (1 << 0), */

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to