[Bf-blender-cvs] [731ffd3] master: Cycles: remove approximate subdivision surface with gregory patches code.

Brecht Van Lommel noreply at git.blender.org
Thu Nov 28 02:35:39 CET 2013


Commit: 731ffd3cd4c1d578fb02d39dc512bace850c2e8b
Author: Brecht Van Lommel
Date:   Thu Nov 28 00:13:32 2013 +0100
http://developer.blender.org/rB731ffd3cd4c1d578fb02d39dc512bace850c2e8b

Cycles: remove approximate subdivision surface with gregory patches code.

It was never fully implemented and will be replaced by OpenSubdiv. Only linear
subdivision remains now. Also includes some refactoring in the split/dice code,
adding a SubdParams struct to pass around parameters more easily.

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

M	intern/cycles/app/CMakeLists.txt
M	intern/cycles/app/cycles_xml.cpp
M	intern/cycles/blender/blender_mesh.cpp
M	intern/cycles/subd/CMakeLists.txt
D	intern/cycles/subd/subd_build.cpp
D	intern/cycles/subd/subd_build.h
M	intern/cycles/subd/subd_dice.cpp
M	intern/cycles/subd/subd_dice.h
D	intern/cycles/subd/subd_edge.h
D	intern/cycles/subd/subd_face.h
M	intern/cycles/subd/subd_mesh.cpp
M	intern/cycles/subd/subd_mesh.h
M	intern/cycles/subd/subd_patch.cpp
M	intern/cycles/subd/subd_patch.h
D	intern/cycles/subd/subd_ring.cpp
D	intern/cycles/subd/subd_ring.h
M	intern/cycles/subd/subd_split.cpp
M	intern/cycles/subd/subd_split.h
D	intern/cycles/subd/subd_stencil.cpp
D	intern/cycles/subd/subd_stencil.h
D	intern/cycles/subd/subd_vert.h

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

diff --git a/intern/cycles/app/CMakeLists.txt b/intern/cycles/app/CMakeLists.txt
index a2142d7..ada5ea5 100644
--- a/intern/cycles/app/CMakeLists.txt
+++ b/intern/cycles/app/CMakeLists.txt
@@ -41,7 +41,7 @@ if(WITH_CYCLES_STANDALONE AND WITH_CYCLES_STANDALONE_GUI)
 endif()
 
 if(WITH_CYCLES_OSL)
-	list(APPEND LIBRARIES cycles_kernel_osl ${OSL_LIBRARIES})
+	list(APPEND LIBRARIES cycles_kernel_osl ${OSL_LIBRARIES} ${LLVM_LIBRARY})
 endif()
 
 include_directories(${INC})
diff --git a/intern/cycles/app/cycles_xml.cpp b/intern/cycles/app/cycles_xml.cpp
index 55a2a30..df187f0 100644
--- a/intern/cycles/app/cycles_xml.cpp
+++ b/intern/cycles/app/cycles_xml.cpp
@@ -703,15 +703,14 @@ static void xml_read_mesh(const XMLReadState& state, pugi::xml_node node)
 		}
 
 		/* finalize subd mesh */
-		sdmesh.link_boundary();
-
-		/* subdivide */
-		DiagSplit dsplit;
-		//dsplit.camera = state.scene->camera;
-		//dsplit.dicing_rate = 5.0f;
-		dsplit.dicing_rate = state.dicing_rate;
-		xml_read_float(&dsplit.dicing_rate, node, "dicing_rate");
-		sdmesh.tessellate(&dsplit, false, mesh, shader, smooth);
+		sdmesh.finish();
+
+		/* parameters */
+		SubdParams sdparams(mesh, shader, smooth);
+		xml_read_float(&sdparams.dicing_rate, node, "dicing_rate");
+
+		DiagSplit dsplit(sdparams);;
+		sdmesh.tessellate(&dsplit);
 	}
 	else {
 		/* create vertices */
@@ -789,12 +788,11 @@ static void xml_read_patch(const XMLReadState& state, pugi::xml_node node)
 		mesh->used_shaders.push_back(state.shader);
 
 		/* split */
-		DiagSplit dsplit;
-		//dsplit.camera = state.scene->camera;
-		//dsplit.dicing_rate = 5.0f;
-		dsplit.dicing_rate = state.dicing_rate;
-		xml_read_float(&dsplit.dicing_rate, node, "dicing_rate");
-		dsplit.split_quad(mesh, patch, state.shader, state.smooth);
+		SubdParams sdparams(mesh, state.shader, state.smooth);
+		xml_read_float(&sdparams.dicing_rate, node, "dicing_rate");
+
+		DiagSplit dsplit(sdparams);
+		dsplit.split_quad(patch);
 
 		delete patch;
 
diff --git a/intern/cycles/blender/blender_mesh.cpp b/intern/cycles/blender/blender_mesh.cpp
index e42af60..45ec92a 100644
--- a/intern/cycles/blender/blender_mesh.cpp
+++ b/intern/cycles/blender/blender_mesh.cpp
@@ -365,7 +365,7 @@ static void create_mesh(Scene *scene, Mesh *mesh, BL::Mesh b_mesh, const vector<
 	}
 }
 
