[Bf-blender-cvs] [260ee7a7705] soc-2018-npr: update to new OSD API again
Sebastian Parborg
noreply at git.blender.org
Tue Jul 17 11:27:04 CEST 2018
Commit: 260ee7a77051696c9d8b2b7cb2fb8e0c67d9d2c2
Author: Sebastian Parborg
Date: Mon Jul 16 13:10:59 2018 +0200
Branches: soc-2018-npr
https://developer.blender.org/rB260ee7a77051696c9d8b2b7cb2fb8e0c67d9d2c2
update to new OSD API again
===================================================================
M intern/opensubdiv/internal/opensubdiv_evaluator.cc
M intern/opensubdiv/internal/opensubdiv_evaluator_internal.cc
M intern/opensubdiv/internal/opensubdiv_evaluator_internal.h
M intern/opensubdiv/opensubdiv_evaluator_capi.h
M source/blender/modifiers/intern/MOD_mybmesh.c
===================================================================
diff --git a/intern/opensubdiv/internal/opensubdiv_evaluator.cc b/intern/opensubdiv/internal/opensubdiv_evaluator.cc
index 29d42a903ba..d9ed40a5a6a 100644
--- a/intern/opensubdiv/internal/opensubdiv_evaluator.cc
+++ b/intern/opensubdiv/internal/opensubdiv_evaluator.cc
@@ -104,6 +104,21 @@ void evaluateLimit(OpenSubdiv_Evaluator* evaluator,
P, dPdu, dPdv);
}
+void evaluateLimit2(OpenSubdiv_Evaluator* evaluator,
+ const int ptex_face_index,
+ const float face_u, const float face_v,
+ float P[3],
+ float dPdu[3],
+ float dPdv[3],
+ float dPduu[3],
+ float dPduv[3],
+ float dPdvv[3]) {
+ evaluator->internal->eval_output->evaluateLimit2(ptex_face_index,
+ face_u, face_v,
+ P, dPdu, dPdv,
+ dPduu, dPduv, dPdvv);
+}
+
void evaluateVarying(OpenSubdiv_Evaluator* evaluator,
const int ptex_face_index,
float face_u, float face_v,
@@ -134,6 +149,7 @@ void assignFunctionPointers(OpenSubdiv_Evaluator* evaluator) {
evaluator->refine = refine;
evaluator->evaluateLimit = evaluateLimit;
+ evaluator->evaluateLimit2 = evaluateLimit2;
evaluator->evaluateVarying = evaluateVarying;
evaluator->evaluateFaceVarying = evaluateFaceVarying;
}
diff --git a/intern/opensubdiv/internal/opensubdiv_evaluator_internal.cc b/intern/opensubdiv/internal/opensubdiv_evaluator_internal.cc
index 595df3eaa75..e3a46ab6b46 100644
--- a/intern/opensubdiv/internal/opensubdiv_evaluator_internal.cc
+++ b/intern/opensubdiv/internal/opensubdiv_evaluator_internal.cc
@@ -356,6 +356,69 @@ class VolatileEvalOutput {
}
}
+ void evalPatchesWithDerivatives2(const PatchCoord& patch_coord,
+ float P[3],
+ float dPdu[3],
+ float dPdv[3],
+ float dPduu[3],
+ float dPduv[3],
+ float dPdvv[3])
+ {
+ StackAllocatedBuffer<6, 1> vertex_data;
+ StackAllocatedBuffer<6, 1> derivatives;
+ StackAllocatedBuffer<6, 1> derivatives1;
+ StackAllocatedBuffer<6, 1> derivatives2;
+ BufferDescriptor vertex_desc(0, 3, 6),
+ du_desc(0, 3, 6),
+ dv_desc(3, 3, 6),
+ duu_desc(0, 3, 6),
+ duv_desc(3, 3, 6),
+ dvv_desc(0, 3, 6);
+ SinglePatchCoordBuffer patch_coord_buffer(patch_coord);
+ const EVALUATOR *eval_instance =
+ OpenSubdiv::Osd::GetEvaluator<EVALUATOR>(evaluator_cache_,
+ src_desc_,
+ vertex_desc,
+ du_desc,
+ dv_desc,
+ duu_desc,
+ duv_desc,
+ dvv_desc,
+ device_context_);
+ EVALUATOR::EvalPatches(src_data_, src_desc_,
+ &vertex_data, vertex_desc,
+ &derivatives, du_desc,
+ &derivatives, dv_desc,
+ &derivatives1, duu_desc,
+ &derivatives1, duv_desc,
+ &derivatives2, dvv_desc,
+ patch_coord_buffer.GetNumVertices(),
+ &patch_coord_buffer,
+ patch_table_, eval_instance, device_context_);
+ float *refined_verts = vertex_data.BindCpuBuffer();
+ memcpy(P, refined_verts, sizeof(float) * 3);
+ if (dPdu != NULL || dPdv != NULL || dPduu != NULL || dPduv != NULL || dPdvv != NULL) {
+ float *refined_drivatives = derivatives.BindCpuBuffer();
+ float *refined_drivatives1 = derivatives1.BindCpuBuffer();
+ float *refined_drivatives2 = derivatives2.BindCpuBuffer();
+ if (dPdu) {
+ memcpy(dPdu, refined_drivatives, sizeof(float) * 3);
+ }
+ if (dPdv) {
+ memcpy(dPdv, refined_drivatives + 3, sizeof(float) * 3);
+ }
+ if (dPduu) {
+ memcpy(dPduu, refined_drivatives1, sizeof(float) * 3);
+ }
+ if (dPduv) {
+ memcpy(dPduv, refined_drivatives1 + 3, sizeof(float) * 3);
+ }
+ if (dPdvv) {
+ memcpy(dPdvv, refined_drivatives2, sizeof(float) * 3);
+ }
+ }
+ }
+
void evalPatchVarying(const PatchCoord& patch_coord, float varying[3]) {
StackAllocatedBuffer<6, 1> varying_data;
BufferDescriptor varying_desc(3, 3, 6);
@@ -564,6 +627,33 @@ void CpuEvalOutputAPI::evaluateLimit(const int ptex_face_index,
implementation_->evalPatchCoord(patch_coord, P);
}}
+void CpuEvalOutputAPI::evaluateLimit2(const int ptex_face_index,
+ float face_u, float face_v,
+ float P[3],
+ float dPdu[3],
+ float dPdv[3],
+ float dPduu[3],
+ float dPduv[3],
+ float dPdvv[3]) {
+ assert(face_u >= 0.0f);
+ assert(face_u <= 1.0f);
+ assert(face_v >= 0.0f);
+ assert(face_v <= 1.0f);
+ const PatchTable::PatchHandle* handle =
+ patch_map_->FindPatch(ptex_face_index, face_u, face_v);
+ PatchCoord patch_coord(*handle, face_u, face_v);
+ if (dPdu != NULL || dPdv != NULL || dPduu != NULL || dPduv != NULL || dPdvv != NULL ) {
+ implementation_->evalPatchesWithDerivatives2(patch_coord,
+ P,
+ dPdu,
+ dPdv,
+ dPduu,
+ dPduv,
+ dPdvv);
+ } else {
+ implementation_->evalPatchCoord(patch_coord, P);
+ }}
+
void CpuEvalOutputAPI::evaluateVarying(const int ptex_face_index,
float face_u, float face_v,
float varying[3]) {
diff --git a/intern/opensubdiv/internal/opensubdiv_evaluator_internal.h b/intern/opensubdiv/internal/opensubdiv_evaluator_internal.h
index cc69db6abc6..fdb3e27c55a 100644
--- a/intern/opensubdiv/internal/opensubdiv_evaluator_internal.h
+++ b/intern/opensubdiv/internal/opensubdiv_evaluator_internal.h
@@ -97,6 +97,15 @@ class CpuEvalOutputAPI {
float face_u, float face_v,
float P[3], float dPdu[3], float dPdv[3]);
+ void evaluateLimit2(const int ptex_face_index,
+ float face_u, float face_v,
+ float P[3],
+ float dPdu[3],
+ float dPdv[3],
+ float dPduu[3],
+ float dPduv[3],
+ float dPdvv[3]);
+
// Evaluate varying data at a given bilinear coordinate of given ptex face.
void evaluateVarying(const int ptes_face_index,
float face_u, float face_v,
diff --git a/intern/opensubdiv/opensubdiv_evaluator_capi.h b/intern/opensubdiv/opensubdiv_evaluator_capi.h
index 07a55cfd349..7650cb31079 100644
--- a/intern/opensubdiv/opensubdiv_evaluator_capi.h
+++ b/intern/opensubdiv/opensubdiv_evaluator_capi.h
@@ -86,6 +86,16 @@ typedef struct OpenSubdiv_Evaluator {
float face_u, float face_v,
float P[3], float dPdu[3], float dPdv[3]);
+ void (*evaluateLimit2)(struct OpenSubdiv_Evaluator* evaluator,
+ const int ptex_face_index,
+ float face_u, float face_v,
+ float P[3],
+ float dPdu[3],
+ float dPdv[3],
+ float dPduu[3],
+ float dPduv[3],
+ float dPdvv[3]);
+
// Evaluate varying data at a given bilinear coordinate of given ptex face.
void (*evaluateVarying)(struct OpenSubdiv_Evaluator* evaluator,
const int ptex_face_index,
diff --git a/source/blender/modifiers/intern/MOD_mybmesh.c b/source/blender/modifiers/intern/MOD_mybmesh.c
index 57b76283c38..5ef6eb148d5 100644
--- a/source/blender/modifiers/intern/MOD_mybmesh.c
+++ b/source/blender/modifiers/intern/MOD_mybmesh.c
@@ -67,11 +67,13 @@
#include "opensubdiv_capi.h"
#include "opensubdiv_converter_capi.h"
+#include "opensubdiv_evaluator_capi.h"
+#include "opensubdiv_topology_refiner_capi.h"
#include "PIL_time.h"
#include "PIL_time_utildefines.h"
-struct OpenSubdiv_EvaluatorDescr;
+struct OpenSubdiv_Evaluator;
typedef struct {
BMVert *vert;
@@ -132,14 +134,14 @@ typedef struct {
//are we in the cusp insertion step
bool is_cusp;
- struct OpenSubdiv_EvaluatorDescr *eval;
+ struct OpenSubdiv_Evaluator *eval;
} MeshData;
//TODO for Kr look in subdiv.cpp in coutours source code (II)
//TODO dynamic arrays, use BLI_stack, BLI_buffer, BLI_mempool, BLI_memarena.
-static void verts_to_limit(BMesh *bm, struct OpenSubdiv_EvaluatorDescr *eval){
+static void verts_to_limit(BMesh *bm, struct OpenSubdiv_Evaluator *eval){
int i, j;
@@ -167,7 +169,7 @@ static void verts_to_limit(BMesh *bm, struct OpenSubdiv_EvaluatorDescr *eval){
u = v = 0;
break;
}
- openSubdiv_evaluateLimit(eval, i, u, v, vert->co, du, dv);
+ eval->evaluateLimit(eval, i, u, v, vert->co, du, dv);
//Adjust vert normal to the limit normal
cross_v3_v3v3(vert->no, du, dv);
normalize_v3(vert->no);
@@ -429,11 +431,11 @@ static void split_BB_FF_edges(MeshData *m_d) {
{
float P1[3], P2[3], du[3], dv[3];
//is this a FF or BB edge?
- openSubdiv_evaluateLimit(m_d->eval, face_index, v1_u, v1_v, P1, du, dv);
+ m_d->eval->evaluateLimit(m_d->eval, face_index, v1_u, v1_v, P1, du, dv);
is_B = calc_if_B(m_d->cam_loc, P1, du, dv);
- openSubdiv_evaluateLimit(m_d->eval, face_index, v2_u, v2_v, P2, du, dv);
+ m_d->eval->evaluateLimit(m_d->eval, face_index, v2_u, v2_v, P2, du, dv);
if( is_B != calc_if_B(m_d->cam_loc, P2, du, dv) ){
//FB edge, we only want to split FF or BB
@@ -452,7 +454,7 @@ static void split_BB_FF_edges(MeshData *m_d) {
for(i=0; i < 10; i++){
v = step_arr[i];
- openSubdiv_evaluateLimit(m_d->eval, face_index, u, v, P, du, dv);
+ m_d->eval->evaluateLimit(m_d->eval, face_index, u, v, P, du, dv);
if( calc_if_B(m_d->cam_loc, P, du, dv) != is_B ){
split_edge_and_move_vert(m_d->bm, e, P, du, dv);
v_buf.u = u;
@@ -466,7 +468,7 @@ static void split_BB_FF_edges(MeshData *m_d) {
for(i=0; i < 10; i++){
u = step_arr[i];
- openSubdiv_evaluateLimit(m_d->eval, face_index, u, v, P, du, dv);
+ m_d->eval->evaluateLimit(m_d->eval, face_index, u, v, P, du, dv);
if( calc_if_B(m_d->cam_loc, P, du, dv) != is_B ){
split_edge_and_move_vert(m_d->bm, e, P, du, dv);
v_buf.u = u;
@@ -490,7 +492,7 @@ static void split_BB_FF_edges(MeshData *m_d) {
}
v = step_arr[i];
- openSubdiv_evaluateLimit(m_d->eval, face_index, u, v, P, du, dv);
+ m_d->eval->evaluateLimit(m_d->eval, face_index, u, v, P, du, dv);
if( calc_if_B(m_d->cam_loc, P, du, dv) != is_B ){
split_edge_and_move_vert(m_d->bm, e, P, du, dv);
v_
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list