Cleanup: Subdiv: Remove common_ prefix
[blender.git] / source / blender / blenkernel / BKE_subdiv_eval.hh
blob6cbb030b3b613dd9bca9d30eb1b729e08302267e
1 /* SPDX-FileCopyrightText: 2018 Blender Authors
3 * SPDX-License-Identifier: GPL-2.0-or-later */
5 /** \file
6 * \ingroup bke
7 */
9 #pragma once
11 #include "BLI_math_vector_types.hh"
12 #include "BLI_span.hh"
14 struct Mesh;
15 struct OpenSubdiv_EvaluatorCache;
16 struct OpenSubdiv_EvaluatorSettings;
18 namespace blender::bke::subdiv {
20 struct Subdiv;
22 enum eSubdivEvaluatorType {
23 SUBDIV_EVALUATOR_TYPE_CPU,
24 SUBDIV_EVALUATOR_TYPE_GPU,
27 /* Returns true if evaluator is ready for use. */
28 bool eval_begin(Subdiv *subdiv,
29 eSubdivEvaluatorType evaluator_type,
30 OpenSubdiv_EvaluatorCache *evaluator_cache,
31 const OpenSubdiv_EvaluatorSettings *settings);
33 /* coarse_vertex_cos is an optional argument which allows to override coordinates of the coarse
34 * mesh. */
35 bool eval_begin_from_mesh(Subdiv *subdiv,
36 const Mesh *mesh,
37 Span<float3> coarse_vert_positions,
38 eSubdivEvaluatorType evaluator_type,
39 OpenSubdiv_EvaluatorCache *evaluator_cache);
40 bool eval_refine_from_mesh(Subdiv *subdiv, const Mesh *mesh, Span<float3> coarse_vert_positions);
42 /* Makes sure displacement evaluator is initialized.
44 * NOTE: This function must be called once before evaluating displacement or
45 * final surface position. */
46 void eval_init_displacement(Subdiv *subdiv);
48 /* Single point queries. */
50 /* Evaluate point at a limit surface, with optional derivatives and normal. */
52 void eval_limit_point(Subdiv *subdiv, int ptex_face_index, float u, float v, float r_P[3]);
53 void eval_limit_point_and_derivatives(Subdiv *subdiv,
54 int ptex_face_index,
55 float u,
56 float v,
57 float r_P[3],
58 float r_dPdu[3],
59 float r_dPdv[3]);
60 void eval_limit_point_and_normal(
61 Subdiv *subdiv, int ptex_face_index, float u, float v, float r_P[3], float r_N[3]);
63 /* Evaluate smoothly interpolated vertex data (such as ORCO). */
64 void eval_vertex_data(Subdiv *subdiv,
65 const int ptex_face_index,
66 const float u,
67 const float v,
68 float r_vertex_data[]);
70 /* Evaluate face-varying layer (such as UV). */
71 void eval_face_varying(Subdiv *subdiv,
72 int face_varying_channel,
73 int ptex_face_index,
74 float u,
75 float v,
76 float r_face_varying[2]);
78 /* NOTE: Expects derivatives to be correct.
80 * TODO(sergey): This is currently used together with
81 * eval_final_point() which can easily evaluate derivatives.
82 * Would be nice to have displacement evaluation function which does not require
83 * knowing derivatives ahead of a time. */
84 void eval_displacement(Subdiv *subdiv,
85 int ptex_face_index,
86 float u,
87 float v,
88 const float dPdu[3],
89 const float dPdv[3],
90 float r_D[3]);
92 /* Evaluate point on a limit surface with displacement applied to it. */
93 void eval_final_point(Subdiv *subdiv, int ptex_face_index, float u, float v, float r_P[3]);
95 } // namespace blender::bke::subdiv