[Bf-blender-cvs] [e3781b3] strand_gpu: Own file for strand drawing code to avoid polluting drawobject.c even more.
Lukas Tönne
noreply at git.blender.org
Tue Jul 5 09:56:55 CEST 2016
Commit: e3781b3ab36be238667f92cfc10047bb81d7abca
Author: Lukas Tönne
Date: Wed Jun 29 17:37:04 2016 +0200
Branches: strand_gpu
https://developer.blender.org/rBe3781b3ab36be238667f92cfc10047bb81d7abca
Own file for strand drawing code to avoid polluting drawobject.c even more.
===================================================================
M source/blender/editors/space_view3d/CMakeLists.txt
M source/blender/editors/space_view3d/drawobject.c
A source/blender/editors/space_view3d/drawstrands.c
M source/blender/editors/space_view3d/view3d_intern.h
===================================================================
diff --git a/source/blender/editors/space_view3d/CMakeLists.txt b/source/blender/editors/space_view3d/CMakeLists.txt
index 059b384..da79336 100644
--- a/source/blender/editors/space_view3d/CMakeLists.txt
+++ b/source/blender/editors/space_view3d/CMakeLists.txt
@@ -47,6 +47,7 @@ set(SRC
drawmesh.c
drawobject.c
drawsimdebug.c
+ drawstrands.c
drawvolume.c
space_view3d.c
view3d_buttons.c
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 8c0e05e..206ab18 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -7970,37 +7970,8 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
if (md->type == eModifierType_Strands) {
StrandsModifierData *smd = (StrandsModifierData *)md;
- if (smd->strands) {
- GPUStrands *gpu_strands = GPU_strands_get(smd->strands);
-
- GPU_strands_bind_uniforms(gpu_strands, ob->obmat, rv3d->viewmat);
- GPU_strands_bind(gpu_strands, rv3d->viewmat, rv3d->viewinv);
-
- GLuint vertex_buffer;
- glGenBuffers(1, &vertex_buffer);
- glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer);
- const size_t numverts = 4;
- float verts[12] = {
- 0.0f, 0.0f, 0.0f,
- 1.0f, 0.0f, 0.0f,
- 0.0f, 1.0f, 0.0f,
- 1.0f, 1.0f, 0.0f,
- };
- glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 3 * numverts, verts, GL_STATIC_DRAW);
-
- glEnableClientState(GL_VERTEX_ARRAY);
- glVertexPointer(3, GL_FLOAT, 0, NULL);
-
- glDrawArrays(GL_TRIANGLES, 0, numverts);
-
- glDisableClientState(GL_VERTEX_ARRAY);
-
- /* cleanup */
- glBindBuffer(GL_ARRAY_BUFFER, 0);
- glDeleteBuffers(1, &vertex_buffer);
-
- GPU_strands_unbind(gpu_strands);
- }
+ if (smd->strands)
+ draw_strands(smd->strands, ob, rv3d);
}
}
diff --git a/source/blender/editors/space_view3d/drawstrands.c b/source/blender/editors/space_view3d/drawstrands.c
new file mode 100644
index 0000000..51b885c
--- /dev/null
+++ b/source/blender/editors/space_view3d/drawstrands.c
@@ -0,0 +1,84 @@
+/*
+ * ***** 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) Blender Foundation
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Lukas Toenne
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/editors/space_view3d/drawstrands.c
+ * \ingroup spview3d
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_screen_types.h"
+#include "DNA_strand_types.h"
+#include "DNA_view3d_types.h"
+
+#include "BLI_utildefines.h"
+#include "BLI_math.h"
+
+#include "BKE_strands.h"
+
+#include "BIF_gl.h"
+
+#include "GPU_debug.h"
+#include "GPU_shader.h"
+#include "GPU_strands.h"
+
+#include "view3d_intern.h" // own include
+
+void draw_strands(Strands *strands, Object *ob, RegionView3D *rv3d)
+{
+ GPUStrands *gpu_strands = GPU_strands_get(strands);
+
+ GPU_strands_bind_uniforms(gpu_strands, ob->obmat, rv3d->viewmat);
+ GPU_strands_bind(gpu_strands, rv3d->viewmat, rv3d->viewinv);
+
+ GLuint vertex_buffer;
+ glGenBuffers(1, &vertex_buffer);
+ glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer);
+ const size_t numverts = 4;
+ float verts[12] = {
+ 0.0f, 0.0f, 0.0f,
+ 1.0f, 0.0f, 0.0f,
+ 0.0f, 1.0f, 0.0f,
+ 1.0f, 1.0f, 0.0f,
+ };
+ glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 3 * numverts, verts, GL_STATIC_DRAW);
+
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glVertexPointer(3, GL_FLOAT, 0, NULL);
+
+ glDrawArrays(GL_TRIANGLES, 0, numverts);
+
+ glDisableClientState(GL_VERTEX_ARRAY);
+
+ /* cleanup */
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+ glDeleteBuffers(1, &vertex_buffer);
+
+ GPU_strands_unbind(gpu_strands);
+}
diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h
index 6d831c6..eb1a65c 100644
--- a/source/blender/editors/space_view3d/view3d_intern.h
+++ b/source/blender/editors/space_view3d/view3d_intern.h
@@ -46,6 +46,7 @@ struct bContext;
struct bMotionPath;
struct bPoseChannel;
struct Mesh;
+struct Strands;
struct wmNDOFMotionData;
struct wmOperatorType;
struct wmWindowManager;
@@ -285,7 +286,10 @@ ARegion *view3d_has_tools_region(ScrArea *sa);
extern const char *view3d_context_dir[]; /* doc access */
-/* draw_volume.c */
+/* drawstrands.c */
+void draw_strands(struct Strands *strands, struct Object *ob, struct RegionView3D *rv3d);
+
+/* drawvolume.c */
void draw_smoke_volume(struct SmokeDomainSettings *sds, struct Object *ob,
const float min[3], const float max[3],
const float viewnormal[3]);
More information about the Bf-blender-cvs
mailing list