-static void create_subd_mesh(Mesh *mesh, BL::Mesh b_mesh, PointerRNA *cmesh, const vector<uint>& used_shaders)
+static void create_subd_mesh(Scene *scene, Mesh *mesh, BL::Mesh b_mesh, PointerRNA *cmesh, const vector<uint>& used_shaders)
 {
 	/* create subd mesh */
 	SubdMesh sdmesh;
@@ -386,21 +386,20 @@ static void create_subd_mesh(Mesh *mesh, BL::Mesh b_mesh, PointerRNA *cmesh, con
 
 		if(n == 4)
 			sdmesh.add_face(vi[0], vi[1], vi[2], vi[3]);
-#if 0
 		else
 			sdmesh.add_face(vi[0], vi[1], vi[2]);
-#endif
 	}
 
 	/* finalize subd mesh */
-	sdmesh.link_boundary();
+	sdmesh.finish();
 
-	/* subdivide */
-	DiagSplit dsplit;
-	dsplit.camera = NULL;
-	dsplit.dicing_rate = RNA_float_get(cmesh, "dicing_rate");
+	SubdParams sdparams(mesh, used_shaders[0], true);
+	sdparams.dicing_rate = RNA_float_get(cmesh, "dicing_rate");
+	//scene->camera->update();
+	//sdparams.camera = scene->camera;
 
-	sdmesh.tessellate(&dsplit, false, mesh, used_shaders[0], true);
+	DiagSplit dsplit(sdparams);;
+	sdmesh.tessellate(&dsplit);
 }
 
 /* Sync */
