1 /* SPDX-FileCopyrightText: 2018 Blender Authors
3 * SPDX-License-Identifier: GPL-2.0-or-later */
11 #include "BLI_math_vector_types.hh"
12 #include "BLI_span.hh"
15 struct OpenSubdiv_EvaluatorCache
;
16 struct OpenSubdiv_EvaluatorSettings
;
18 namespace blender::bke::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
35 bool eval_begin_from_mesh(Subdiv
*subdiv
,
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
,
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
,
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
,
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
,
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