[Bf-blender-cvs] [98970f7] master: OpenSubdiv: Get number of UVs from topology refiner

Sergey Sharybin noreply at git.blender.org
Fri Jul 22 14:56:33 CEST 2016


Commit: 98970f71fe95e6b842582f5b71f3081798a8f54a
Author: Sergey Sharybin
Date:   Fri Jul 22 12:50:27 2016 +0200
Branches: master
https://developer.blender.org/rB98970f71fe95e6b842582f5b71f3081798a8f54a

OpenSubdiv: Get number of UVs from topology refiner

This allows us to store more than one UV layer in the UVs array.

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

M	intern/opensubdiv/opensubdiv_capi.cc

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

diff --git a/intern/opensubdiv/opensubdiv_capi.cc b/intern/opensubdiv/opensubdiv_capi.cc
index 8e0c7f9..9093fd8 100644
--- a/intern/opensubdiv/opensubdiv_capi.cc
+++ b/intern/opensubdiv/opensubdiv_capi.cc
@@ -164,7 +164,7 @@ static void interpolate_fvar_data(OpenSubdiv::Far::TopologyRefiner& refiner,
 	const int channel = 0;
 	/* TODO(sergey): Make it somehow more generic way. */
 	const int fvar_width = 2;
-
+	const int num_uvs = refiner.GetLevel(0).GetNumFVarValues(0) * 2;
 	int max_level = refiner.GetMaxLevel(),
 	    num_values_max = refiner.GetLevel(max_level).GetNumFVarValues(channel),
 	    num_values_total = refiner.GetNumFVarValuesTotal(channel);
@@ -177,7 +177,7 @@ static void interpolate_fvar_data(OpenSubdiv::Far::TopologyRefiner& refiner,
 		fvar_data.resize(num_values_max * fvar_width);
 		std::vector<FVarVertex> buffer(num_values_total - num_values_max);
 		FVarVertex *src = &buffer[0];
-		memcpy(src, &uvs[0], uvs.size() * sizeof(float));
+		memcpy(src, &uvs[0], num_uvs * sizeof(float));
 		/* Defer the last level to treat separately with its alternate
 		 * destination.
 		 */
@@ -192,7 +192,7 @@ static void interpolate_fvar_data(OpenSubdiv::Far::TopologyRefiner& refiner,
 		/* For adaptive we keep all levels. */
 		fvar_data.resize(num_values_total * fvar_width);
 		FVarVertex *src = reinterpret_cast<FVarVertex *>(&fvar_data[0]);
-		memcpy(src, &uvs[0], uvs.size() * sizeof(float));
+		memcpy(src, &uvs[0], num_uvs * sizeof(float));
 		for (int level = 1; level <= max_level; ++level) {
 			FVarVertex *dst = src + refiner.GetLevel(level-1).GetNumFVarValues(channel);
 			primvar_refiner.InterpolateFaceVarying(level, src, dst, channel);




More information about the Bf-blender-cvs mailing list