Blender V5.3
sculpt_cloth.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
11#include "BLI_array.hh"
12#include "BLI_index_mask_fwd.hh"
13#include "BLI_map.hh"
15#include "BLI_vector.hh"
16
17#include "BKE_collision.h"
18
19namespace blender {
20
21struct Brush;
22struct Sculpt;
23struct SculptSession;
24namespace bke::pbvh {
25class Node;
26}
27
29
30/* Cloth Simulation. */
32 /* Constraints were not built for this node, so it can't be simulated. */
34
35 /* There are constraints for the geometry in this node, but it should not be simulated. */
37
38 /* There are constraints for this node and they should be used by the solver. */
40};
41
43 /* Constraint that creates the structure of the cloth. */
45 /* Constraint that references the position of a vertex and a position in deformation_pos which
46 * can be deformed by the tools. */
48 /* Constraint that references the vertex position and a editable soft-body position for
49 * plasticity. */
51 /* Constraint that references the vertex position and its initial position. */
53};
54
56 /* Elements that are affected by the constraint. */
57 /* Element a should always be a mesh vertex with the index stored in elem_index_a as it is always
58 * deformed. Element b could be another vertex of the same mesh or any other position (arbitrary
59 * point, position for a previous state). In that case, elem_index_a and elem_index_b should be
60 * the same to avoid affecting two different vertices when solving the constraints.
61 * *elem_position points to the position which is owned by the element. */
64
67
68 float length;
69 float strength;
70
71 /* Index in #SimulationData.node_state of the node from where this constraint was created.
72 * This constraints will only be used by the solver if the state is active. */
73 int node;
74
76};
77
108
109/* Public functions. */
110
111std::unique_ptr<SimulationData> brush_simulation_create(const Depsgraph &depsgraph,
112 Object &ob,
113 float cloth_mass,
114 float cloth_damping,
115 float cloth_softbody_strength,
116 bool use_collisions,
117 bool needs_deform_coords);
118
119void sim_activate_nodes(Object &object, SimulationData &cloth_sim, const IndexMask &node_mask);
120
121void brush_store_simulation_state(const Depsgraph &depsgraph,
122 const Object &object,
123 SimulationData &cloth_sim);
124
125void do_simulation_step(const Depsgraph &depsgraph,
126 const Sculpt &sd,
127 Object &ob,
128 SimulationData &cloth_sim,
129 const IndexMask &node_mask);
130
131void ensure_nodes_constraints(const Sculpt &sd,
132 Object &ob,
133 const IndexMask &node_mask,
134 SimulationData &cloth_sim,
135 const float3 &initial_location,
136 float radius);
137
141void simulation_limits_draw(uint gpuattr,
142 const Brush &brush,
143 const float location[3],
144 const float normal[3],
145 float rds,
146 float line_width,
147 const float outline_col[3],
148 float alpha);
150 Brush &brush,
151 SculptSession &ss,
152 const float outline_col[3],
153 float outline_alpha);
154
156 const Brush &brush,
157 IndexMaskMemory &memory);
158
159void do_cloth_brush(const Depsgraph &depsgraph,
160 const Sculpt &sd,
161 Object &object,
162 const IndexMask &node_mask);
163
165
166} // namespace ed::sculpt_paint::cloth
167
168} // namespace blender
bool is_cloth_deform_brush(const Brush &brush)
void brush_store_simulation_state(const Depsgraph &depsgraph, const Object &object, SimulationData &cloth_sim)
void ensure_nodes_constraints(const Sculpt &sd, Object &object, const IndexMask &node_mask, SimulationData &cloth_sim, const float3 &initial_location, const float radius)
void sim_activate_nodes(Object &object, SimulationData &cloth_sim, const IndexMask &node_mask)
IndexMask brush_affected_nodes_gather(const Object &object, const Brush &brush, IndexMaskMemory &memory)
void plane_falloff_preview_draw(const uint gpuattr, Brush &brush, SculptSession &ss, const float outline_col[3], float outline_alpha)
void do_simulation_step(const Depsgraph &depsgraph, const Sculpt &sd, Object &object, SimulationData &cloth_sim, const IndexMask &node_mask)
void simulation_limits_draw(const uint gpuattr, const Brush &brush, const float location[3], const float normal[3], const float rds, const float line_width, const float outline_col[3], const float alpha)
std::unique_ptr< SimulationData > brush_simulation_create(const Depsgraph &depsgraph, Object &ob, const float cloth_mass, const float cloth_damping, const float cloth_softbody_strength, const bool use_collisions, const bool needs_deform_coords)
void do_cloth_brush(const Depsgraph &depsgraph, const Sculpt &sd, Object &ob, const IndexMask &node_mask)
BMesh Iterators.
unsigned int uint
Definition BKE_text.h:55
VecBase< float, 3 > float3
Map< const bke::pbvh::Node *, int > node_state_index