@@ -482,7 +481,7 @@ Mesh *BlenderSync::sync_mesh(BL::Object b_ob, bool object_updated, bool hide_tri
 		if(b_mesh) {
 			if(render_layer.use_surfaces && !hide_tris) {
 				if(cmesh.data && experimental && RNA_boolean_get(&cmesh, "use_subdivision"))
-					create_subd_mesh(mesh, b_mesh, &cmesh, used_shaders);
+					create_subd_mesh(scene, mesh, b_mesh, &cmesh, used_shaders);
 				else
 					create_mesh(scene, mesh, b_mesh, used_shaders);
 			}
diff --git a/intern/cycles/subd/CMakeLists.txt b/intern/cycles/subd/CMakeLists.txt
index 838776d..2641f6d 100644
--- a/intern/cycles/subd/CMakeLists.txt
+++ b/intern/cycles/subd/CMakeLists.txt
@@ -12,26 +12,17 @@ set(INC_SYS
 )
 
 set(SRC
-	subd_build.cpp
 	subd_dice.cpp
 	subd_mesh.cpp
 	subd_patch.cpp
-	subd_ring.cpp
 	subd_split.cpp
-	subd_stencil.cpp
 )
 
 set(SRC_HEADERS
-	subd_build.h
 	subd_dice.h
-	subd_edge.h
-	subd_face.h
 	subd_mesh.h
 	subd_patch.h
-	subd_ring.h
 	subd_split.h
-	subd_stencil.h
-	subd_vert.h
 )
 
 include_directories(${INC})
diff --git a/intern/cycles/subd/subd_build.cpp b/intern/cycles/subd/subd_build.cpp
deleted file mode 100644
index f3c2837..0000000
--- a/intern/cycles/subd/subd_build.cpp
+++ /dev/null
@@ -1,669 +0,0 @@
-/*
- * Copyright 2006, NVIDIA Corporation Ignacio Castano <icastano at nvidia.com>
- *
- * Modifications copyright (c) 2011, Blender Foundation. All rights reserved.
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- * 
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-#include "subd_build.h"
-#include "subd_edge.h"
-#include "subd_face.h"
-#include "subd_ring.h"
-#include "subd_mesh.h"
-#include "subd_patch.h"
-#include "subd_stencil.h"
-#include "subd_vert.h"
-
-#include "util_algorithm.h"
-#include "util_debug.h"
-#include "util_math.h"
-#include "util_string.h"
-
-CCL_NAMESPACE_BEGIN
-
-/* Subd Builder */
-
-SubdBuilder *SubdBuilder::create(bool linear)
-{
-	if(linear)
-		return new SubdLinearBuilder();
-	else
-		return new SubdAccBuilder();
-}
-
-/* Gregory ACC Stencil */
-
-class GregoryAccStencil {
-public:
-	SubdFaceRing *ring;
-	StencilMask stencil[20];
-
-	GregoryAccStencil(SubdFaceRing *ring_)
-	{
-		ring = ring_;
-
-		for(int i = 0; i < 20; i++)
-			stencil[i].resize(ring->num_verts());
-	}
-
-	StencilMask& get(int i)
-	{
-		assert(i < 20);
-		return stencil[i];
-	}
-
-	float& get(int i, SubdVert *vert)
-	{
-		assert(i < 20);
-		return stencil[i][ring->vert_index(vert)];
-	}
-};
-
-static float pseudoValence(SubdVert *vert)
-{
-	float valence = (float)vert->valence();
-
-	if(vert->is_boundary()) {
-		/* we treat boundary verts as being half a closed mesh. corners are
-		 * special case. n = 4 for corners and n = 2*(n-1) for boundaries. */
-		if(valence == 2) return 4;
-		return (valence - 1)*2;
-	}
-
-	return valence;
-}
-
-/* Subd ACC Builder */
-
-SubdAccBuilder::SubdAccBuilder()
-{
-}
-
-SubdAccBuilder::~SubdAccBuilder()
-{
-}
-
-Patch *SubdAccBuilder::run(SubdFace *face)
-{
-	SubdFaceRing ring(face, face->edge);
-	GregoryAccStencil stencil(&ring);
-	float3 position[20];
-
-	computeCornerStencil(&ring, &stencil);
-	computeEdgeStencil(&ring, &stencil);
-	computeInteriorStencil(&ring, &stencil);
-
-	ring.evaluate_stencils(position, stencil.stencil, 20);
-
-	if(face->num_edges() == 3) {
-		GregoryTrianglePatch *patch = new GregoryTrianglePatch();
-		memcpy(patch->hull, position, sizeof(float3)*20);
-		return patch;
-	}
-	else if(face->num_edges() == 4) {
-		GregoryQuadPatch *patch = new GregoryQuadPatch();
-		memcpy(patch->hull, position, sizeof(float3)*20);
-		return patch;
-	}
-
-	assert(0); /* n-gons should have been split already */
-	return NULL;
-}
-
-/* Gregory Patch */
-
-void SubdAccBuilder::computeCornerStencil(SubdFaceRing *ring, GregoryAccStencil *stencil)
-{
-	const int cornerIndices[7] = {8, 11, 19, 16,   6, 9, 12};
-	int primitiveOffset = ring->is_quad()? 0: 4;
-
-	SubdEdge *firstEdge = ring->firstEdge();
-
-	/* compute corner control points */
-	int v = 0;
-
-	for(SubdFace::EdgeIterator it(firstEdge); !it.isDone(); it.advance(), v++) {
-		SubdVert *vert = it.current()->from();
-		int valence = vert->valence();
-		int cid = cornerIndices[primitiveOffset+v];
-
-		if(vert->is_boundary()) {
-			/* compute vertex limit position */
-			SubdEdge *edge0 = vert->edge;
-			SubdEdge *edge1 = vert->edge->prev;
-
-			assert(edge0->face == NULL);
-			assert(edge0->to() != vert);
-			assert(edge1->face == NULL);
-			assert(edge1->from() != vert);
-
-			stencil->get(cid, vert) = 2.0f/3.0f;
-			stencil->get(cid, edge0->to()) = 1.0f/6.0f;
-			stencil->get(cid, edge1->from()) = 1.0f/6.0f;
-
-			assert(stencil->get(cid).is_normalized());
-		}
-		else {
-			stencil->get(cid, vert) = 3.0f*valence*valence;
-
-			for(SubdVert::EdgeIterator eit(vert->edge); !eit.isDone(); eit.advance()) {
-				SubdEdge *edge = eit.current();
-				assert(vert->co == edge->from()->co);
-
-				stencil->get(cid, edge->to()) = 12.0f;
-
-				if(SubdFaceRing::is_triangle(edge->face)) {
-					/* distribute weight to all verts */
-					stencil->get(cid, vert) += 1.0f;
-					stencil->get(cid, edge->to()) += 1.0f;
-					stencil->get(cid, edge->next->to()) += 1.0f;
-				}
-				else
-					stencil->get(cid, edge->next->to()) = 3.0f;
-			}
-
-			/* normalize stencil. */
-			stencil->get(cid).normalize();
-		}
-	}
-}
-
-void SubdAccBuilder::computeEdgeStencil(SubdFaceRing *ring, GregoryAccStencil *stencil)
-{
-	const int cornerIndices[7] = {8, 11, 19, 16,    6,  9, 12};
-	const int edge1Indices[7] = {9, 13, 18, 14,    7, 10, 13};
-	const int edge2Indices[7] = {12, 10, 15, 17,    14,  8, 11};
-	int primitiveOffset = ring->is_quad()? 0: 4;
-
-	float tangentScales[14] = {
-		0.0f, 0.0f, 0.0f, 0.667791f, 1.0f,
-		1.11268f, 1.1284f, 1.10289f, 1.06062f,
-		1.01262f, 0.963949f, 0.916926f, 0.872541f, 0.831134f
-	};
-
-	SubdEdge *firstEdge = ring->firstEdge();
-
-	/* compute corner / edge control points */
-	int v = 0;
-
-	for(SubdFace

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list