Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenkernel/BKE_subdiv.h')
-rw-r--r--source/blender/blenkernel/BKE_subdiv.h73
1 files changed, 65 insertions, 8 deletions
diff --git a/source/blender/blenkernel/BKE_subdiv.h b/source/blender/blenkernel/BKE_subdiv.h
index c4628cb9da7..887eff6e7dc 100644
--- a/source/blender/blenkernel/BKE_subdiv.h
+++ b/source/blender/blenkernel/BKE_subdiv.h
@@ -29,9 +29,12 @@
#include "BLI_sys_types.h"
struct Mesh;
+struct MultiresModifierData;
+struct Object;
struct OpenSubdiv_Converter;
struct OpenSubdiv_Evaluator;
struct OpenSubdiv_TopologyRefiner;
+struct Subdiv;
/** \file BKE_subdiv.h
* \ingroup bke
@@ -92,22 +95,47 @@ typedef struct SubdivStats {
double begin_timestamp_[NUM_SUBDIV_STATS_VALUES];
} SubdivStats;
+/* Functor which evaluates dispalcement at a given (u, v) of given ptex face. */
+typedef struct SubdivDisplacement {
+ /* Return displacement which is to be added to the original coordinate.
+ *
+ * NOTE: This function is supposed to return "continuous" displacement for
+ * each pf PTex faces created for special (non-quad) polygon. This means,
+ * if displacement is stored on per-corner manner (like MDisps for multires)
+ * this is up the displacement implementation to average boundaries of the
+ * displacement grids if needed.
+ *
+ * Averaging of displacement for vertices created for over coarse vertices
+ * and edges is done by subdiv code.
+ */
+ void (*eval_displacement)(struct SubdivDisplacement *displacement,
+ const int ptex_face_index,
+ const float u, const float v,
+ const float dPdu[3], const float dPdv[3],
+ float r_D[3]);
+
+ /* Free the data, not the evaluator itself. */
+ void (*free)(struct SubdivDisplacement *displacement);
+
+ void *user_data;
+} SubdivDisplacement;
+
typedef struct Subdiv {
/* Settings this subdivision surface is created for.
*
* It is read-only after assignment in BKE_subdiv_new_from_FOO().
*/
SubdivSettings settings;
-
/* Topology refiner includes all the glue logic to feed Blender side
* topology to OpenSubdiv. It can be shared by both evaluator and GL mesh
* drawer.
*/
struct OpenSubdiv_TopologyRefiner *topology_refiner;
-
/* CPU side evaluator. */
struct OpenSubdiv_Evaluator *evaluator;
-
+ /* Optional displacement evaluator. */
+ struct SubdivDisplacement *displacement_evaluator;
+ /* Statistics for debugging. */
SubdivStats stats;
} Subdiv;
@@ -148,29 +176,49 @@ void BKE_subdiv_eval_limit_point(
Subdiv *subdiv,
const int ptex_face_index,
const float u, const float v,
- float P[3]);
+ float r_P[3]);
void BKE_subdiv_eval_limit_point_and_derivatives(
Subdiv *subdiv,
const int ptex_face_index,
const float u, const float v,
- float P[3], float dPdu[3], float dPdv[3]);
+ float r_P[3], float r_dPdu[3], float r_dPdv[3]);
void BKE_subdiv_eval_limit_point_and_normal(
Subdiv *subdiv,
const int ptex_face_index,
const float u, const float v,
- float P[3], float N[3]);
+ float r_P[3], float r_N[3]);
void BKE_subdiv_eval_limit_point_and_short_normal(
Subdiv *subdiv,
const int ptex_face_index,
const float u, const float v,
- float P[3], short N[3]);
+ float r_P[3], short r_N[3]);
void BKE_subdiv_eval_face_varying(
Subdiv *subdiv,
const int face_varying_channel,
const int ptex_face_index,
const float u, const float v,
- float varying[2]);
+ float r_varying[2]);
+
+/* NOTE: Expects derivatives to be correct.
+ *
+ * TODO(sergey): This is currently used together with
+ * BKE_subdiv_eval_final_point() which cas easily evaluate derivatives.
+ * Would be nice to have dispalcement evaluation function which does not require
+ * knowing derivatives ahead of a time.
+ */
+void BKE_subdiv_eval_displacement(
+ Subdiv *subdiv,
+ const int ptex_face_index,
+ const float u, const float v,
+ const float dPdu[3], const float dPdv[3],
+ float r_D[3]);
+
+void BKE_subdiv_eval_final_point(
+ Subdiv *subdiv,
+ const int ptex_face_index,
+ const float u, const float v,
+ float r_P[3]);
/* Patch queries at given resolution.
*
@@ -220,4 +268,13 @@ struct Mesh *BKE_subdiv_to_mesh(
const SubdivToMeshSettings *settings,
const struct Mesh *coarse_mesh);
+/* ============================ DISPLACEMENT API ============================ */
+
+void BKE_subdiv_displacement_attach_from_multires(
+ Subdiv *subdiv,
+ const struct Object *object,
+ const struct MultiresModifierData *mmd);
+
+void BKE_subdiv_displacement_detach(Subdiv *subdiv);
+
#endif /* __BKE_SUBDIV_H__ */