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:
authorSergey Sharybin <sergey.vfx@gmail.com>2018-08-14 18:05:54 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2018-08-15 16:40:08 +0300
commit913b8396d971f258df70827274bcdf86dd894185 (patch)
tree56b0a0f53752ed26da0ea1580a26bfe41490310d /source/blender/blenkernel/intern/subdiv_eval.c
parent5a89dfe06baa2ab96947bb6b5f6c63c4b864fab2 (diff)
Multires: Initial groundwork to hook up displacement to new Subdiv object
Adds a displacement support for OpenSubdiov based subsurf object implemented as a callback which gives vector displacement in object space. Currently is implemented to calculate displacement based on myltires displacement grids, but we can support things in the future if needed. Submitting to review to see if there is something obviously wrong in the direction (old multires code was sharing same displacement code to both calculate final displaced mesh and reshape an existing one, which is rather confusing and probably can be done more cleanly?). Reviewers: brecht Reviewed By: brecht Differential Revision: https://developer.blender.org/D3604
Diffstat (limited to 'source/blender/blenkernel/intern/subdiv_eval.c')
-rw-r--r--source/blender/blenkernel/intern/subdiv_eval.c66
1 files changed, 53 insertions, 13 deletions
diff --git a/source/blender/blenkernel/intern/subdiv_eval.c b/source/blender/blenkernel/intern/subdiv_eval.c
index e3754655ea6..7b234683102 100644
--- a/source/blender/blenkernel/intern/subdiv_eval.c
+++ b/source/blender/blenkernel/intern/subdiv_eval.c
@@ -164,53 +164,53 @@ 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])
{
BKE_subdiv_eval_limit_point_and_derivatives(subdiv,
ptex_face_index,
u, v,
- P, NULL, NULL);
+ r_P, NULL, NULL);
}
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])
{
subdiv->evaluator->evaluateLimit(subdiv->evaluator,
ptex_face_index,
u, v,
- P, dPdu, dPdv);
+ r_P, r_dPdu, r_dPdv);
}
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])
{
float dPdu[3], dPdv[3];
BKE_subdiv_eval_limit_point_and_derivatives(subdiv,
ptex_face_index,
u, v,
- P, dPdu, dPdv);
- cross_v3_v3v3(N, dPdu, dPdv);
- normalize_v3(N);
+ r_P, dPdu, dPdv);
+ cross_v3_v3v3(r_N, dPdu, dPdv);
+ normalize_v3(r_N);
}
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])
{
float N_float[3];
BKE_subdiv_eval_limit_point_and_normal(subdiv,
ptex_face_index,
u, v,
- P, N_float);
- normal_float_to_short_v3(N, N_float);
+ r_P, N_float);
+ normal_float_to_short_v3(r_N, N_float);
}
void BKE_subdiv_eval_face_varying(
@@ -218,13 +218,53 @@ void BKE_subdiv_eval_face_varying(
const int face_varying_channel,
const int ptex_face_index,
const float u, const float v,
- float face_varying[2])
+ float r_face_varying[2])
{
subdiv->evaluator->evaluateFaceVarying(subdiv->evaluator,
face_varying_channel,
ptex_face_index,
u, v,
- face_varying);
+ r_face_varying);
+}
+
+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])
+{
+ if (subdiv->displacement_evaluator == NULL) {
+ zero_v3(r_D);
+ return;
+ }
+ subdiv->displacement_evaluator->eval_displacement(
+ subdiv->displacement_evaluator,
+ ptex_face_index,
+ u, v,
+ dPdu, dPdv,
+ r_D);
+}
+
+void BKE_subdiv_eval_final_point(
+ Subdiv *subdiv,
+ const int ptex_face_index,
+ const float u, const float v,
+ float r_P[3])
+{
+ if (subdiv->displacement_evaluator) {
+ float dPdu[3], dPdv[3], D[3];
+ BKE_subdiv_eval_limit_point_and_derivatives(
+ subdiv, ptex_face_index, u, v, r_P, dPdu, dPdv);
+ BKE_subdiv_eval_displacement(subdiv,
+ ptex_face_index, u, v,
+ dPdu, dPdv,
+ D);
+ add_v3_v3(r_P, D);
+ }
+ else {
+ BKE_subdiv_eval_limit_point(subdiv, ptex_face_index, u, v, r_P);
+ }
}
/* =================== Patch queries at given resolution =================== */