Merge branch 'refactor-mesh-position-generic' into refactor-mesh-corners-generic
This commit is contained in:
commit
3a81f0a978
|
@ -58,7 +58,7 @@ ccl_device_noinline void motion_triangle_shader_setup(KernelGlobals kg,
|
|||
sd->P = motion_triangle_point_from_uv(kg, sd, isect_object, isect_prim, sd->u, sd->v, verts);
|
||||
/* Compute face normal. */
|
||||
float3 Ng;
|
||||
if (sd->object_flag & SD_OBJECT_NEGATIVE_SCALE_APPLIED) {
|
||||
if (object_negative_scale_applied(sd->object_flag)) {
|
||||
Ng = normalize(cross(verts[2] - verts[0], verts[1] - verts[0]));
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -201,6 +201,11 @@ ccl_device_inline void object_normal_transform(KernelGlobals kg,
|
|||
*N = normalize(transform_direction_transposed(&tfm, *N));
|
||||
}
|
||||
|
||||
ccl_device_inline bool object_negative_scale_applied(const int object_flag)
|
||||
{
|
||||
return ((object_flag & SD_OBJECT_NEGATIVE_SCALE) && (object_flag & SD_OBJECT_TRANSFORM_APPLIED));
|
||||
}
|
||||
|
||||
/* Transform direction vector from object to world space */
|
||||
|
||||
ccl_device_inline void object_dir_transform(KernelGlobals kg,
|
||||
|
|
|
@ -21,7 +21,7 @@ ccl_device_inline float3 triangle_normal(KernelGlobals kg, ccl_private ShaderDat
|
|||
const float3 v2 = kernel_data_fetch(tri_verts, tri_vindex.w + 2);
|
||||
|
||||
/* return normal */
|
||||
if (sd->object_flag & SD_OBJECT_NEGATIVE_SCALE_APPLIED) {
|
||||
if (object_negative_scale_applied(sd->object_flag)) {
|
||||
return normalize(cross(v2 - v0, v1 - v0));
|
||||
}
|
||||
else {
|
||||
|
@ -50,7 +50,7 @@ ccl_device_inline void triangle_point_normal(KernelGlobals kg,
|
|||
/* get object flags */
|
||||
int object_flag = kernel_data_fetch(object_flag, object);
|
||||
/* compute normal */
|
||||
if (object_flag & SD_OBJECT_NEGATIVE_SCALE_APPLIED) {
|
||||
if (object_negative_scale_applied(object_flag)) {
|
||||
*Ng = normalize(cross(v2 - v0, v1 - v0));
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -176,8 +176,9 @@ ccl_device_forceinline void mnee_setup_manifold_vertex(KernelGlobals kg,
|
|||
|
||||
/* Geometric normal. */
|
||||
vtx->ng = normalize(cross(dp_du, dp_dv));
|
||||
if (sd_vtx->object_flag & SD_OBJECT_NEGATIVE_SCALE_APPLIED)
|
||||
if (sd_vtx->object_flag & SD_OBJECT_NEGATIVE_SCALE) {
|
||||
vtx->ng = -vtx->ng;
|
||||
}
|
||||
|
||||
/* Shading normals: Interpolate normals between vertices. */
|
||||
float n_len;
|
||||
|
|
|
@ -120,7 +120,7 @@ ccl_device_inline bool subsurface_disk(KernelGlobals kg,
|
|||
if (path_flag & PATH_RAY_SUBSURFACE_BACKFACING) {
|
||||
hit_Ng = -hit_Ng;
|
||||
}
|
||||
if (object_flag & SD_OBJECT_NEGATIVE_SCALE_APPLIED) {
|
||||
if (object_negative_scale_applied(object_flag)) {
|
||||
hit_Ng = -hit_Ng;
|
||||
}
|
||||
|
||||
|
|
|
@ -223,11 +223,16 @@ ccl_device bool compute_emitter_centroid_and_dir(KernelGlobals kg,
|
|||
triangle_world_space_vertices(kg, object, prim_id, -1.0f, vertices);
|
||||
centroid = (vertices[0] + vertices[1] + vertices[2]) / 3.0f;
|
||||
|
||||
if (kemitter->emission_sampling == EMISSION_SAMPLING_FRONT) {
|
||||
const bool is_front_only = (kemitter->emission_sampling == EMISSION_SAMPLING_FRONT);
|
||||
const bool is_back_only = (kemitter->emission_sampling == EMISSION_SAMPLING_BACK);
|
||||
if (is_front_only || is_back_only) {
|
||||
dir = safe_normalize(cross(vertices[1] - vertices[0], vertices[2] - vertices[0]));
|
||||
}
|
||||
else if (kemitter->emission_sampling == EMISSION_SAMPLING_BACK) {
|
||||
dir = -safe_normalize(cross(vertices[1] - vertices[0], vertices[2] - vertices[0]));
|
||||
if (is_back_only) {
|
||||
dir = -dir;
|
||||
}
|
||||
if (kernel_data_fetch(object_flag, object) & SD_OBJECT_NEGATIVE_SCALE) {
|
||||
dir = -dir;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* Double-sided: any vector in the plane. */
|
||||
|
|
|
@ -146,7 +146,7 @@ ccl_device_forceinline bool triangle_light_sample(KernelGlobals kg,
|
|||
|
||||
/* flip normal if necessary */
|
||||
const int object_flag = kernel_data_fetch(object_flag, object);
|
||||
if (object_flag & SD_OBJECT_NEGATIVE_SCALE_APPLIED) {
|
||||
if (object_flag & SD_OBJECT_NEGATIVE_SCALE) {
|
||||
ls->Ng = -ls->Ng;
|
||||
}
|
||||
ls->eval_fac = 1.0f;
|
||||
|
|
|
@ -224,7 +224,7 @@ ccl_device float3 svm_bevel(
|
|||
float3 hit_Ng = isect.Ng[hit];
|
||||
int object = isect.hits[hit].object;
|
||||
int object_flag = kernel_data_fetch(object_flag, object);
|
||||
if (object_flag & SD_OBJECT_NEGATIVE_SCALE_APPLIED) {
|
||||
if (object_negative_scale_applied(object_flag)) {
|
||||
hit_Ng = -hit_Ng;
|
||||
}
|
||||
|
||||
|
|
|
@ -850,8 +850,8 @@ enum ShaderDataObjectFlag {
|
|||
SD_OBJECT_MOTION = (1 << 1),
|
||||
/* Vertices have transform applied. */
|
||||
SD_OBJECT_TRANSFORM_APPLIED = (1 << 2),
|
||||
/* Vertices have negative scale applied. */
|
||||
SD_OBJECT_NEGATIVE_SCALE_APPLIED = (1 << 3),
|
||||
/* The object's transform applies a negative scale. */
|
||||
SD_OBJECT_NEGATIVE_SCALE = (1 << 3),
|
||||
/* Object has a volume shader. */
|
||||
SD_OBJECT_HAS_VOLUME = (1 << 4),
|
||||
/* Object intersects AABB of an object with volume shader. */
|
||||
|
@ -873,7 +873,7 @@ enum ShaderDataObjectFlag {
|
|||
SD_OBJECT_CAUSTICS = (SD_OBJECT_CAUSTICS_CASTER | SD_OBJECT_CAUSTICS_RECEIVER),
|
||||
|
||||
SD_OBJECT_FLAGS = (SD_OBJECT_HOLDOUT_MASK | SD_OBJECT_MOTION | SD_OBJECT_TRANSFORM_APPLIED |
|
||||
SD_OBJECT_NEGATIVE_SCALE_APPLIED | SD_OBJECT_HAS_VOLUME |
|
||||
SD_OBJECT_NEGATIVE_SCALE | SD_OBJECT_HAS_VOLUME |
|
||||
SD_OBJECT_INTERSECTS_VOLUME | SD_OBJECT_SHADOW_CATCHER |
|
||||
SD_OBJECT_HAS_VOLUME_ATTRIBUTES | SD_OBJECT_CAUSTICS |
|
||||
SD_OBJECT_HAS_VOLUME_MOTION)
|
||||
|
|
|
@ -211,6 +211,11 @@ bool OIIOImageLoader::load_pixels(const ImageMetaData &metadata,
|
|||
if (strcmp(in->format_name(), "dds") == 0) {
|
||||
do_associate_alpha = true;
|
||||
}
|
||||
/* Workaround OIIO bug that sets oiio:UnassociatedAlpha on the last layer
|
||||
* but not composite image that we read. */
|
||||
if (strcmp(in->format_name(), "psd") == 0) {
|
||||
do_associate_alpha = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -94,14 +94,17 @@ LightTreePrimitive::LightTreePrimitive(Scene *scene, int prim_id, int object_id)
|
|||
* seems to work fine */
|
||||
centroid = (vertices[0] + vertices[1] + vertices[2]) / 3.0f;
|
||||
|
||||
if (shader->emission_sampling == EMISSION_SAMPLING_FRONT) {
|
||||
/* Front only. */
|
||||
const bool is_front_only = (shader->emission_sampling == EMISSION_SAMPLING_FRONT);
|
||||
const bool is_back_only = (shader->emission_sampling == EMISSION_SAMPLING_BACK);
|
||||
if (is_front_only || is_back_only) {
|
||||
/* One-sided. */
|
||||
bcone.axis = safe_normalize(cross(vertices[1] - vertices[0], vertices[2] - vertices[0]));
|
||||
bcone.theta_o = 0;
|
||||
}
|
||||
else if (shader->emission_sampling == EMISSION_SAMPLING_BACK) {
|
||||
/* Back only. */
|
||||
bcone.axis = -safe_normalize(cross(vertices[1] - vertices[0], vertices[2] - vertices[0]));
|
||||
if (is_back_only) {
|
||||
bcone.axis = -bcone.axis;
|
||||
}
|
||||
if (transform_negative_scale(object->get_tfm())) {
|
||||
bcone.axis = -bcone.axis;
|
||||
}
|
||||
bcone.theta_o = 0;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -435,6 +435,10 @@ void ObjectManager::device_update_object_transform(UpdateObjectTransformState *s
|
|||
state->have_motion = true;
|
||||
}
|
||||
|
||||
if (transform_negative_scale(tfm)) {
|
||||
flag |= SD_OBJECT_NEGATIVE_SCALE;
|
||||
}
|
||||
|
||||
if (geom->geometry_type == Geometry::MESH || geom->geometry_type == Geometry::POINTCLOUD) {
|
||||
/* TODO: why only mesh? */
|
||||
Mesh *mesh = static_cast<Mesh *>(geom);
|
||||
|
@ -970,8 +974,6 @@ void ObjectManager::apply_static_transforms(DeviceScene *dscene, Scene *scene, P
|
|||
}
|
||||
|
||||
object_flag[i] |= SD_OBJECT_TRANSFORM_APPLIED;
|
||||
if (geom->transform_negative_scaled)
|
||||
object_flag[i] |= SD_OBJECT_NEGATIVE_SCALE_APPLIED;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,9 @@ void util_cdf_invert(const int resolution,
|
|||
const bool make_symmetric,
|
||||
vector<float> &inv_cdf)
|
||||
{
|
||||
assert(cdf[0] == 0.0f && cdf[resolution] == 1.0f);
|
||||
const int cdf_size = cdf.size();
|
||||
assert(cdf[0] == 0.0f && cdf[cdf_size - 1] == 1.0f);
|
||||
|
||||
const float inv_resolution = 1.0f / (float)resolution;
|
||||
const float range = to - from;
|
||||
inv_cdf.resize(resolution);
|
||||
|
@ -26,12 +28,12 @@ void util_cdf_invert(const int resolution,
|
|||
float x = i / (float)half_size;
|
||||
int index = upper_bound(cdf.begin(), cdf.end(), x) - cdf.begin();
|
||||
float t;
|
||||
if (index < cdf.size() - 1) {
|
||||
if (index < cdf_size - 1) {
|
||||
t = (x - cdf[index]) / (cdf[index + 1] - cdf[index]);
|
||||
}
|
||||
else {
|
||||
t = 0.0f;
|
||||
index = cdf.size() - 1;
|
||||
index = cdf_size - 1;
|
||||
}
|
||||
float y = ((index + t) / (resolution - 1)) * (2.0f * range);
|
||||
inv_cdf[half_size + i] = 0.5f * (1.0f + y);
|
||||
|
@ -43,7 +45,7 @@ void util_cdf_invert(const int resolution,
|
|||
float x = (i + 0.5f) * inv_resolution;
|
||||
int index = upper_bound(cdf.begin(), cdf.end(), x) - cdf.begin() - 1;
|
||||
float t;
|
||||
if (index < cdf.size() - 1) {
|
||||
if (index < cdf_size - 1) {
|
||||
t = (x - cdf[index]) / (cdf[index + 1] - cdf[index]);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -122,7 +122,7 @@ BVHTree *bvhtree_from_editmesh_verts_ex(BVHTreeFromEditMesh *data,
|
|||
* (else will be computed from mask).
|
||||
*/
|
||||
BVHTree *bvhtree_from_mesh_verts_ex(struct BVHTreeFromMesh *data,
|
||||
const float (*positions)[3],
|
||||
const float (*vert_positions)[3],
|
||||
int verts_num,
|
||||
const blender::BitVector<> &verts_mask,
|
||||
int verts_num_active,
|
||||
|
@ -153,7 +153,7 @@ BVHTree *bvhtree_from_editmesh_edges_ex(BVHTreeFromEditMesh *data,
|
|||
* (else will be computed from mask).
|
||||
*/
|
||||
BVHTree *bvhtree_from_mesh_edges_ex(struct BVHTreeFromMesh *data,
|
||||
const float (*positions)[3],
|
||||
const float (*vert_positions)[3],
|
||||
const struct MEdge *edge,
|
||||
int edges_num,
|
||||
const blender::BitVector<> &edges_mask,
|
||||
|
@ -180,7 +180,7 @@ BVHTree *bvhtree_from_editmesh_looptri_ex(BVHTreeFromEditMesh *data,
|
|||
* Builds a BVH-tree where nodes are the looptri faces of the given mesh.
|
||||
*/
|
||||
BVHTree *bvhtree_from_mesh_looptri_ex(struct BVHTreeFromMesh *data,
|
||||
const float (*positions)[3],
|
||||
const float (*vert_positions)[3],
|
||||
const int *corner_verts,
|
||||
const struct MLoopTri *looptri,
|
||||
int looptri_num,
|
||||
|
|
|
@ -131,7 +131,9 @@ void BKE_keyblock_update_from_mesh(const struct Mesh *me, struct KeyBlock *kb);
|
|||
void BKE_keyblock_convert_from_mesh(const struct Mesh *me,
|
||||
const struct Key *key,
|
||||
struct KeyBlock *kb);
|
||||
void BKE_keyblock_convert_to_mesh(const struct KeyBlock *kb, float (*positions)[3], int totvert);
|
||||
void BKE_keyblock_convert_to_mesh(const struct KeyBlock *kb,
|
||||
float (*vert_positions)[3],
|
||||
int totvert);
|
||||
|
||||
/**
|
||||
* Computes normals (vertices, polygons and/or loops ones) of given mesh for given shape key.
|
||||
|
|
|
@ -730,7 +730,7 @@ bool BKE_mesh_center_of_volume(const struct Mesh *me, float r_cent[3]);
|
|||
* \param r_volume: Volume (unsigned).
|
||||
* \param r_center: Center of mass.
|
||||
*/
|
||||
void BKE_mesh_calc_volume(const float (*positions)[3],
|
||||
void BKE_mesh_calc_volume(const float (*vert_positions)[3],
|
||||
int mverts_num,
|
||||
const struct MLoopTri *mlooptri,
|
||||
int looptri_num,
|
||||
|
|
|
@ -32,7 +32,7 @@ void BKE_bmesh_prefair_and_fair_verts(struct BMesh *bm,
|
|||
/* This function can optionally use the vertex coordinates of deform_mverts to read and write the
|
||||
* fairing result. When NULL, the function will use mesh positions directly. */
|
||||
void BKE_mesh_prefair_and_fair_verts(struct Mesh *mesh,
|
||||
float (*deform_positions)[3],
|
||||
float (*deform_vert_positions)[3],
|
||||
bool *affect_verts,
|
||||
eMeshFairingDepth depth);
|
||||
|
||||
|
|
|
@ -257,7 +257,7 @@ void BKE_mesh_loop_islands_add(MeshIslandStore *island_store,
|
|||
int num_innercut_items,
|
||||
int *innercut_item_indices);
|
||||
|
||||
typedef bool (*MeshRemapIslandsCalc)(const float (*positions)[3],
|
||||
typedef bool (*MeshRemapIslandsCalc)(const float (*vert_positions)[3],
|
||||
int totvert,
|
||||
const struct MEdge *edges,
|
||||
int totedge,
|
||||
|
|
|
@ -157,14 +157,14 @@ void BKE_mesh_remap_calc_source_cddata_masks_from_map_modes(
|
|||
* in favor of a global good matching.
|
||||
*/
|
||||
float BKE_mesh_remap_calc_difference_from_mesh(const struct SpaceTransform *space_transform,
|
||||
const float (*positions_dst)[3],
|
||||
const float (*vert_positions_dst)[3],
|
||||
int numverts_dst,
|
||||
struct Mesh *me_src);
|
||||
|
||||
/**
|
||||
* Set r_space_transform so that best bbox of dst matches best bbox of src.
|
||||
*/
|
||||
void BKE_mesh_remap_find_best_match_from_mesh(const float (*positions_dst)[3],
|
||||
void BKE_mesh_remap_find_best_match_from_mesh(const float (*vert_positions_dst)[3],
|
||||
int numverts_dst,
|
||||
struct Mesh *me_src,
|
||||
struct SpaceTransform *r_space_transform);
|
||||
|
@ -173,7 +173,7 @@ void BKE_mesh_remap_calc_verts_from_mesh(int mode,
|
|||
const struct SpaceTransform *space_transform,
|
||||
float max_dist,
|
||||
float ray_radius,
|
||||
const float (*positions_dst)[3],
|
||||
const float (*vert_positions_dst)[3],
|
||||
int numverts_dst,
|
||||
bool dirty_nors_dst,
|
||||
struct Mesh *me_src,
|
||||
|
@ -184,7 +184,7 @@ void BKE_mesh_remap_calc_edges_from_mesh(int mode,
|
|||
const struct SpaceTransform *space_transform,
|
||||
float max_dist,
|
||||
float ray_radius,
|
||||
const float (*positions_dst)[3],
|
||||
const float (*vert_positions_dst)[3],
|
||||
int numverts_dst,
|
||||
const struct MEdge *edges_dst,
|
||||
int numedges_dst,
|
||||
|
@ -198,7 +198,7 @@ void BKE_mesh_remap_calc_loops_from_mesh(int mode,
|
|||
float max_dist,
|
||||
float ray_radius,
|
||||
struct Mesh *mesh_dst,
|
||||
const float (*positions_dst)[3],
|
||||
const float (*vert_positions_dst)[3],
|
||||
int numverts_dst,
|
||||
const struct MEdge *edges_dst,
|
||||
int numedges_dst,
|
||||
|
@ -221,7 +221,7 @@ void BKE_mesh_remap_calc_polys_from_mesh(int mode,
|
|||
float max_dist,
|
||||
float ray_radius,
|
||||
const struct Mesh *mesh_dst,
|
||||
const float (*positions_dst)[3],
|
||||
const float (*vert_positions_dst)[3],
|
||||
const int *corner_verts,
|
||||
const struct MPoly *polys_dst,
|
||||
int numpolys_dst,
|
||||
|
|
|
@ -690,7 +690,7 @@ void nodeRemoveNode(struct Main *bmain,
|
|||
|
||||
void nodeDimensionsGet(const struct bNode *node, float *r_width, float *r_height);
|
||||
void nodeTagUpdateID(struct bNode *node);
|
||||
void nodeInternalLinks(struct bNode *node, struct bNodeLink ***r_links, int *r_len);
|
||||
void nodeInternalLinks(struct bNode *node, struct bNodeLink **r_links, int *r_len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
|
|
|
@ -254,7 +254,7 @@ class bNodeRuntime : NonCopyable, NonMovable {
|
|||
float anim_ofsx;
|
||||
|
||||
/** List of cached internal links (input to output), for muted nodes and operators. */
|
||||
Vector<bNodeLink *> internal_links;
|
||||
Vector<bNodeLink> internal_links;
|
||||
|
||||
/** Eagerly maintained cache of the node's index in the tree. */
|
||||
int index_in_tree = -1;
|
||||
|
@ -626,7 +626,7 @@ inline bool bNode::is_group_output() const
|
|||
return this->type == NODE_GROUP_OUTPUT;
|
||||
}
|
||||
|
||||
inline blender::Span<const bNodeLink *> bNode::internal_links() const
|
||||
inline blender::Span<bNodeLink> bNode::internal_links() const
|
||||
{
|
||||
return this->runtime->internal_links;
|
||||
}
|
||||
|
|
|
@ -582,7 +582,7 @@ void psys_get_texture(struct ParticleSimulationData *sim,
|
|||
* Interpolate a location on a face based on face coordinates.
|
||||
*/
|
||||
void psys_interpolate_face(struct Mesh *mesh,
|
||||
const float (*positions)[3],
|
||||
const float (*vert_positions)[3],
|
||||
const float (*vert_normals)[3],
|
||||
struct MFace *mface,
|
||||
struct MTFace *tface,
|
||||
|
|
|
@ -764,7 +764,7 @@ void BKE_pbvh_parallel_range_settings(struct TaskParallelSettings *settings,
|
|||
bool use_threading,
|
||||
int totnode);
|
||||
|
||||
float (*BKE_pbvh_get_positions(const PBVH *pbvh))[3];
|
||||
float (*BKE_pbvh_get_vert_positions(const PBVH *pbvh))[3];
|
||||
const float (*BKE_pbvh_get_vert_normals(const PBVH *pbvh))[3];
|
||||
const bool *BKE_pbvh_get_vert_hide(const PBVH *pbvh);
|
||||
bool *BKE_pbvh_get_vert_hide_for_write(PBVH *pbvh);
|
||||
|
|
|
@ -62,7 +62,7 @@ void fill_mesh_from_openvdb_data(const Span<openvdb::Vec3s> vdb_verts,
|
|||
int vert_offset,
|
||||
int poly_offset,
|
||||
int loop_offset,
|
||||
MutableSpan<float3> positions,
|
||||
MutableSpan<float3> vert_positions,
|
||||
MutableSpan<MPoly> polys,
|
||||
MutableSpan<int> corner_verts);
|
||||
|
||||
|
|
|
@ -762,7 +762,7 @@ BVHTree *bvhtree_from_editmesh_verts(
|
|||
}
|
||||
|
||||
BVHTree *bvhtree_from_mesh_verts_ex(BVHTreeFromMesh *data,
|
||||
const float (*positions)[3],
|
||||
const float (*vert_positions)[3],
|
||||
const int verts_num,
|
||||
const BitVector<> &verts_mask,
|
||||
int verts_num_active,
|
||||
|
@ -771,14 +771,14 @@ BVHTree *bvhtree_from_mesh_verts_ex(BVHTreeFromMesh *data,
|
|||
int axis)
|
||||
{
|
||||
BVHTree *tree = bvhtree_from_mesh_verts_create_tree(
|
||||
epsilon, tree_type, axis, positions, verts_num, verts_mask, verts_num_active);
|
||||
epsilon, tree_type, axis, vert_positions, verts_num, verts_mask, verts_num_active);
|
||||
|
||||
bvhtree_balance(tree, false);
|
||||
|
||||
if (data) {
|
||||
/* Setup BVHTreeFromMesh */
|
||||
bvhtree_from_mesh_setup_data(
|
||||
tree, BVHTREE_FROM_VERTS, positions, nullptr, nullptr, nullptr, nullptr, data);
|
||||
tree, BVHTREE_FROM_VERTS, vert_positions, nullptr, nullptr, nullptr, nullptr, data);
|
||||
}
|
||||
|
||||
return tree;
|
||||
|
@ -896,7 +896,7 @@ BVHTree *bvhtree_from_editmesh_edges(
|
|||
}
|
||||
|
||||
BVHTree *bvhtree_from_mesh_edges_ex(BVHTreeFromMesh *data,
|
||||
const float (*positions)[3],
|
||||
const float (*vert_positions)[3],
|
||||
const MEdge *edge,
|
||||
const int edges_num,
|
||||
const BitVector<> &edges_mask,
|
||||
|
@ -906,14 +906,14 @@ BVHTree *bvhtree_from_mesh_edges_ex(BVHTreeFromMesh *data,
|
|||
int axis)
|
||||
{
|
||||
BVHTree *tree = bvhtree_from_mesh_edges_create_tree(
|
||||
positions, edge, edges_num, edges_mask, edges_num_active, epsilon, tree_type, axis);
|
||||
vert_positions, edge, edges_num, edges_mask, edges_num_active, epsilon, tree_type, axis);
|
||||
|
||||
bvhtree_balance(tree, false);
|
||||
|
||||
if (data) {
|
||||
/* Setup BVHTreeFromMesh */
|
||||
bvhtree_from_mesh_setup_data(
|
||||
tree, BVHTREE_FROM_EDGES, positions, edge, nullptr, nullptr, nullptr, data);
|
||||
tree, BVHTREE_FROM_EDGES, vert_positions, edge, nullptr, nullptr, nullptr, data);
|
||||
}
|
||||
|
||||
return tree;
|
||||
|
@ -1105,7 +1105,7 @@ BVHTree *bvhtree_from_editmesh_looptri(
|
|||
}
|
||||
|
||||
BVHTree *bvhtree_from_mesh_looptri_ex(BVHTreeFromMesh *data,
|
||||
const float (*positions)[3],
|
||||
const float (*vert_positions)[3],
|
||||
const int *corner_verts,
|
||||
const struct MLoopTri *looptri,
|
||||
const int looptri_num,
|
||||
|
@ -1118,7 +1118,7 @@ BVHTree *bvhtree_from_mesh_looptri_ex(BVHTreeFromMesh *data,
|
|||
BVHTree *tree = bvhtree_from_mesh_looptri_create_tree(epsilon,
|
||||
tree_type,
|
||||
axis,
|
||||
positions,
|
||||
vert_positions,
|
||||
corner_verts,
|
||||
looptri,
|
||||
looptri_num,
|
||||
|
@ -1130,7 +1130,7 @@ BVHTree *bvhtree_from_mesh_looptri_ex(BVHTreeFromMesh *data,
|
|||
if (data) {
|
||||
/* Setup BVHTreeFromMesh */
|
||||
bvhtree_from_mesh_setup_data(
|
||||
tree, BVHTREE_FROM_LOOPTRI, positions, nullptr, nullptr, corner_verts, looptri, data);
|
||||
tree, BVHTREE_FROM_LOOPTRI, vert_positions, nullptr, nullptr, corner_verts, looptri, data);
|
||||
}
|
||||
|
||||
return tree;
|
||||
|
|
|
@ -38,7 +38,7 @@ typedef struct {
|
|||
|
||||
/* these point to data in the DerivedMesh custom data layers,
|
||||
* they are only here for efficiency and convenience */
|
||||
float (*positions)[3];
|
||||
float (*vert_positions)[3];
|
||||
const float (*vert_normals)[3];
|
||||
MEdge *medge;
|
||||
MFace *mface;
|
||||
|
@ -79,7 +79,7 @@ static int cdDM_getNumPolys(DerivedMesh *dm)
|
|||
static void cdDM_copyVertArray(DerivedMesh *dm, float (*r_positions)[3])
|
||||
{
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh *)dm;
|
||||
memcpy(r_positions, cddm->positions, sizeof(float[3]) * dm->numVertData);
|
||||
memcpy(r_positions, cddm->vert_positions, sizeof(float[3]) * dm->numVertData);
|
||||
}
|
||||
|
||||
static void cdDM_copyEdgeArray(DerivedMesh *dm, MEdge *r_edge)
|
||||
|
@ -110,7 +110,7 @@ static void cdDM_getVertCo(DerivedMesh *dm, int index, float r_co[3])
|
|||
{
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh *)dm;
|
||||
|
||||
copy_v3_v3(r_co, cddm->positions[index]);
|
||||
copy_v3_v3(r_co, cddm->vert_positions[index]);
|
||||
}
|
||||
|
||||
static void cdDM_getVertNo(DerivedMesh *dm, int index, float r_no[3])
|
||||
|
@ -130,7 +130,7 @@ static void cdDM_recalc_looptri(DerivedMesh *dm)
|
|||
|
||||
BKE_mesh_recalc_looptri(cddm->corner_verts,
|
||||
cddm->mpoly,
|
||||
cddm->positions,
|
||||
cddm->vert_positions,
|
||||
totloop,
|
||||
totpoly,
|
||||
cddm->dm.looptris.array_wip);
|
||||
|
@ -229,7 +229,7 @@ static DerivedMesh *cdDM_from_mesh_ex(Mesh *mesh,
|
|||
CustomData_merge(&mesh->ldata, &dm->loopData, cddata_masks.lmask, alloctype, mesh->totloop);
|
||||
CustomData_merge(&mesh->pdata, &dm->polyData, cddata_masks.pmask, alloctype, mesh->totpoly);
|
||||
|
||||
cddm->positions = CustomData_get_layer_named(&dm->vertData, CD_PROP_FLOAT3, "position");
|
||||
cddm->vert_positions = CustomData_get_layer_named(&dm->vertData, CD_PROP_FLOAT3, "position");
|
||||
/* Though this may be an unnecessary calculation, simply retrieving the layer may return nothing
|
||||
* or dirty normals. */
|
||||
cddm->vert_normals = BKE_mesh_vertex_normals_ensure(mesh);
|
||||
|
|
|
@ -3048,7 +3048,7 @@ void BKE_curve_bevelList_make(Object *ob, const ListBase *nurbs, const bool for_
|
|||
bevp2 = bevp1 + (bl->nr - 1);
|
||||
nr = bl->nr / 2;
|
||||
while (nr--) {
|
||||
std::swap( *bevp1, *bevp2);
|
||||
std::swap(*bevp1, *bevp2);
|
||||
bevp1++;
|
||||
bevp2--;
|
||||
}
|
||||
|
@ -4446,12 +4446,12 @@ void BKE_nurb_direction_switch(Nurb *nu)
|
|||
swap_v3_v3(bezt2->vec[0], bezt2->vec[2]);
|
||||
}
|
||||
|
||||
std::swap( bezt1->h1, bezt1->h2);
|
||||
std::swap( bezt1->f1, bezt1->f3);
|
||||
std::swap(bezt1->h1, bezt1->h2);
|
||||
std::swap(bezt1->f1, bezt1->f3);
|
||||
|
||||
if (bezt1 != bezt2) {
|
||||
std::swap( bezt2->h1, bezt2->h2);
|
||||
std::swap( bezt2->f1, bezt2->f3);
|
||||
std::swap(bezt2->h1, bezt2->h2);
|
||||
std::swap(bezt2->f1, bezt2->f3);
|
||||
bezt1->tilt = -bezt1->tilt;
|
||||
bezt2->tilt = -bezt2->tilt;
|
||||
}
|
||||
|
@ -4469,7 +4469,7 @@ void BKE_nurb_direction_switch(Nurb *nu)
|
|||
bp2 = bp1 + (a - 1);
|
||||
a /= 2;
|
||||
while (bp1 != bp2 && a > 0) {
|
||||
std::swap( *bp1, *bp2);
|
||||
std::swap(*bp1, *bp2);
|
||||
a--;
|
||||
bp1->tilt = -bp1->tilt;
|
||||
bp2->tilt = -bp2->tilt;
|
||||
|
@ -4491,7 +4491,7 @@ void BKE_nurb_direction_switch(Nurb *nu)
|
|||
fp2 = fp1 + (a - 1);
|
||||
a /= 2;
|
||||
while (fp1 != fp2 && a > 0) {
|
||||
std::swap( *fp1, *fp2);
|
||||
std::swap(*fp1, *fp2);
|
||||
a--;
|
||||
fp1++;
|
||||
fp2--;
|
||||
|
@ -4530,7 +4530,7 @@ void BKE_nurb_direction_switch(Nurb *nu)
|
|||
a /= 2;
|
||||
|
||||
while (bp1 != bp2 && a > 0) {
|
||||
std::swap( *bp1, *bp2);
|
||||
std::swap(*bp1, *bp2);
|
||||
a--;
|
||||
bp1++;
|
||||
bp2--;
|
||||
|
|
|
@ -1774,7 +1774,7 @@ typedef struct DynamicPaintModifierApplyData {
|
|||
const DynamicPaintSurface *surface;
|
||||
Object *ob;
|
||||
|
||||
float (*positions)[3];
|
||||
float (*vert_positions)[3];
|
||||
const float (*vert_normals)[3];
|
||||
const int *corner_verts;
|
||||
const MPoly *mpoly;
|
||||
|
@ -1795,7 +1795,7 @@ static void dynamic_paint_apply_surface_displace_cb(void *__restrict userdata,
|
|||
const float *value = (float *)surface->data->type_data;
|
||||
const float val = value[i] * surface->disp_factor;
|
||||
|
||||
madd_v3_v3fl(data->positions[i], data->vert_normals[i], -val);
|
||||
madd_v3_v3fl(data->vert_positions[i], data->vert_normals[i], -val);
|
||||
}
|
||||
|
||||
/* apply displacing vertex surface to the derived mesh */
|
||||
|
@ -1809,11 +1809,9 @@ static void dynamicPaint_applySurfaceDisplace(DynamicPaintSurface *surface, Mesh
|
|||
|
||||
/* displace paint */
|
||||
if (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE) {
|
||||
float(*positions)[3] = BKE_mesh_vert_positions_for_write(result);
|
||||
|
||||
DynamicPaintModifierApplyData data = {
|
||||
.surface = surface,
|
||||
.positions = positions,
|
||||
.vert_positions = BKE_mesh_vert_positions_for_write(result),
|
||||
.vert_normals = BKE_mesh_vertex_normals_ensure(result),
|
||||
};
|
||||
TaskParallelSettings settings;
|
||||
|
@ -1881,7 +1879,7 @@ static void dynamic_paint_apply_surface_wave_cb(void *__restrict userdata,
|
|||
|
||||
PaintWavePoint *wPoint = (PaintWavePoint *)data->surface->data->type_data;
|
||||
|
||||
madd_v3_v3fl(data->positions[i], data->vert_normals[i], wPoint[i].height);
|
||||
madd_v3_v3fl(data->vert_positions[i], data->vert_normals[i], wPoint[i].height);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -2007,11 +2005,9 @@ static Mesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd, Object *
|
|||
}
|
||||
/* wave simulation */
|
||||
else if (surface->type == MOD_DPAINT_SURFACE_T_WAVE) {
|
||||
float(*positions)[3] = BKE_mesh_vert_positions_for_write(result);
|
||||
|
||||
DynamicPaintModifierApplyData data = {
|
||||
.surface = surface,
|
||||
.positions = positions,
|
||||
.vert_positions = BKE_mesh_vert_positions_for_write(result),
|
||||
.vert_normals = BKE_mesh_vertex_normals_ensure(result),
|
||||
};
|
||||
TaskParallelSettings settings;
|
||||
|
|
|
@ -840,7 +840,7 @@ BLI_INLINE void apply_effector_fields(FluidEffectorSettings *UNUSED(fes),
|
|||
}
|
||||
|
||||
static void update_velocities(FluidEffectorSettings *fes,
|
||||
const float (*positions)[3],
|
||||
const float (*vert_positions)[3],
|
||||
const int *corner_verts,
|
||||
const MLoopTri *mlooptri,
|
||||
float *velocity_map,
|
||||
|
@ -870,7 +870,8 @@ static void update_velocities(FluidEffectorSettings *fes,
|
|||
v1 = corner_verts[mlooptri[f_index].tri[0]];
|
||||
v2 = corner_verts[mlooptri[f_index].tri[1]];
|
||||
v3 = corner_verts[mlooptri[f_index].tri[2]];
|
||||
interp_weights_tri_v3(weights, positions[v1], positions[v2], positions[v3], nearest.co);
|
||||
interp_weights_tri_v3(
|
||||
weights, vert_positions[v1], vert_positions[v2], vert_positions[v3], nearest.co);
|
||||
|
||||
/* Apply object velocity. */
|
||||
float hit_vel[3];
|
||||
|
@ -937,7 +938,7 @@ static void update_velocities(FluidEffectorSettings *fes,
|
|||
typedef struct ObstaclesFromDMData {
|
||||
FluidEffectorSettings *fes;
|
||||
|
||||
const float (*positions)[3];
|
||||
const float (*vert_positions)[3];
|
||||
const int *corner_verts;
|
||||
const MLoopTri *mlooptri;
|
||||
|
||||
|
@ -972,7 +973,7 @@ static void obstacles_from_mesh_task_cb(void *__restrict userdata,
|
|||
|
||||
/* Calculate object velocities. Result in bb->velocity. */
|
||||
update_velocities(data->fes,
|
||||
data->positions,
|
||||
data->vert_positions,
|
||||
data->corner_verts,
|
||||
data->mlooptri,
|
||||
bb->velocity,
|
||||
|
@ -1070,7 +1071,7 @@ static void obstacles_from_mesh(Object *coll_ob,
|
|||
|
||||
ObstaclesFromDMData data = {
|
||||
.fes = fes,
|
||||
.positions = positions,
|
||||
.vert_positions = positions,
|
||||
.corner_verts = corner_verts,
|
||||
.mlooptri = looptri,
|
||||
.tree = &tree_data,
|
||||
|
@ -1784,7 +1785,7 @@ static void update_distances(int index,
|
|||
}
|
||||
|
||||
static void sample_mesh(FluidFlowSettings *ffs,
|
||||
const float (*positions)[3],
|
||||
const float (*vert_positions)[3],
|
||||
const float (*vert_normals)[3],
|
||||
const int *corner_verts,
|
||||
const MLoopTri *mlooptri,
|
||||
|
@ -1872,7 +1873,8 @@ static void sample_mesh(FluidFlowSettings *ffs,
|
|||
v1 = corner_verts[mlooptri[f_index].tri[0]];
|
||||
v2 = corner_verts[mlooptri[f_index].tri[1]];
|
||||
v3 = corner_verts[mlooptri[f_index].tri[2]];
|
||||
interp_weights_tri_v3(weights, positions[v1], positions[v2], positions[v3], nearest.co);
|
||||
interp_weights_tri_v3(
|
||||
weights, vert_positions[v1], vert_positions[v2], vert_positions[v3], nearest.co);
|
||||
|
||||
/* Compute emission strength for smoke flow. */
|
||||
if (is_gas_flow) {
|
||||
|
@ -1978,7 +1980,7 @@ typedef struct EmitFromDMData {
|
|||
FluidDomainSettings *fds;
|
||||
FluidFlowSettings *ffs;
|
||||
|
||||
const float (*positions)[3];
|
||||
const float (*vert_positions)[3];
|
||||
const float (*vert_normals)[3];
|
||||
const int *corner_verts;
|
||||
const MLoopTri *mlooptri;
|
||||
|
@ -2012,7 +2014,7 @@ static void emit_from_mesh_task_cb(void *__restrict userdata,
|
|||
* Result in bb->influence. Also computes initial velocities. Result in bb->velocity. */
|
||||
if (ELEM(data->ffs->behavior, FLUID_FLOW_BEHAVIOR_GEOMETRY, FLUID_FLOW_BEHAVIOR_INFLOW)) {
|
||||
sample_mesh(data->ffs,
|
||||
data->positions,
|
||||
data->vert_positions,
|
||||
data->vert_normals,
|
||||
data->corner_verts,
|
||||
data->mlooptri,
|
||||
|
@ -2136,7 +2138,7 @@ static void emit_from_mesh(
|
|||
EmitFromDMData data = {
|
||||
.fds = fds,
|
||||
.ffs = ffs,
|
||||
.positions = positions,
|
||||
.vert_positions = positions,
|
||||
.vert_normals = vert_normals,
|
||||
.corner_verts = corner_verts,
|
||||
.mlooptri = mlooptri,
|
||||
|
|
|
@ -2471,7 +2471,7 @@ static void gpencil_generate_edgeloops(Object *ob,
|
|||
if (me->totedge == 0) {
|
||||
return;
|
||||
}
|
||||
const Span<float3> positions = me->vert_positions();
|
||||
const Span<float3> vert_positions = me->vert_positions();
|
||||
const Span<MEdge> edges = me->edges();
|
||||
const Span<MDeformVert> dverts = me->deform_verts();
|
||||
const float(*vert_normals)[3] = BKE_mesh_vertex_normals_ensure(me);
|
||||
|
@ -2491,13 +2491,13 @@ static void gpencil_generate_edgeloops(Object *ob,
|
|||
copy_v3_v3(gped->n1, vert_normals[ed->v1]);
|
||||
|
||||
gped->v1 = ed->v1;
|
||||
copy_v3_v3(gped->v1_co, positions[ed->v1]);
|
||||
copy_v3_v3(gped->v1_co, vert_positions[ed->v1]);
|
||||
|
||||
copy_v3_v3(gped->n2, vert_normals[ed->v2]);
|
||||
gped->v2 = ed->v2;
|
||||
copy_v3_v3(gped->v2_co, positions[ed->v2]);
|
||||
copy_v3_v3(gped->v2_co, vert_positions[ed->v2]);
|
||||
|
||||
sub_v3_v3v3(gped->vec, positions[ed->v1], positions[ed->v2]);
|
||||
sub_v3_v3v3(gped->vec, vert_positions[ed->v1], vert_positions[ed->v2]);
|
||||
|
||||
/* If use seams, mark as done if not a seam. */
|
||||
if ((use_seams) && ((ed->flag & ME_SEAM) == 0)) {
|
||||
|
@ -2561,7 +2561,7 @@ static void gpencil_generate_edgeloops(Object *ob,
|
|||
bGPDspoint *pt = &gps_stroke->points[i];
|
||||
copy_v3_v3(fpt, vert_normals[vertex_index]);
|
||||
mul_v3_v3fl(fpt, fpt, offset);
|
||||
add_v3_v3v3(&pt->x, positions[vertex_index], fpt);
|
||||
add_v3_v3v3(&pt->x, vert_positions[vertex_index], fpt);
|
||||
mul_m4_v3(matrix, &pt->x);
|
||||
|
||||
pt->pressure = 1.0f;
|
||||
|
|
|
@ -2213,10 +2213,12 @@ void BKE_keyblock_convert_from_mesh(const Mesh *me, const Key *key, KeyBlock *kb
|
|||
BKE_keyblock_update_from_mesh(me, kb);
|
||||
}
|
||||
|
||||
void BKE_keyblock_convert_to_mesh(const KeyBlock *kb, float (*positions)[3], const int totvert)
|
||||
void BKE_keyblock_convert_to_mesh(const KeyBlock *kb,
|
||||
float (*vert_positions)[3],
|
||||
const int totvert)
|
||||
{
|
||||
const int tot = min_ii(kb->totelem, totvert);
|
||||
memcpy(kb->data, positions, sizeof(float[3]) * tot);
|
||||
memcpy(kb->data, vert_positions, sizeof(float[3]) * tot);
|
||||
}
|
||||
|
||||
void BKE_keyblock_mesh_calc_normals(const KeyBlock *kb,
|
||||
|
|
|
@ -459,7 +459,7 @@ static bool mesh_calc_center_centroid_ex(const float (*positions)[3],
|
|||
return true;
|
||||
}
|
||||
|
||||
void BKE_mesh_calc_volume(const float (*positions)[3],
|
||||
void BKE_mesh_calc_volume(const float (*vert_positions)[3],
|
||||
const int mverts_num,
|
||||
const MLoopTri *looptri,
|
||||
const int looptri_num,
|
||||
|
@ -484,16 +484,16 @@ void BKE_mesh_calc_volume(const float (*positions)[3],
|
|||
}
|
||||
|
||||
if (!mesh_calc_center_centroid_ex(
|
||||
positions, mverts_num, looptri, looptri_num, corner_verts, center)) {
|
||||
vert_positions, mverts_num, looptri, looptri_num, corner_verts, center)) {
|
||||
return;
|
||||
}
|
||||
|
||||
totvol = 0.0f;
|
||||
|
||||
for (i = 0, lt = looptri; i < looptri_num; i++, lt++) {
|
||||
const float *v1 = positions[corner_verts[lt->tri[0]]];
|
||||
const float *v2 = positions[corner_verts[lt->tri[1]]];
|
||||
const float *v3 = positions[corner_verts[lt->tri[2]]];
|
||||
const float *v1 = vert_positions[corner_verts[lt->tri[0]]];
|
||||
const float *v2 = vert_positions[corner_verts[lt->tri[1]]];
|
||||
const float *v3 = vert_positions[corner_verts[lt->tri[2]]];
|
||||
float vol;
|
||||
|
||||
vol = volume_tetrahedron_signed_v3(center, v1, v2, v3);
|
||||
|
|
|
@ -470,13 +470,13 @@ static void prefair_and_fair_verts(FairingContext *fairing_context,
|
|||
}
|
||||
|
||||
void BKE_mesh_prefair_and_fair_verts(struct Mesh *mesh,
|
||||
float (*deform_positions)[3],
|
||||
float (*deform_vert_positions)[3],
|
||||
bool *affect_verts,
|
||||
const eMeshFairingDepth depth)
|
||||
{
|
||||
MutableSpan<float3> deform_positions_span;
|
||||
if (deform_positions) {
|
||||
deform_positions_span = {reinterpret_cast<float3 *>(deform_positions), mesh->totvert};
|
||||
if (deform_vert_positions) {
|
||||
deform_positions_span = {reinterpret_cast<float3 *>(deform_vert_positions), mesh->totvert};
|
||||
}
|
||||
MeshFairingContext *fairing_context = new MeshFairingContext(mesh, deform_positions_span);
|
||||
prefair_and_fair_verts(fairing_context, affect_verts, depth);
|
||||
|
|
|
@ -110,7 +110,7 @@ static bool mesh_remap_bvhtree_query_raycast(BVHTreeFromMesh *treedata,
|
|||
* \{ */
|
||||
|
||||
float BKE_mesh_remap_calc_difference_from_mesh(const SpaceTransform *space_transform,
|
||||
const float (*positions_dst)[3],
|
||||
const float (*vert_positions_dst)[3],
|
||||
const int numverts_dst,
|
||||
Mesh *me_src)
|
||||
{
|
||||
|
@ -127,7 +127,7 @@ float BKE_mesh_remap_calc_difference_from_mesh(const SpaceTransform *space_trans
|
|||
for (i = 0; i < numverts_dst; i++) {
|
||||
float tmp_co[3];
|
||||
|
||||
copy_v3_v3(tmp_co, positions_dst[i]);
|
||||
copy_v3_v3(tmp_co, vert_positions_dst[i]);
|
||||
|
||||
/* Convert the vertex to tree coordinates, if needed. */
|
||||
if (space_transform) {
|
||||
|
@ -239,7 +239,7 @@ static void mesh_calc_eigen_matrix(const float (*positions)[3],
|
|||
copy_v3_v3(r_mat[3], center);
|
||||
}
|
||||
|
||||
void BKE_mesh_remap_find_best_match_from_mesh(const float (*positions_dst)[3],
|
||||
void BKE_mesh_remap_find_best_match_from_mesh(const float (*vert_positions_dst)[3],
|
||||
const int numverts_dst,
|
||||
Mesh *me_src,
|
||||
SpaceTransform *r_space_transform)
|
||||
|
@ -265,11 +265,11 @@ void BKE_mesh_remap_find_best_match_from_mesh(const float (*positions_dst)[3],
|
|||
float(*vcos_src)[3] = BKE_mesh_vert_coords_alloc(me_src, nullptr);
|
||||
|
||||
mesh_calc_eigen_matrix(nullptr, (const float(*)[3])vcos_src, numverts_src, mat_src);
|
||||
mesh_calc_eigen_matrix(positions_dst, nullptr, numverts_dst, mat_dst);
|
||||
mesh_calc_eigen_matrix(vert_positions_dst, nullptr, numverts_dst, mat_dst);
|
||||
|
||||
BLI_space_transform_global_from_matrices(r_space_transform, mat_dst, mat_src);
|
||||
match = BKE_mesh_remap_calc_difference_from_mesh(
|
||||
r_space_transform, positions_dst, numverts_dst, me_src);
|
||||
r_space_transform, vert_positions_dst, numverts_dst, me_src);
|
||||
best_match = match;
|
||||
copy_m4_m4(best_mat_dst, mat_dst);
|
||||
|
||||
|
@ -281,7 +281,7 @@ void BKE_mesh_remap_find_best_match_from_mesh(const float (*positions_dst)[3],
|
|||
|
||||
BLI_space_transform_global_from_matrices(r_space_transform, mat_dst, mat_src);
|
||||
match = BKE_mesh_remap_calc_difference_from_mesh(
|
||||
r_space_transform, positions_dst, numverts_dst, me_src);
|
||||
r_space_transform, vert_positions_dst, numverts_dst, me_src);
|
||||
if (match < best_match) {
|
||||
best_match = match;
|
||||
copy_m4_m4(best_mat_dst, mat_dst);
|
||||
|
@ -463,7 +463,7 @@ void BKE_mesh_remap_calc_verts_from_mesh(const int mode,
|
|||
const SpaceTransform *space_transform,
|
||||
const float max_dist,
|
||||
const float ray_radius,
|
||||
const float (*positions_dst)[3],
|
||||
const float (*vert_positions_dst)[3],
|
||||
const int numverts_dst,
|
||||
const bool /*dirty_nors_dst*/,
|
||||
Mesh *me_src,
|
||||
|
@ -496,7 +496,7 @@ void BKE_mesh_remap_calc_verts_from_mesh(const int mode,
|
|||
nearest.index = -1;
|
||||
|
||||
for (i = 0; i < numverts_dst; i++) {
|
||||
copy_v3_v3(tmp_co, positions_dst[i]);
|
||||
copy_v3_v3(tmp_co, vert_positions_dst[i]);
|
||||
|
||||
/* Convert the vertex to tree coordinates, if needed. */
|
||||
if (space_transform) {
|
||||
|
@ -521,7 +521,7 @@ void BKE_mesh_remap_calc_verts_from_mesh(const int mode,
|
|||
nearest.index = -1;
|
||||
|
||||
for (i = 0; i < numverts_dst; i++) {
|
||||
copy_v3_v3(tmp_co, positions_dst[i]);
|
||||
copy_v3_v3(tmp_co, vert_positions_dst[i]);
|
||||
|
||||
/* Convert the vertex to tree coordinates, if needed. */
|
||||
if (space_transform) {
|
||||
|
@ -583,7 +583,7 @@ void BKE_mesh_remap_calc_verts_from_mesh(const int mode,
|
|||
|
||||
if (mode == MREMAP_MODE_VERT_POLYINTERP_VNORPROJ) {
|
||||
for (i = 0; i < numverts_dst; i++) {
|
||||
copy_v3_v3(tmp_co, positions_dst[i]);
|
||||
copy_v3_v3(tmp_co, vert_positions_dst[i]);
|
||||
copy_v3_v3(tmp_no, vert_normals_dst[i]);
|
||||
|
||||
/* Convert the vertex to tree coordinates, if needed. */
|
||||
|
@ -620,7 +620,7 @@ void BKE_mesh_remap_calc_verts_from_mesh(const int mode,
|
|||
nearest.index = -1;
|
||||
|
||||
for (i = 0; i < numverts_dst; i++) {
|
||||
copy_v3_v3(tmp_co, positions_dst[i]);
|
||||
copy_v3_v3(tmp_co, vert_positions_dst[i]);
|
||||
|
||||
/* Convert the vertex to tree coordinates, if needed. */
|
||||
if (space_transform) {
|
||||
|
@ -689,7 +689,7 @@ void BKE_mesh_remap_calc_edges_from_mesh(const int mode,
|
|||
const SpaceTransform *space_transform,
|
||||
const float max_dist,
|
||||
const float ray_radius,
|
||||
const float (*positions_dst)[3],
|
||||
const float (*vert_positions_dst)[3],
|
||||
const int numverts_dst,
|
||||
const MEdge *edges_dst,
|
||||
const int numedges_dst,
|
||||
|
@ -759,7 +759,7 @@ void BKE_mesh_remap_calc_edges_from_mesh(const int mode,
|
|||
|
||||
/* Compute closest verts only once! */
|
||||
if (v_dst_to_src_map[vidx_dst].hit_dist == -1.0f) {
|
||||
copy_v3_v3(tmp_co, positions_dst[vidx_dst]);
|
||||
copy_v3_v3(tmp_co, vert_positions_dst[vidx_dst]);
|
||||
|
||||
/* Convert the vertex to tree coordinates, if needed. */
|
||||
if (space_transform) {
|
||||
|
@ -797,7 +797,7 @@ void BKE_mesh_remap_calc_edges_from_mesh(const int mode,
|
|||
const MEdge *e_src = &edges_src[*eidx_src];
|
||||
const float *other_co_src = vcos_src[BKE_mesh_edge_other_vert(e_src, vidx_src)];
|
||||
const float *other_co_dst =
|
||||
positions_dst[BKE_mesh_edge_other_vert(e_dst, int(vidx_dst))];
|
||||
vert_positions_dst[BKE_mesh_edge_other_vert(e_dst, int(vidx_dst))];
|
||||
const float totdist = first_dist + len_v3v3(other_co_src, other_co_dst);
|
||||
|
||||
if (totdist < best_totdist) {
|
||||
|
@ -810,8 +810,8 @@ void BKE_mesh_remap_calc_edges_from_mesh(const int mode,
|
|||
if (best_eidx_src >= 0) {
|
||||
const float *co1_src = vcos_src[edges_src[best_eidx_src].v1];
|
||||
const float *co2_src = vcos_src[edges_src[best_eidx_src].v2];
|
||||
const float *co1_dst = positions_dst[e_dst->v1];
|
||||
const float *co2_dst = positions_dst[e_dst->v2];
|
||||
const float *co1_dst = vert_positions_dst[e_dst->v1];
|
||||
const float *co2_dst = vert_positions_dst[e_dst->v2];
|
||||
float co_src[3], co_dst[3];
|
||||
|
||||
/* TODO: would need an isect_seg_seg_v3(), actually! */
|
||||
|
@ -852,8 +852,10 @@ void BKE_mesh_remap_calc_edges_from_mesh(const int mode,
|
|||
nearest.index = -1;
|
||||
|
||||
for (i = 0; i < numedges_dst; i++) {
|
||||
interp_v3_v3v3(
|
||||
tmp_co, positions_dst[edges_dst[i].v1], positions_dst[edges_dst[i].v2], 0.5f);
|
||||
interp_v3_v3v3(tmp_co,
|
||||
vert_positions_dst[edges_dst[i].v1],
|
||||
vert_positions_dst[edges_dst[i].v2],
|
||||
0.5f);
|
||||
|
||||
/* Convert the vertex to tree coordinates, if needed. */
|
||||
if (space_transform) {
|
||||
|
@ -879,8 +881,10 @@ void BKE_mesh_remap_calc_edges_from_mesh(const int mode,
|
|||
BKE_bvhtree_from_mesh_get(&treedata, me_src, BVHTREE_FROM_LOOPTRI, 2);
|
||||
|
||||
for (i = 0; i < numedges_dst; i++) {
|
||||
interp_v3_v3v3(
|
||||
tmp_co, positions_dst[edges_dst[i].v1], positions_dst[edges_dst[i].v2], 0.5f);
|
||||
interp_v3_v3v3(tmp_co,
|
||||
vert_positions_dst[edges_dst[i].v1],
|
||||
vert_positions_dst[edges_dst[i].v2],
|
||||
0.5f);
|
||||
|
||||
/* Convert the vertex to tree coordinates, if needed. */
|
||||
if (space_transform) {
|
||||
|
@ -953,8 +957,8 @@ void BKE_mesh_remap_calc_edges_from_mesh(const int mode,
|
|||
int sources_num = 0;
|
||||
int j;
|
||||
|
||||
copy_v3_v3(v1_co, positions_dst[me->v1]);
|
||||
copy_v3_v3(v2_co, positions_dst[me->v2]);
|
||||
copy_v3_v3(v1_co, vert_positions_dst[me->v1]);
|
||||
copy_v3_v3(v2_co, vert_positions_dst[me->v2]);
|
||||
|
||||
copy_v3_v3(v1_no, vert_normals_dst[me->v1]);
|
||||
copy_v3_v3(v2_no, vert_normals_dst[me->v2]);
|
||||
|
@ -1232,7 +1236,7 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
|
|||
const float max_dist,
|
||||
const float ray_radius,
|
||||
Mesh *mesh_dst,
|
||||
const float (*positions_dst)[3],
|
||||
const float (*vert_positions_dst)[3],
|
||||
const int numverts_dst,
|
||||
const MEdge *edges_dst,
|
||||
const int numedges_dst,
|
||||
|
@ -1365,7 +1369,7 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
|
|||
CustomData_set_layer_flag(ldata_dst, CD_NORMAL, CD_FLAG_TEMPORARY);
|
||||
}
|
||||
if (dirty_nors_dst || do_loop_nors_dst) {
|
||||
BKE_mesh_normals_loop_split(positions_dst,
|
||||
BKE_mesh_normals_loop_split(vert_positions_dst,
|
||||
BKE_mesh_vertex_normals_ensure(mesh_dst),
|
||||
numverts_dst,
|
||||
edges_dst,
|
||||
|
@ -1609,7 +1613,7 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
|
|||
if (use_from_vert) {
|
||||
MeshElemMap *vert_to_refelem_map_src = nullptr;
|
||||
|
||||
copy_v3_v3(tmp_co, positions_dst[vert_dst_i]);
|
||||
copy_v3_v3(tmp_co, vert_positions_dst[vert_dst_i]);
|
||||
nearest.index = -1;
|
||||
|
||||
/* Convert the vertex to tree coordinates, if needed. */
|
||||
|
@ -1670,8 +1674,10 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
|
|||
mp_src = &polys_src[pidx_src];
|
||||
|
||||
if (!pcent_dst_valid) {
|
||||
BKE_mesh_calc_poly_center(
|
||||
mp_dst, &corner_verts_src[mp_dst->loopstart], positions_dst, pcent_dst);
|
||||
BKE_mesh_calc_poly_center(mp_dst,
|
||||
&corner_verts_src[mp_dst->loopstart],
|
||||
vert_positions_dst,
|
||||
pcent_dst);
|
||||
pcent_dst_valid = true;
|
||||
}
|
||||
pcent_src = poly_cents_src[pidx_src];
|
||||
|
@ -1717,7 +1723,7 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
|
|||
int n = (ray_radius > 0.0f) ? MREMAP_RAYCAST_APPROXIMATE_NR : 1;
|
||||
float w = 1.0f;
|
||||
|
||||
copy_v3_v3(tmp_co, positions_dst[vert_dst_i]);
|
||||
copy_v3_v3(tmp_co, vert_positions_dst[vert_dst_i]);
|
||||
copy_v3_v3(tmp_no, loop_nors_dst[plidx_dst + mp_dst->loopstart]);
|
||||
|
||||
/* We do our transform here, since we may do several raycast/nearest queries. */
|
||||
|
@ -1745,7 +1751,7 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
|
|||
* is null, it means none of its loop mapped to this source island,
|
||||
* hence we can skip it later.
|
||||
*/
|
||||
copy_v3_v3(tmp_co, positions_dst[vert_dst_i]);
|
||||
copy_v3_v3(tmp_co, vert_positions_dst[vert_dst_i]);
|
||||
nearest.index = -1;
|
||||
|
||||
/* Convert the vertex to tree coordinates, if needed. */
|
||||
|
@ -1771,7 +1777,7 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
|
|||
}
|
||||
}
|
||||
else { /* Nearest poly either to use all its loops/verts or just closest one. */
|
||||
copy_v3_v3(tmp_co, positions_dst[vert_dst_i]);
|
||||
copy_v3_v3(tmp_co, vert_positions_dst[vert_dst_i]);
|
||||
nearest.index = -1;
|
||||
|
||||
/* Convert the vertex to tree coordinates, if needed. */
|
||||
|
@ -1900,7 +1906,7 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
|
|||
int j;
|
||||
float best_dist_sq = FLT_MAX;
|
||||
|
||||
copy_v3_v3(tmp_co, positions_dst[corner_verts_dst[lidx_dst]]);
|
||||
copy_v3_v3(tmp_co, vert_positions_dst[corner_verts_dst[lidx_dst]]);
|
||||
|
||||
/* We do our transform here,
|
||||
* since we may do several raycast/nearest queries. */
|
||||
|
@ -1993,7 +1999,7 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
|
|||
int j;
|
||||
|
||||
const int vert_dst_i = corner_verts_dst[lidx_dst];
|
||||
copy_v3_v3(tmp_co, positions_dst[vert_dst_i]);
|
||||
copy_v3_v3(tmp_co, vert_positions_dst[vert_dst_i]);
|
||||
|
||||
/* We do our transform here,
|
||||
* since we may do several raycast/nearest queries. */
|
||||
|
@ -2161,7 +2167,7 @@ void BKE_mesh_remap_calc_polys_from_mesh(const int mode,
|
|||
const float max_dist,
|
||||
const float ray_radius,
|
||||
const Mesh *mesh_dst,
|
||||
const float (*positions_dst)[3],
|
||||
const float (*vert_positions_dst)[3],
|
||||
const int *corner_verts,
|
||||
const MPoly *polys_dst,
|
||||
const int numpolys_dst,
|
||||
|
@ -2202,7 +2208,7 @@ void BKE_mesh_remap_calc_polys_from_mesh(const int mode,
|
|||
for (i = 0; i < numpolys_dst; i++) {
|
||||
const MPoly *mp = &polys_dst[i];
|
||||
|
||||
BKE_mesh_calc_poly_center(mp, &corner_verts[mp->loopstart], positions_dst, tmp_co);
|
||||
BKE_mesh_calc_poly_center(mp, &corner_verts[mp->loopstart], vert_positions_dst, tmp_co);
|
||||
|
||||
/* Convert the vertex to tree coordinates, if needed. */
|
||||
if (space_transform) {
|
||||
|
@ -2227,7 +2233,7 @@ void BKE_mesh_remap_calc_polys_from_mesh(const int mode,
|
|||
for (i = 0; i < numpolys_dst; i++) {
|
||||
const MPoly *mp = &polys_dst[i];
|
||||
|
||||
BKE_mesh_calc_poly_center(mp, &corner_verts[mp->loopstart], positions_dst, tmp_co);
|
||||
BKE_mesh_calc_poly_center(mp, &corner_verts[mp->loopstart], vert_positions_dst, tmp_co);
|
||||
copy_v3_v3(tmp_no, poly_nors_dst[i]);
|
||||
|
||||
/* Convert the vertex to tree coordinates, if needed. */
|
||||
|
@ -2290,7 +2296,7 @@ void BKE_mesh_remap_calc_polys_from_mesh(const int mode,
|
|||
const int tris_num = mp->totloop - 2;
|
||||
int j;
|
||||
|
||||
BKE_mesh_calc_poly_center(mp, &corner_verts[mp->loopstart], positions_dst, pcent_dst);
|
||||
BKE_mesh_calc_poly_center(mp, &corner_verts[mp->loopstart], vert_positions_dst, pcent_dst);
|
||||
copy_v3_v3(tmp_no, poly_nors_dst[i]);
|
||||
|
||||
/* We do our transform here, else it'd be redone by raycast helper for each ray, ugh! */
|
||||
|
@ -2320,7 +2326,7 @@ void BKE_mesh_remap_calc_polys_from_mesh(const int mode,
|
|||
|
||||
for (j = 0; j < mp->totloop; j++) {
|
||||
const int vert_i = corner_verts[j + mp->loopstart];
|
||||
copy_v3_v3(tmp_co, positions_dst[vert_i]);
|
||||
copy_v3_v3(tmp_co, vert_positions_dst[vert_i]);
|
||||
if (space_transform) {
|
||||
BLI_space_transform_apply(space_transform, tmp_co);
|
||||
}
|
||||
|
|
|
@ -207,7 +207,7 @@ static int search_polyloop_cmp(const void *v1, const void *v2)
|
|||
|
||||
/* NOLINTNEXTLINE: readability-function-size */
|
||||
bool BKE_mesh_validate_arrays(Mesh *mesh,
|
||||
float (*positions)[3],
|
||||
float (*vert_positions)[3],
|
||||
uint totvert,
|
||||
MEdge *medges,
|
||||
uint totedge,
|
||||
|
@ -306,11 +306,11 @@ bool BKE_mesh_validate_arrays(Mesh *mesh,
|
|||
bool fix_normal = true;
|
||||
|
||||
for (j = 0; j < 3; j++) {
|
||||
if (!isfinite(positions[i][j])) {
|
||||
if (!isfinite(vert_positions[i][j])) {
|
||||
PRINT_ERR("\tVertex %u: has invalid coordinate", i);
|
||||
|
||||
if (do_fixes) {
|
||||
zero_v3(positions[i]);
|
||||
zero_v3(vert_positions[i]);
|
||||
|
||||
fix_flag.verts = true;
|
||||
}
|
||||
|
@ -332,7 +332,7 @@ bool BKE_mesh_validate_arrays(Mesh *mesh,
|
|||
* although it's also possible degenerate/opposite faces accumulate to a zero vector.
|
||||
* To detect this a full normal recalculation would be needed, which is out of scope
|
||||
* for a basic validity check (see "Vertex Normal" in the doc-string). */
|
||||
if (!is_zero_v3(positions[i])) {
|
||||
if (!is_zero_v3(vert_positions[i])) {
|
||||
PRINT_ERR("\tVertex %u: has zero normal, assuming Z-up normal", i);
|
||||
if (do_fixes) {
|
||||
float *normal = (float *)vert_normals[i];
|
||||
|
|
|
@ -1959,10 +1959,10 @@ void nodeRemoveSocketEx(bNodeTree *ntree, bNode *node, bNodeSocket *sock, bool d
|
|||
}
|
||||
}
|
||||
|
||||
for (bNodeLink *link : node->runtime->internal_links) {
|
||||
if (link->fromsock == sock || link->tosock == sock) {
|
||||
node->runtime->internal_links.remove_first_occurrence_and_reorder(link);
|
||||
MEM_freeN(link);
|
||||
for (const int64_t i : node->runtime->internal_links.index_range()) {
|
||||
const bNodeLink &link = node->runtime->internal_links[i];
|
||||
if (link.fromsock == sock || link.tosock == sock) {
|
||||
node->runtime->internal_links.remove_and_reorder(i);
|
||||
BKE_ntree_update_tag_node_internal_link(ntree, node);
|
||||
break;
|
||||
}
|
||||
|
@ -1986,9 +1986,6 @@ void nodeRemoveAllSockets(bNodeTree *ntree, bNode *node)
|
|||
}
|
||||
}
|
||||
|
||||
for (bNodeLink *link : node->runtime->internal_links) {
|
||||
MEM_freeN(link);
|
||||
}
|
||||
node->runtime->internal_links.clear();
|
||||
|
||||
LISTBASE_FOREACH_MUTABLE (bNodeSocket *, sock, &node->inputs) {
|
||||
|
@ -2312,14 +2309,12 @@ bNode *node_copy_with_mapping(bNodeTree *dst_tree,
|
|||
node_dst->prop = IDP_CopyProperty_ex(node_src.prop, flag);
|
||||
}
|
||||
|
||||
node_dst->runtime->internal_links.clear();
|
||||
for (const bNodeLink *src_link : node_src.runtime->internal_links) {
|
||||
bNodeLink *dst_link = (bNodeLink *)MEM_dupallocN(src_link);
|
||||
dst_link->fromnode = node_dst;
|
||||
dst_link->tonode = node_dst;
|
||||
dst_link->fromsock = socket_map.lookup(src_link->fromsock);
|
||||
dst_link->tosock = socket_map.lookup(src_link->tosock);
|
||||
node_dst->runtime->internal_links.append(dst_link);
|
||||
node_dst->runtime->internal_links = node_src.runtime->internal_links;
|
||||
for (bNodeLink &dst_link : node_dst->runtime->internal_links) {
|
||||
dst_link.fromnode = node_dst;
|
||||
dst_link.tonode = node_dst;
|
||||
dst_link.fromsock = socket_map.lookup(dst_link.fromsock);
|
||||
dst_link.tosock = socket_map.lookup(dst_link.tosock);
|
||||
}
|
||||
|
||||
if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
|
||||
|
@ -2474,8 +2469,8 @@ static void adjust_multi_input_indices_after_removed_link(bNodeTree *ntree,
|
|||
void nodeInternalRelink(bNodeTree *ntree, bNode *node)
|
||||
{
|
||||
/* store link pointers in output sockets, for efficient lookup */
|
||||
for (bNodeLink *link : node->runtime->internal_links) {
|
||||
link->tosock->link = link;
|
||||
for (bNodeLink &link : node->runtime->internal_links) {
|
||||
link.tosock->link = &link;
|
||||
}
|
||||
|
||||
/* redirect downstream links */
|
||||
|
@ -2989,11 +2984,6 @@ void node_free_node(bNodeTree *ntree, bNode *node)
|
|||
MEM_freeN(sock);
|
||||
}
|
||||
|
||||
for (bNodeLink *link : node->runtime->internal_links) {
|
||||
MEM_freeN(link);
|
||||
}
|
||||
node->runtime->internal_links.clear();
|
||||
|
||||
if (node->prop) {
|
||||
/* Remember, no ID user refcount management here! */
|
||||
IDP_FreePropertyContent_ex(node->prop, false);
|
||||
|
@ -3644,7 +3634,7 @@ void nodeTagUpdateID(bNode *node)
|
|||
node->runtime->update |= NODE_UPDATE_ID;
|
||||
}
|
||||
|
||||
void nodeInternalLinks(bNode *node, bNodeLink ***r_links, int *r_len)
|
||||
void nodeInternalLinks(bNode *node, bNodeLink **r_links, int *r_len)
|
||||
{
|
||||
*r_links = node->runtime->internal_links.data();
|
||||
*r_len = node->runtime->internal_links.size();
|
||||
|
|
|
@ -95,8 +95,8 @@ static void update_internal_link_inputs(const bNodeTree &ntree)
|
|||
for (bNodeSocket *socket : node->runtime->outputs) {
|
||||
socket->runtime->internal_link_input = nullptr;
|
||||
}
|
||||
for (bNodeLink *link : node->runtime->internal_links) {
|
||||
link->tosock->runtime->internal_link_input = link->fromsock;
|
||||
for (bNodeLink &link : node->runtime->internal_links) {
|
||||
link.tosock->runtime->internal_link_input = link.fromsock;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -635,8 +635,8 @@ class NodeTreeMainUpdater {
|
|||
const bNodeSocket *from_socket = item.first;
|
||||
const bNodeSocket *to_socket = item.second;
|
||||
bool found = false;
|
||||
for (const bNodeLink *internal_link : node->runtime->internal_links) {
|
||||
if (from_socket == internal_link->fromsock && to_socket == internal_link->tosock) {
|
||||
for (const bNodeLink &internal_link : node->runtime->internal_links) {
|
||||
if (from_socket == internal_link.fromsock && to_socket == internal_link.tosock) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
@ -682,19 +682,17 @@ class NodeTreeMainUpdater {
|
|||
bNode &node,
|
||||
Span<std::pair<bNodeSocket *, bNodeSocket *>> links)
|
||||
{
|
||||
for (bNodeLink *link : node.runtime->internal_links) {
|
||||
MEM_freeN(link);
|
||||
}
|
||||
node.runtime->internal_links.clear();
|
||||
node.runtime->internal_links.reserve(links.size());
|
||||
for (const auto &item : links) {
|
||||
bNodeSocket *from_socket = item.first;
|
||||
bNodeSocket *to_socket = item.second;
|
||||
bNodeLink *link = MEM_cnew<bNodeLink>(__func__);
|
||||
link->fromnode = &node;
|
||||
link->fromsock = from_socket;
|
||||
link->tonode = &node;
|
||||
link->tosock = to_socket;
|
||||
link->flag |= NODE_LINK_VALID;
|
||||
bNodeLink link{};
|
||||
link.fromnode = &node;
|
||||
link.fromsock = from_socket;
|
||||
link.tonode = &node;
|
||||
link.tosock = to_socket;
|
||||
link.flag |= NODE_LINK_VALID;
|
||||
node.runtime->internal_links.append(link);
|
||||
}
|
||||
BKE_ntree_update_tag_node_internal_link(&ntree, &node);
|
||||
|
|
|
@ -553,7 +553,7 @@ struct VertexDupliData_Mesh {
|
|||
VertexDupliData_Params params;
|
||||
|
||||
int totvert;
|
||||
Span<float3> positions;
|
||||
Span<float3> vert_positions;
|
||||
const float (*vert_normals)[3];
|
||||
|
||||
const float (*orco)[3];
|
||||
|
@ -656,7 +656,7 @@ static void make_child_duplis_verts_from_mesh(const DupliContext *ctx,
|
|||
inst_ob,
|
||||
child_imat,
|
||||
i,
|
||||
vdd->positions[i],
|
||||
vdd->vert_positions[i],
|
||||
vdd->vert_normals[i],
|
||||
use_rotation);
|
||||
if (vdd->orco) {
|
||||
|
@ -734,7 +734,7 @@ static void make_duplis_verts(const DupliContext *ctx)
|
|||
VertexDupliData_Mesh vdd{};
|
||||
vdd.params = vdd_params;
|
||||
vdd.totvert = me_eval->totvert;
|
||||
vdd.positions = me_eval->vert_positions();
|
||||
vdd.vert_positions = me_eval->vert_positions();
|
||||
vdd.vert_normals = BKE_mesh_vertex_normals_ensure(me_eval);
|
||||
vdd.orco = (const float(*)[3])CustomData_get_layer(&me_eval->vdata, CD_ORCO);
|
||||
|
||||
|
|
|
@ -1274,7 +1274,7 @@ typedef struct ParticleInterpolationData {
|
|||
HairKey *hkey[2];
|
||||
|
||||
Mesh *mesh;
|
||||
float3 *positions[2];
|
||||
float3 *vert_positions[2];
|
||||
|
||||
int keyed;
|
||||
ParticleKey *kkey[2];
|
||||
|
@ -1435,8 +1435,8 @@ static void init_particle_interpolation(Object *ob,
|
|||
|
||||
if (pind->mesh) {
|
||||
float3 *positions = pind->mesh->vert_positions_for_write().data();
|
||||
pind->positions[0] = &positions[pa->hair_index];
|
||||
pind->positions[1] = pind->positions[0] + 1;
|
||||
pind->vert_positions[0] = &positions[pa->hair_index];
|
||||
pind->vert_positions[1] = pind->vert_positions[0] + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1554,7 +1554,7 @@ static void do_particle_interpolation(ParticleSystem *psys,
|
|||
|
||||
while (pind->hkey[1]->time < real_t) {
|
||||
pind->hkey[1]++;
|
||||
pind->positions[1]++;
|
||||
pind->vert_positions[1]++;
|
||||
}
|
||||
|
||||
pind->hkey[0] = pind->hkey[1] - 1;
|
||||
|
@ -1566,9 +1566,9 @@ static void do_particle_interpolation(ParticleSystem *psys,
|
|||
edit_to_particle(keys + 2, pind->ekey[1]);
|
||||
}
|
||||
else if (pind->mesh) {
|
||||
pind->positions[0] = pind->positions[1] - 1;
|
||||
mvert_to_particle(keys + 1, pind->positions[0], pind->hkey[0]);
|
||||
mvert_to_particle(keys + 2, pind->positions[1], pind->hkey[1]);
|
||||
pind->vert_positions[0] = pind->vert_positions[1] - 1;
|
||||
mvert_to_particle(keys + 1, pind->vert_positions[0], pind->hkey[0]);
|
||||
mvert_to_particle(keys + 2, pind->vert_positions[1], pind->hkey[1]);
|
||||
}
|
||||
else if (pind->keyed) {
|
||||
memcpy(keys + 1, pind->kkey[0], sizeof(ParticleKey));
|
||||
|
@ -1594,10 +1594,10 @@ static void do_particle_interpolation(ParticleSystem *psys,
|
|||
}
|
||||
else if (pind->mesh) {
|
||||
if (pind->hkey[0] != pa->hair) {
|
||||
mvert_to_particle(keys, pind->positions[0] - 1, pind->hkey[0] - 1);
|
||||
mvert_to_particle(keys, pind->vert_positions[0] - 1, pind->hkey[0] - 1);
|
||||
}
|
||||
else {
|
||||
mvert_to_particle(keys, pind->positions[0], pind->hkey[0]);
|
||||
mvert_to_particle(keys, pind->vert_positions[0], pind->hkey[0]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -1619,10 +1619,10 @@ static void do_particle_interpolation(ParticleSystem *psys,
|
|||
}
|
||||
else if (pind->mesh) {
|
||||
if (pind->hkey[1] != pa->hair + pa->totkey - 1) {
|
||||
mvert_to_particle(keys + 3, pind->positions[1] + 1, pind->hkey[1] + 1);
|
||||
mvert_to_particle(keys + 3, pind->vert_positions[1] + 1, pind->hkey[1] + 1);
|
||||
}
|
||||
else {
|
||||
mvert_to_particle(keys + 3, pind->positions[1], pind->hkey[1]);
|
||||
mvert_to_particle(keys + 3, pind->vert_positions[1], pind->hkey[1]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -1700,7 +1700,7 @@ static void interpolate_pathcache(ParticleCacheKey *first, float t, ParticleCach
|
|||
/************************************************/
|
||||
|
||||
void psys_interpolate_face(Mesh *mesh,
|
||||
const float (*positions)[3],
|
||||
const float (*vert_positions)[3],
|
||||
const float (*vert_normals)[3],
|
||||
MFace *mface,
|
||||
MTFace *tface,
|
||||
|
@ -1719,16 +1719,16 @@ void psys_interpolate_face(Mesh *mesh,
|
|||
float tuv[4][2];
|
||||
const float *o1, *o2, *o3, *o4;
|
||||
|
||||
v1 = positions[mface->v1];
|
||||
v2 = positions[mface->v2];
|
||||
v3 = positions[mface->v3];
|
||||
v1 = vert_positions[mface->v1];
|
||||
v2 = vert_positions[mface->v2];
|
||||
v3 = vert_positions[mface->v3];
|
||||
|
||||
copy_v3_v3(n1, vert_normals[mface->v1]);
|
||||
copy_v3_v3(n2, vert_normals[mface->v2]);
|
||||
copy_v3_v3(n3, vert_normals[mface->v3]);
|
||||
|
||||
if (mface->v4) {
|
||||
v4 = positions[mface->v4];
|
||||
v4 = vert_positions[mface->v4];
|
||||
copy_v3_v3(n4, vert_normals[mface->v4]);
|
||||
|
||||
interp_v3_v3v3v3v3(vec, v1, v2, v3, v4, w);
|
||||
|
@ -2161,8 +2161,8 @@ void psys_particle_on_dm(Mesh *mesh_final,
|
|||
const float(*vert_normals)[3] = BKE_mesh_vertex_normals_ensure(mesh_final);
|
||||
|
||||
if (from == PART_FROM_VERT) {
|
||||
const float(*positions)[3] = BKE_mesh_vert_positions(mesh_final);
|
||||
copy_v3_v3(vec, positions[mapindex]);
|
||||
const float(*vert_positions)[3] = BKE_mesh_vert_positions(mesh_final);
|
||||
copy_v3_v3(vec, vert_positions[mapindex]);
|
||||
|
||||
if (nor) {
|
||||
copy_v3_v3(nor, vert_normals[mapindex]);
|
||||
|
@ -2189,7 +2189,7 @@ void psys_particle_on_dm(Mesh *mesh_final,
|
|||
|
||||
MFace *mfaces = static_cast<MFace *>(CustomData_get_layer(&mesh_final->fdata, CD_MFACE));
|
||||
mface = &mfaces[mapindex];
|
||||
const float(*positions)[3] = BKE_mesh_vert_positions(mesh_final);
|
||||
const float(*vert_positions)[3] = BKE_mesh_vert_positions(mesh_final);
|
||||
mtface = static_cast<MTFace *>(CustomData_get_layer(&mesh_final->fdata, CD_MTFACE));
|
||||
|
||||
if (mtface) {
|
||||
|
@ -2198,7 +2198,7 @@ void psys_particle_on_dm(Mesh *mesh_final,
|
|||
|
||||
if (from == PART_FROM_VOLUME) {
|
||||
psys_interpolate_face(mesh_final,
|
||||
positions,
|
||||
vert_positions,
|
||||
vert_normals,
|
||||
mface,
|
||||
mtface,
|
||||
|
@ -2221,7 +2221,7 @@ void psys_particle_on_dm(Mesh *mesh_final,
|
|||
}
|
||||
else {
|
||||
psys_interpolate_face(mesh_final,
|
||||
positions,
|
||||
vert_positions,
|
||||
vert_normals,
|
||||
mface,
|
||||
mtface,
|
||||
|
@ -3911,10 +3911,10 @@ static void psys_face_mat(Object *ob, Mesh *mesh, ParticleData *pa, float mat[4]
|
|||
}
|
||||
}
|
||||
else {
|
||||
const float(*positions)[3] = BKE_mesh_vert_positions(mesh);
|
||||
copy_v3_v3(v[0], positions[mface->v1]);
|
||||
copy_v3_v3(v[1], positions[mface->v2]);
|
||||
copy_v3_v3(v[2], positions[mface->v3]);
|
||||
const float(*vert_positions)[3] = BKE_mesh_vert_positions(mesh);
|
||||
copy_v3_v3(v[0], vert_positions[mface->v1]);
|
||||
copy_v3_v3(v[1], vert_positions[mface->v2]);
|
||||
copy_v3_v3(v[2], vert_positions[mface->v3]);
|
||||
}
|
||||
|
||||
triatomat(v[0], v[1], v[2], (osface) ? osface->uv : nullptr, mat);
|
||||
|
|
|
@ -3428,7 +3428,7 @@ void BKE_pbvh_parallel_range_settings(TaskParallelSettings *settings,
|
|||
settings->use_threading = use_threading && totnode > 1;
|
||||
}
|
||||
|
||||
float (*BKE_pbvh_get_positions(const PBVH *pbvh))[3]
|
||||
float (*BKE_pbvh_get_vert_positions(const PBVH *pbvh))[3]
|
||||
{
|
||||
BLI_assert(pbvh->header.type == PBVH_FACES);
|
||||
return pbvh->vert_positions;
|
||||
|
|
|
@ -1686,14 +1686,14 @@ static void scene_undo_preserve(BlendLibReader *reader, ID *id_new, ID *id_old)
|
|||
Scene *scene_new = (Scene *)id_new;
|
||||
Scene *scene_old = (Scene *)id_old;
|
||||
|
||||
std::swap( scene_old->cursor, scene_new->cursor);
|
||||
std::swap(scene_old->cursor, scene_new->cursor);
|
||||
if (scene_new->toolsettings != nullptr && scene_old->toolsettings != nullptr) {
|
||||
/* First try to restore ID pointers that can be and should be preserved (like brushes or
|
||||
* palettes), and counteract the swap of the whole ToolSettings structs below for the others
|
||||
* (like object ones). */
|
||||
scene_foreach_toolsettings(
|
||||
nullptr, scene_new->toolsettings, true, reader, scene_old->toolsettings);
|
||||
std::swap( *scene_old->toolsettings, *scene_new->toolsettings);
|
||||
std::swap(*scene_old->toolsettings, *scene_new->toolsettings);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ struct ShrinkwrapCalcData {
|
|||
|
||||
Object *ob; /* object we are applying shrinkwrap to */
|
||||
|
||||
float (*positions)[3]; /* Array of verts being projected. */
|
||||
float (*vert_positions)[3]; /* Array of verts being projected. */
|
||||
const float (*vert_normals)[3];
|
||||
/* Vertices being shrink-wrapped. */
|
||||
float (*vertexCos)[3];
|
||||
|
@ -359,8 +359,8 @@ static void shrinkwrap_calc_nearest_vertex_cb_ex(void *__restrict userdata,
|
|||
}
|
||||
|
||||
/* Convert the vertex to tree coordinates */
|
||||
if (calc->positions) {
|
||||
copy_v3_v3(tmp_co, calc->positions[i]);
|
||||
if (calc->vert_positions) {
|
||||
copy_v3_v3(tmp_co, calc->vert_positions[i]);
|
||||
}
|
||||
else {
|
||||
copy_v3_v3(tmp_co, co);
|
||||
|
@ -521,12 +521,13 @@ static void shrinkwrap_calc_normal_projection_cb_ex(void *__restrict userdata,
|
|||
return;
|
||||
}
|
||||
|
||||
if (calc->positions != nullptr && calc->smd->projAxis == MOD_SHRINKWRAP_PROJECT_OVER_NORMAL) {
|
||||
/* calc->positions contains verts from evaluated mesh. */
|
||||
if (calc->vert_positions != nullptr &&
|
||||
calc->smd->projAxis == MOD_SHRINKWRAP_PROJECT_OVER_NORMAL) {
|
||||
/* calc->vert_positions contains verts from evaluated mesh. */
|
||||
/* These coordinates are deformed by vertexCos only for normal projection
|
||||
* (to get correct normals) for other cases calc->verts contains undeformed coordinates and
|
||||
* vertexCos should be used */
|
||||
copy_v3_v3(tmp_co, calc->positions[i]);
|
||||
copy_v3_v3(tmp_co, calc->vert_positions[i]);
|
||||
copy_v3_v3(tmp_no, calc->vert_normals[i]);
|
||||
}
|
||||
else {
|
||||
|
@ -642,7 +643,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc)
|
|||
|
||||
/* Prepare data to retrieve the direction in which we should project each vertex */
|
||||
if (calc->smd->projAxis == MOD_SHRINKWRAP_PROJECT_OVER_NORMAL) {
|
||||
if (calc->positions == nullptr) {
|
||||
if (calc->vert_positions == nullptr) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1121,8 +1122,8 @@ static void shrinkwrap_calc_nearest_surface_point_cb_ex(void *__restrict userdat
|
|||
}
|
||||
|
||||
/* Convert the vertex to tree coordinates */
|
||||
if (calc->positions) {
|
||||
copy_v3_v3(tmp_co, calc->positions[i]);
|
||||
if (calc->vert_positions) {
|
||||
copy_v3_v3(tmp_co, calc->vert_positions[i]);
|
||||
}
|
||||
else {
|
||||
copy_v3_v3(tmp_co, co);
|
||||
|
@ -1411,7 +1412,7 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd,
|
|||
|
||||
if (mesh != nullptr && smd->shrinkType == MOD_SHRINKWRAP_PROJECT) {
|
||||
/* Setup arrays to get vertexs positions, normals and deform weights */
|
||||
calc.positions = BKE_mesh_vert_positions_for_write(mesh);
|
||||
calc.vert_positions = BKE_mesh_vert_positions_for_write(mesh);
|
||||
calc.vert_normals = BKE_mesh_vertex_normals_ensure(mesh);
|
||||
|
||||
/* Using vertices positions/normals as if a subsurface was applied */
|
||||
|
@ -1431,11 +1432,12 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd,
|
|||
(ob->mode & OB_MODE_EDIT) ? SUBSURF_IN_EDIT_MODE : SubsurfFlags(0));
|
||||
|
||||
if (ss_mesh) {
|
||||
calc.positions = reinterpret_cast<float(*)[3]>(ss_mesh->getVertArray(ss_mesh));
|
||||
if (calc.positions) {
|
||||
calc.vert_positions = reinterpret_cast<float(*)[3]>(ss_mesh->getVertArray(ss_mesh));
|
||||
if (calc.vert_positions) {
|
||||
/* TRICKY: this code assumes subsurface will have the transformed original vertices
|
||||
* in their original order at the end of the vert array. */
|
||||
calc.positions = calc.positions + ss_mesh->getNumVerts(ss_mesh) - dm->getNumVerts(dm);
|
||||
calc.vert_positions = calc.vert_positions + ss_mesh->getNumVerts(ss_mesh) -
|
||||
dm->getNumVerts(dm);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1576,7 +1578,7 @@ void BKE_shrinkwrap_remesh_target_project(Mesh *src_me, Mesh *target_me, Object
|
|||
calc.vgroup = -1;
|
||||
calc.target = target_me;
|
||||
calc.keepDist = ssmd.keepDist;
|
||||
calc.positions = BKE_mesh_vert_positions_for_write(src_me);
|
||||
calc.vert_positions = BKE_mesh_vert_positions_for_write(src_me);
|
||||
BLI_SPACE_TRANSFORM_SETUP(&calc.local2target, ob_target, ob_target);
|
||||
|
||||
ShrinkwrapTreeData tree;
|
||||
|
|
|
@ -255,8 +255,8 @@ typedef struct ccdf_minmax {
|
|||
|
||||
typedef struct ccd_Mesh {
|
||||
int mvert_num, tri_num;
|
||||
const float (*positions)[3];
|
||||
const float (*positions_prev)[3];
|
||||
const float (*vert_positions)[3];
|
||||
const float (*vert_positions_prev)[3];
|
||||
const MVertTri *tri;
|
||||
int safety;
|
||||
ccdf_minmax *mima;
|
||||
|
@ -290,20 +290,20 @@ static ccd_Mesh *ccd_mesh_make(Object *ob)
|
|||
pccd_M->safety = CCD_SAFETY;
|
||||
pccd_M->bbmin[0] = pccd_M->bbmin[1] = pccd_M->bbmin[2] = 1e30f;
|
||||
pccd_M->bbmax[0] = pccd_M->bbmax[1] = pccd_M->bbmax[2] = -1e30f;
|
||||
pccd_M->positions_prev = NULL;
|
||||
pccd_M->vert_positions_prev = NULL;
|
||||
|
||||
/* Blow it up with force-field ranges. */
|
||||
hull = max_ff(ob->pd->pdef_sbift, ob->pd->pdef_sboft);
|
||||
|
||||
/* Allocate and copy verts. */
|
||||
pccd_M->positions = MEM_dupallocN(cmd->xnew);
|
||||
pccd_M->vert_positions = MEM_dupallocN(cmd->xnew);
|
||||
/* note that xnew coords are already in global space, */
|
||||
/* determine the ortho BB */
|
||||
for (i = 0; i < pccd_M->mvert_num; i++) {
|
||||
const float *v;
|
||||
|
||||
/* evaluate limits */
|
||||
v = pccd_M->positions[i];
|
||||
v = pccd_M->vert_positions[i];
|
||||
pccd_M->bbmin[0] = min_ff(pccd_M->bbmin[0], v[0] - hull);
|
||||
pccd_M->bbmin[1] = min_ff(pccd_M->bbmin[1], v[1] - hull);
|
||||
pccd_M->bbmin[2] = min_ff(pccd_M->bbmin[2], v[2] - hull);
|
||||
|
@ -325,7 +325,7 @@ static ccd_Mesh *ccd_mesh_make(Object *ob)
|
|||
mima->minx = mima->miny = mima->minz = 1e30f;
|
||||
mima->maxx = mima->maxy = mima->maxz = -1e30f;
|
||||
|
||||
v = pccd_M->positions[vt->tri[0]];
|
||||
v = pccd_M->vert_positions[vt->tri[0]];
|
||||
mima->minx = min_ff(mima->minx, v[0] - hull);
|
||||
mima->miny = min_ff(mima->miny, v[1] - hull);
|
||||
mima->minz = min_ff(mima->minz, v[2] - hull);
|
||||
|
@ -333,7 +333,7 @@ static ccd_Mesh *ccd_mesh_make(Object *ob)
|
|||
mima->maxy = max_ff(mima->maxy, v[1] + hull);
|
||||
mima->maxz = max_ff(mima->maxz, v[2] + hull);
|
||||
|
||||
v = pccd_M->positions[vt->tri[1]];
|
||||
v = pccd_M->vert_positions[vt->tri[1]];
|
||||
mima->minx = min_ff(mima->minx, v[0] - hull);
|
||||
mima->miny = min_ff(mima->miny, v[1] - hull);
|
||||
mima->minz = min_ff(mima->minz, v[2] - hull);
|
||||
|
@ -341,7 +341,7 @@ static ccd_Mesh *ccd_mesh_make(Object *ob)
|
|||
mima->maxy = max_ff(mima->maxy, v[1] + hull);
|
||||
mima->maxz = max_ff(mima->maxz, v[2] + hull);
|
||||
|
||||
v = pccd_M->positions[vt->tri[2]];
|
||||
v = pccd_M->vert_positions[vt->tri[2]];
|
||||
mima->minx = min_ff(mima->minx, v[0] - hull);
|
||||
mima->miny = min_ff(mima->miny, v[1] - hull);
|
||||
mima->minz = min_ff(mima->minz, v[2] - hull);
|
||||
|
@ -381,19 +381,19 @@ static void ccd_mesh_update(Object *ob, ccd_Mesh *pccd_M)
|
|||
hull = max_ff(ob->pd->pdef_sbift, ob->pd->pdef_sboft);
|
||||
|
||||
/* rotate current to previous */
|
||||
if (pccd_M->positions_prev) {
|
||||
MEM_freeN((void *)pccd_M->positions_prev);
|
||||
if (pccd_M->vert_positions_prev) {
|
||||
MEM_freeN((void *)pccd_M->vert_positions_prev);
|
||||
}
|
||||
pccd_M->positions_prev = pccd_M->positions;
|
||||
pccd_M->vert_positions_prev = pccd_M->vert_positions;
|
||||
/* Allocate and copy verts. */
|
||||
pccd_M->positions = MEM_dupallocN(cmd->xnew);
|
||||
pccd_M->vert_positions = MEM_dupallocN(cmd->xnew);
|
||||
/* note that xnew coords are already in global space, */
|
||||
/* determine the ortho BB */
|
||||
for (i = 0; i < pccd_M->mvert_num; i++) {
|
||||
const float *v;
|
||||
|
||||
/* evaluate limits */
|
||||
v = pccd_M->positions[i];
|
||||
v = pccd_M->vert_positions[i];
|
||||
pccd_M->bbmin[0] = min_ff(pccd_M->bbmin[0], v[0] - hull);
|
||||
pccd_M->bbmin[1] = min_ff(pccd_M->bbmin[1], v[1] - hull);
|
||||
pccd_M->bbmin[2] = min_ff(pccd_M->bbmin[2], v[2] - hull);
|
||||
|
@ -403,7 +403,7 @@ static void ccd_mesh_update(Object *ob, ccd_Mesh *pccd_M)
|
|||
pccd_M->bbmax[2] = max_ff(pccd_M->bbmax[2], v[2] + hull);
|
||||
|
||||
/* evaluate limits */
|
||||
v = pccd_M->positions_prev[i];
|
||||
v = pccd_M->vert_positions_prev[i];
|
||||
pccd_M->bbmin[0] = min_ff(pccd_M->bbmin[0], v[0] - hull);
|
||||
pccd_M->bbmin[1] = min_ff(pccd_M->bbmin[1], v[1] - hull);
|
||||
pccd_M->bbmin[2] = min_ff(pccd_M->bbmin[2], v[2] - hull);
|
||||
|
@ -420,8 +420,8 @@ static void ccd_mesh_update(Object *ob, ccd_Mesh *pccd_M)
|
|||
mima->minx = mima->miny = mima->minz = 1e30f;
|
||||
mima->maxx = mima->maxy = mima->maxz = -1e30f;
|
||||
|
||||
/* positions */
|
||||
v = pccd_M->positions[vt->tri[0]];
|
||||
/* vert_positions */
|
||||
v = pccd_M->vert_positions[vt->tri[0]];
|
||||
mima->minx = min_ff(mima->minx, v[0] - hull);
|
||||
mima->miny = min_ff(mima->miny, v[1] - hull);
|
||||
mima->minz = min_ff(mima->minz, v[2] - hull);
|
||||
|
@ -429,7 +429,7 @@ static void ccd_mesh_update(Object *ob, ccd_Mesh *pccd_M)
|
|||
mima->maxy = max_ff(mima->maxy, v[1] + hull);
|
||||
mima->maxz = max_ff(mima->maxz, v[2] + hull);
|
||||
|
||||
v = pccd_M->positions[vt->tri[1]];
|
||||
v = pccd_M->vert_positions[vt->tri[1]];
|
||||
mima->minx = min_ff(mima->minx, v[0] - hull);
|
||||
mima->miny = min_ff(mima->miny, v[1] - hull);
|
||||
mima->minz = min_ff(mima->minz, v[2] - hull);
|
||||
|
@ -437,7 +437,7 @@ static void ccd_mesh_update(Object *ob, ccd_Mesh *pccd_M)
|
|||
mima->maxy = max_ff(mima->maxy, v[1] + hull);
|
||||
mima->maxz = max_ff(mima->maxz, v[2] + hull);
|
||||
|
||||
v = pccd_M->positions[vt->tri[2]];
|
||||
v = pccd_M->vert_positions[vt->tri[2]];
|
||||
mima->minx = min_ff(mima->minx, v[0] - hull);
|
||||
mima->miny = min_ff(mima->miny, v[1] - hull);
|
||||
mima->minz = min_ff(mima->minz, v[2] - hull);
|
||||
|
@ -445,8 +445,8 @@ static void ccd_mesh_update(Object *ob, ccd_Mesh *pccd_M)
|
|||
mima->maxy = max_ff(mima->maxy, v[1] + hull);
|
||||
mima->maxz = max_ff(mima->maxz, v[2] + hull);
|
||||
|
||||
/* positions_prev */
|
||||
v = pccd_M->positions_prev[vt->tri[0]];
|
||||
/* vert_positions_prev */
|
||||
v = pccd_M->vert_positions_prev[vt->tri[0]];
|
||||
mima->minx = min_ff(mima->minx, v[0] - hull);
|
||||
mima->miny = min_ff(mima->miny, v[1] - hull);
|
||||
mima->minz = min_ff(mima->minz, v[2] - hull);
|
||||
|
@ -454,7 +454,7 @@ static void ccd_mesh_update(Object *ob, ccd_Mesh *pccd_M)
|
|||
mima->maxy = max_ff(mima->maxy, v[1] + hull);
|
||||
mima->maxz = max_ff(mima->maxz, v[2] + hull);
|
||||
|
||||
v = pccd_M->positions_prev[vt->tri[1]];
|
||||
v = pccd_M->vert_positions_prev[vt->tri[1]];
|
||||
mima->minx = min_ff(mima->minx, v[0] - hull);
|
||||
mima->miny = min_ff(mima->miny, v[1] - hull);
|
||||
mima->minz = min_ff(mima->minz, v[2] - hull);
|
||||
|
@ -462,7 +462,7 @@ static void ccd_mesh_update(Object *ob, ccd_Mesh *pccd_M)
|
|||
mima->maxy = max_ff(mima->maxy, v[1] + hull);
|
||||
mima->maxz = max_ff(mima->maxz, v[2] + hull);
|
||||
|
||||
v = pccd_M->positions_prev[vt->tri[2]];
|
||||
v = pccd_M->vert_positions_prev[vt->tri[2]];
|
||||
mima->minx = min_ff(mima->minx, v[0] - hull);
|
||||
mima->miny = min_ff(mima->miny, v[1] - hull);
|
||||
mima->minz = min_ff(mima->minz, v[2] - hull);
|
||||
|
@ -476,10 +476,10 @@ static void ccd_mesh_free(ccd_Mesh *ccdm)
|
|||
{
|
||||
/* Make sure we're not nuking objects we don't know. */
|
||||
if (ccdm && (ccdm->safety == CCD_SAFETY)) {
|
||||
MEM_freeN((void *)ccdm->positions);
|
||||
MEM_freeN((void *)ccdm->vert_positions);
|
||||
MEM_freeN((void *)ccdm->tri);
|
||||
if (ccdm->positions_prev) {
|
||||
MEM_freeN((void *)ccdm->positions_prev);
|
||||
if (ccdm->vert_positions_prev) {
|
||||
MEM_freeN((void *)ccdm->vert_positions_prev);
|
||||
}
|
||||
MEM_freeN(ccdm->mima);
|
||||
MEM_freeN(ccdm);
|
||||
|
@ -1068,12 +1068,12 @@ static int sb_detect_face_pointCached(const float face_v1[3],
|
|||
{
|
||||
/* only with deflecting set */
|
||||
if (ob->pd && ob->pd->deflect) {
|
||||
const float(*positions)[3] = NULL;
|
||||
const float(*positions_prev)[3] = NULL;
|
||||
const float(*vert_positions)[3] = NULL;
|
||||
const float(*vert_positions_prev)[3] = NULL;
|
||||
if (ccdm) {
|
||||
positions = ccdm->positions;
|
||||
vert_positions = ccdm->vert_positions;
|
||||
a = ccdm->mvert_num;
|
||||
positions_prev = ccdm->positions_prev;
|
||||
vert_positions_prev = ccdm->vert_positions_prev;
|
||||
outerfacethickness = ob->pd->pdef_sboft;
|
||||
if ((aabbmax[0] < ccdm->bbmin[0]) || (aabbmax[1] < ccdm->bbmin[1]) ||
|
||||
(aabbmax[2] < ccdm->bbmin[2]) || (aabbmin[0] > ccdm->bbmax[0]) ||
|
||||
|
@ -1091,12 +1091,12 @@ static int sb_detect_face_pointCached(const float face_v1[3],
|
|||
}
|
||||
|
||||
/* Use mesh. */
|
||||
if (positions) {
|
||||
if (vert_positions) {
|
||||
while (a) {
|
||||
copy_v3_v3(nv1, positions[a - 1]);
|
||||
if (positions_prev) {
|
||||
copy_v3_v3(nv1, vert_positions[a - 1]);
|
||||
if (vert_positions_prev) {
|
||||
mul_v3_fl(nv1, time);
|
||||
madd_v3_v3fl(nv1, positions_prev[a - 1], 1.0f - time);
|
||||
madd_v3_v3fl(nv1, vert_positions_prev[a - 1], 1.0f - time);
|
||||
}
|
||||
/* Origin to face_v2. */
|
||||
sub_v3_v3(nv1, face_v2);
|
||||
|
@ -1120,7 +1120,7 @@ static int sb_detect_face_pointCached(const float face_v1[3],
|
|||
}
|
||||
a--;
|
||||
} /* while (a) */
|
||||
} /* if (positions) */
|
||||
} /* if (vert_positions) */
|
||||
} /* if (ob->pd && ob->pd->deflect) */
|
||||
BLI_ghashIterator_step(ihash);
|
||||
}
|
||||
|
@ -1160,15 +1160,15 @@ static int sb_detect_face_collisionCached(const float face_v1[3],
|
|||
{
|
||||
/* only with deflecting set */
|
||||
if (ob->pd && ob->pd->deflect) {
|
||||
const float(*positions)[3] = NULL;
|
||||
const float(*positions_prev)[3] = NULL;
|
||||
const float(*vert_positions)[3] = NULL;
|
||||
const float(*vert_positions_prev)[3] = NULL;
|
||||
const MVertTri *vt = NULL;
|
||||
const ccdf_minmax *mima = NULL;
|
||||
|
||||
if (ccdm) {
|
||||
positions = ccdm->positions;
|
||||
vert_positions = ccdm->vert_positions;
|
||||
vt = ccdm->tri;
|
||||
positions_prev = ccdm->positions_prev;
|
||||
vert_positions_prev = ccdm->vert_positions_prev;
|
||||
mima = ccdm->mima;
|
||||
a = ccdm->tri_num;
|
||||
|
||||
|
@ -1197,21 +1197,21 @@ static int sb_detect_face_collisionCached(const float face_v1[3],
|
|||
continue;
|
||||
}
|
||||
|
||||
if (positions) {
|
||||
if (vert_positions) {
|
||||
|
||||
copy_v3_v3(nv1, positions[vt->tri[0]]);
|
||||
copy_v3_v3(nv2, positions[vt->tri[1]]);
|
||||
copy_v3_v3(nv3, positions[vt->tri[2]]);
|
||||
copy_v3_v3(nv1, vert_positions[vt->tri[0]]);
|
||||
copy_v3_v3(nv2, vert_positions[vt->tri[1]]);
|
||||
copy_v3_v3(nv3, vert_positions[vt->tri[2]]);
|
||||
|
||||
if (positions_prev) {
|
||||
if (vert_positions_prev) {
|
||||
mul_v3_fl(nv1, time);
|
||||
madd_v3_v3fl(nv1, positions_prev[vt->tri[0]], 1.0f - time);
|
||||
madd_v3_v3fl(nv1, vert_positions_prev[vt->tri[0]], 1.0f - time);
|
||||
|
||||
mul_v3_fl(nv2, time);
|
||||
madd_v3_v3fl(nv2, positions_prev[vt->tri[1]], 1.0f - time);
|
||||
madd_v3_v3fl(nv2, vert_positions_prev[vt->tri[1]], 1.0f - time);
|
||||
|
||||
mul_v3_fl(nv3, time);
|
||||
madd_v3_v3fl(nv3, positions_prev[vt->tri[2]], 1.0f - time);
|
||||
madd_v3_v3fl(nv3, vert_positions_prev[vt->tri[2]], 1.0f - time);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1336,14 +1336,14 @@ static int sb_detect_edge_collisionCached(const float edge_v1[3],
|
|||
{
|
||||
/* only with deflecting set */
|
||||
if (ob->pd && ob->pd->deflect) {
|
||||
const float(*positions)[3] = NULL;
|
||||
const float(*positions_prev)[3] = NULL;
|
||||
const float(*vert_positions)[3] = NULL;
|
||||
const float(*vert_positions_prev)[3] = NULL;
|
||||
const MVertTri *vt = NULL;
|
||||
const ccdf_minmax *mima = NULL;
|
||||
|
||||
if (ccdm) {
|
||||
positions = ccdm->positions;
|
||||
positions_prev = ccdm->positions_prev;
|
||||
vert_positions = ccdm->vert_positions;
|
||||
vert_positions_prev = ccdm->vert_positions_prev;
|
||||
vt = ccdm->tri;
|
||||
mima = ccdm->mima;
|
||||
a = ccdm->tri_num;
|
||||
|
@ -1373,21 +1373,21 @@ static int sb_detect_edge_collisionCached(const float edge_v1[3],
|
|||
continue;
|
||||
}
|
||||
|
||||
if (positions) {
|
||||
if (vert_positions) {
|
||||
|
||||
copy_v3_v3(nv1, positions[vt->tri[0]]);
|
||||
copy_v3_v3(nv2, positions[vt->tri[1]]);
|
||||
copy_v3_v3(nv3, positions[vt->tri[2]]);
|
||||
copy_v3_v3(nv1, vert_positions[vt->tri[0]]);
|
||||
copy_v3_v3(nv2, vert_positions[vt->tri[1]]);
|
||||
copy_v3_v3(nv3, vert_positions[vt->tri[2]]);
|
||||
|
||||
if (positions_prev) {
|
||||
if (vert_positions_prev) {
|
||||
mul_v3_fl(nv1, time);
|
||||
madd_v3_v3fl(nv1, positions_prev[vt->tri[0]], 1.0f - time);
|
||||
madd_v3_v3fl(nv1, vert_positions_prev[vt->tri[0]], 1.0f - time);
|
||||
|
||||
mul_v3_fl(nv2, time);
|
||||
madd_v3_v3fl(nv2, positions_prev[vt->tri[1]], 1.0f - time);
|
||||
madd_v3_v3fl(nv2, vert_positions_prev[vt->tri[1]], 1.0f - time);
|
||||
|
||||
mul_v3_fl(nv3, time);
|
||||
madd_v3_v3fl(nv3, positions_prev[vt->tri[2]], 1.0f - time);
|
||||
madd_v3_v3fl(nv3, vert_positions_prev[vt->tri[2]], 1.0f - time);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1635,14 +1635,14 @@ static int sb_detect_vertex_collisionCached(float opco[3],
|
|||
{
|
||||
/* only with deflecting set */
|
||||
if (ob->pd && ob->pd->deflect) {
|
||||
const float(*positions)[3] = NULL;
|
||||
const float(*positions_prev)[3] = NULL;
|
||||
const float(*vert_positions)[3] = NULL;
|
||||
const float(*vert_positions_prev)[3] = NULL;
|
||||
const MVertTri *vt = NULL;
|
||||
const ccdf_minmax *mima = NULL;
|
||||
|
||||
if (ccdm) {
|
||||
positions = ccdm->positions;
|
||||
positions_prev = ccdm->positions_prev;
|
||||
vert_positions = ccdm->vert_positions;
|
||||
vert_positions_prev = ccdm->vert_positions_prev;
|
||||
vt = ccdm->tri;
|
||||
mima = ccdm->mima;
|
||||
a = ccdm->tri_num;
|
||||
|
@ -1686,30 +1686,30 @@ static int sb_detect_vertex_collisionCached(float opco[3],
|
|||
continue;
|
||||
}
|
||||
|
||||
if (positions) {
|
||||
if (vert_positions) {
|
||||
|
||||
copy_v3_v3(nv1, positions[vt->tri[0]]);
|
||||
copy_v3_v3(nv2, positions[vt->tri[1]]);
|
||||
copy_v3_v3(nv3, positions[vt->tri[2]]);
|
||||
copy_v3_v3(nv1, vert_positions[vt->tri[0]]);
|
||||
copy_v3_v3(nv2, vert_positions[vt->tri[1]]);
|
||||
copy_v3_v3(nv3, vert_positions[vt->tri[2]]);
|
||||
|
||||
if (positions_prev) {
|
||||
if (vert_positions_prev) {
|
||||
/* Grab the average speed of the collider vertices before we spoil nvX
|
||||
* humm could be done once a SB steps but then we' need to store that too
|
||||
* since the AABB reduced probability to get here drastically
|
||||
* it might be a nice tradeoff CPU <--> memory.
|
||||
*/
|
||||
sub_v3_v3v3(vv1, nv1, positions_prev[vt->tri[0]]);
|
||||
sub_v3_v3v3(vv2, nv2, positions_prev[vt->tri[1]]);
|
||||
sub_v3_v3v3(vv3, nv3, positions_prev[vt->tri[2]]);
|
||||
sub_v3_v3v3(vv1, nv1, vert_positions_prev[vt->tri[0]]);
|
||||
sub_v3_v3v3(vv2, nv2, vert_positions_prev[vt->tri[1]]);
|
||||
sub_v3_v3v3(vv3, nv3, vert_positions_prev[vt->tri[2]]);
|
||||
|
||||
mul_v3_fl(nv1, time);
|
||||
madd_v3_v3fl(nv1, positions_prev[vt->tri[0]], 1.0f - time);
|
||||
madd_v3_v3fl(nv1, vert_positions_prev[vt->tri[0]], 1.0f - time);
|
||||
|
||||
mul_v3_fl(nv2, time);
|
||||
madd_v3_v3fl(nv2, positions_prev[vt->tri[1]], 1.0f - time);
|
||||
madd_v3_v3fl(nv2, vert_positions_prev[vt->tri[1]], 1.0f - time);
|
||||
|
||||
mul_v3_fl(nv3, time);
|
||||
madd_v3_v3fl(nv3, positions_prev[vt->tri[2]], 1.0f - time);
|
||||
madd_v3_v3fl(nv3, vert_positions_prev[vt->tri[2]], 1.0f - time);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1743,7 +1743,7 @@ static int sb_detect_vertex_collisionCached(float opco[3],
|
|||
deflected = 2;
|
||||
}
|
||||
}
|
||||
if ((positions_prev) && (*damp > 0.0f)) {
|
||||
if ((vert_positions_prev) && (*damp > 0.0f)) {
|
||||
choose_winner(ve, opco, nv1, nv2, nv3, vv1, vv2, vv3);
|
||||
add_v3_v3(avel, ve);
|
||||
cavel++;
|
||||
|
@ -2632,18 +2632,18 @@ static void springs_from_mesh(Object *ob)
|
|||
BodyPoint *bp;
|
||||
int a;
|
||||
float scale = 1.0f;
|
||||
const float(*positions)[3] = BKE_mesh_vert_positions(me);
|
||||
const float(*vert_positions)[3] = BKE_mesh_vert_positions(me);
|
||||
|
||||
sb = ob->soft;
|
||||
if (me && sb) {
|
||||
/* using bp->origS as a container for spring calculations here
|
||||
* will be overwritten sbObjectStep() to receive
|
||||
* actual modifier stack positions
|
||||
* actual modifier stack vert_positions
|
||||
*/
|
||||
if (me->totvert) {
|
||||
bp = ob->soft->bpoint;
|
||||
for (a = 0; a < me->totvert; a++, bp++) {
|
||||
copy_v3_v3(bp->origS, positions[a]);
|
||||
copy_v3_v3(bp->origS, vert_positions[a]);
|
||||
mul_m4_v3(ob->object_to_world, bp->origS);
|
||||
}
|
||||
}
|
||||
|
@ -2755,7 +2755,7 @@ static void mesh_faces_to_scratch(Object *ob)
|
|||
MLoopTri *looptri, *lt;
|
||||
BodyFace *bodyface;
|
||||
int a;
|
||||
const float(*positions)[3] = BKE_mesh_vert_positions(me);
|
||||
const float(*vert_positions)[3] = BKE_mesh_vert_positions(me);
|
||||
const MPoly *polys = BKE_mesh_polys(me);
|
||||
const int *corner_verts = BKE_mesh_corner_verts(me);
|
||||
|
||||
|
@ -2763,7 +2763,7 @@ static void mesh_faces_to_scratch(Object *ob)
|
|||
|
||||
sb->scratch->totface = poly_to_tri_count(me->totpoly, me->totloop);
|
||||
looptri = lt = MEM_mallocN(sizeof(*looptri) * sb->scratch->totface, __func__);
|
||||
BKE_mesh_recalc_looptri(corner_verts, polys, positions, me->totloop, me->totpoly, looptri);
|
||||
BKE_mesh_recalc_looptri(corner_verts, polys, vert_positions, me->totloop, me->totpoly, looptri);
|
||||
|
||||
bodyface = sb->scratch->bodyface = MEM_mallocN(sizeof(BodyFace) * sb->scratch->totface,
|
||||
"SB_body_Faces");
|
||||
|
@ -3564,7 +3564,7 @@ void sbObjectStep(struct Depsgraph *depsgraph,
|
|||
if (framenr == startframe) {
|
||||
BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED);
|
||||
|
||||
/* first frame, no simulation to do, just set the positions */
|
||||
/* first frame, no simulation to do, just set the vert_positions */
|
||||
softbody_update_positions(ob, sb, vertexCos, numVerts);
|
||||
|
||||
BKE_ptcache_validate(cache, framenr);
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
typedef struct ConverterStorage {
|
||||
SubdivSettings settings;
|
||||
const Mesh *mesh;
|
||||
const float (*positions)[3];
|
||||
const float (*vert_positions)[3];
|
||||
const MEdge *edges;
|
||||
const MPoly *polys;
|
||||
const int *corner_verts;
|
||||
|
@ -394,7 +394,7 @@ static void init_user_data(OpenSubdiv_Converter *converter,
|
|||
ConverterStorage *user_data = MEM_mallocN(sizeof(ConverterStorage), __func__);
|
||||
user_data->settings = *settings;
|
||||
user_data->mesh = mesh;
|
||||
user_data->positions = BKE_mesh_vert_positions(mesh);
|
||||
user_data->vert_positions = BKE_mesh_vert_positions(mesh);
|
||||
user_data->edges = BKE_mesh_edges(mesh);
|
||||
user_data->polys = BKE_mesh_polys(mesh);
|
||||
user_data->corner_verts = BKE_mesh_corner_verts(mesh);
|
||||
|
|
|
@ -113,12 +113,12 @@ void fill_mesh_from_openvdb_data(const Span<openvdb::Vec3s> vdb_verts,
|
|||
const int vert_offset,
|
||||
const int poly_offset,
|
||||
const int loop_offset,
|
||||
MutableSpan<float3> positions,
|
||||
MutableSpan<float3> vert_positions,
|
||||
MutableSpan<MPoly> polys,
|
||||
MutableSpan<int> corner_verts)
|
||||
{
|
||||
/* Write vertices. */
|
||||
positions.slice(vert_offset, vdb_verts.size()).copy_from(vdb_verts.cast<float3>());
|
||||
vert_positions.slice(vert_offset, vdb_verts.size()).copy_from(vdb_verts.cast<float3>());
|
||||
|
||||
/* Write triangles. */
|
||||
for (const int i : vdb_tris.index_range()) {
|
||||
|
|
|
@ -181,8 +181,8 @@ void NodeGraph::add_proxies_mute(bNodeTree *b_ntree,
|
|||
bNodeInstanceKey key,
|
||||
bool is_active_group)
|
||||
{
|
||||
for (const bNodeLink *b_link : b_node->internal_links()) {
|
||||
SocketProxyNode *proxy = new SocketProxyNode(b_node, b_link->fromsock, b_link->tosock, false);
|
||||
for (const bNodeLink &b_link : b_node->internal_links()) {
|
||||
SocketProxyNode *proxy = new SocketProxyNode(b_node, b_link.fromsock, b_link.tosock, false);
|
||||
add_node(proxy, b_ntree, key, is_active_group);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -404,7 +404,7 @@ BLI_INLINE void extract_task_range_run_iter(const MeshRenderData *mr,
|
|||
break;
|
||||
case MR_ITER_LVERT:
|
||||
range_data.loose_elems = mr->lverts;
|
||||
range_data.elems = is_mesh ? mr->positions : (void *)mr->bm->vtable;
|
||||
range_data.elems = is_mesh ? mr->vert_positions : (void *)mr->bm->vtable;
|
||||
func = is_mesh ? extract_range_iter_lvert_mesh : extract_range_iter_lvert_bm;
|
||||
stop = mr->vert_loose_len;
|
||||
break;
|
||||
|
|
|
@ -368,7 +368,7 @@ void mesh_render_data_update_normals(MeshRenderData *mr, const eMRDataType data_
|
|||
MEM_mallocN(sizeof(*mr->loop_normals) * mr->loop_len, __func__));
|
||||
short(*clnors)[2] = static_cast<short(*)[2]>(
|
||||
CustomData_get_layer(&mr->me->ldata, CD_CUSTOMLOOPNORMAL));
|
||||
BKE_mesh_normals_loop_split(reinterpret_cast<const float(*)[3]>(mr->positions),
|
||||
BKE_mesh_normals_loop_split(reinterpret_cast<const float(*)[3]>(mr->vert_positions),
|
||||
mr->vert_normals,
|
||||
mr->vert_len,
|
||||
mr->medge,
|
||||
|
@ -543,7 +543,7 @@ MeshRenderData *mesh_render_data_create(Object *object,
|
|||
mr->poly_len = mr->me->totpoly;
|
||||
mr->tri_len = poly_to_tri_count(mr->poly_len, mr->loop_len);
|
||||
|
||||
mr->positions = mr->me->vert_positions().data();
|
||||
mr->vert_positions = mr->me->vert_positions().data();
|
||||
mr->medge = BKE_mesh_edges(mr->me);
|
||||
mr->mpoly = BKE_mesh_polys(mr->me);
|
||||
mr->corner_verts = BKE_mesh_corner_verts(mr->me);
|
||||
|
|
|
@ -74,7 +74,7 @@ struct MeshRenderData {
|
|||
int freestyle_face_ofs;
|
||||
/** Mesh */
|
||||
Mesh *me;
|
||||
const blender::float3 *positions;
|
||||
const blender::float3 *vert_positions;
|
||||
const MEdge *medge;
|
||||
const int *corner_verts;
|
||||
const int *corner_edges;
|
||||
|
|
|
@ -131,9 +131,9 @@ static void extract_edge_fac_iter_poly_mesh(const MeshRenderData *mr,
|
|||
const int ml_index_other = (ml_index == ml_index_last) ? mp->loopstart : (ml_index + 1);
|
||||
const int vert_next = mr->corner_verts[ml_index_other];
|
||||
float ratio = loop_edge_factor_get(mr->poly_normals[mp_index],
|
||||
mr->positions[vert_i],
|
||||
mr->vert_positions[vert_i],
|
||||
mr->vert_normals[vert_i],
|
||||
mr->positions[vert_next]);
|
||||
mr->vert_positions[vert_next]);
|
||||
data->vbo_data[ml_index] = ratio * 253 + 1;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -175,8 +175,8 @@ static void extract_edituv_stretch_angle_iter_poly_mesh(const MeshRenderData *mr
|
|||
av,
|
||||
data->luv[ml_index_last].uv,
|
||||
data->luv[l_next_tmp].uv,
|
||||
mr->positions[mr->corner_verts[ml_index_last]],
|
||||
mr->positions[mr->corner_verts[l_next_tmp]]);
|
||||
mr->vert_positions[mr->corner_verts[ml_index_last]],
|
||||
mr->vert_positions[mr->corner_verts[l_next_tmp]]);
|
||||
/* Save last edge. */
|
||||
copy_v2_v2(last_auv, auv[1]);
|
||||
copy_v3_v3(last_av, av[1]);
|
||||
|
@ -195,8 +195,8 @@ static void extract_edituv_stretch_angle_iter_poly_mesh(const MeshRenderData *mr
|
|||
av,
|
||||
data->luv[ml_index].uv,
|
||||
data->luv[l_next].uv,
|
||||
mr->positions[mr->corner_verts[ml_index]],
|
||||
mr->positions[mr->corner_verts[l_next]]);
|
||||
mr->vert_positions[mr->corner_verts[ml_index]],
|
||||
mr->vert_positions[mr->corner_verts[l_next]]);
|
||||
}
|
||||
edituv_get_edituv_stretch_angle(auv, av, &data->vbo_data[ml_index]);
|
||||
}
|
||||
|
|
|
@ -75,9 +75,10 @@ static void compute_area_ratio(const MeshRenderData *mr,
|
|||
const MLoopUV *uv_data = (const MLoopUV *)CustomData_get_layer(&mr->me->ldata, CD_MLOOPUV);
|
||||
const MPoly *mp = mr->mpoly;
|
||||
for (int mp_index = 0; mp_index < mr->poly_len; mp_index++, mp++) {
|
||||
float area = BKE_mesh_calc_poly_area(mp,
|
||||
&mr->corner_verts[mp->loopstart],
|
||||
reinterpret_cast<const float(*)[3]>(mr->positions));
|
||||
float area = BKE_mesh_calc_poly_area(
|
||||
mp,
|
||||
&mr->corner_verts[mp->loopstart],
|
||||
reinterpret_cast<const float(*)[3]>(mr->vert_positions));
|
||||
float uvarea = BKE_mesh_calc_poly_uv_area(mp, uv_data);
|
||||
tot_area += area;
|
||||
tot_uv_area += uvarea;
|
||||
|
|
|
@ -82,12 +82,12 @@ static void extract_fdots_pos_iter_poly_mesh(const MeshRenderData *mr,
|
|||
const int vert_i = mr->corner_verts[ml_index];
|
||||
if (mr->use_subsurf_fdots) {
|
||||
if (BLI_BITMAP_TEST(facedot_tags, vert_i)) {
|
||||
copy_v3_v3(center[mp_index], mr->positions[vert_i]);
|
||||
copy_v3_v3(center[mp_index], mr->vert_positions[vert_i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
add_v3_v3(center[mp_index], mr->positions[vert_i]);
|
||||
add_v3_v3(center[mp_index], mr->vert_positions[vert_i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -217,9 +217,9 @@ static void statvis_calc_thickness(const MeshRenderData *mr, float *r_thickness)
|
|||
const MLoopTri *mlooptri = mr->mlooptri;
|
||||
for (int i = 0; i < mr->tri_len; i++, mlooptri++) {
|
||||
const int index = mlooptri->poly;
|
||||
const float *cos[3] = {mr->positions[mr->corner_verts[mlooptri->tri[0]]],
|
||||
mr->positions[mr->corner_verts[mlooptri->tri[1]]],
|
||||
mr->positions[mr->corner_verts[mlooptri->tri[2]]]};
|
||||
const float *cos[3] = {mr->vert_positions[mr->corner_verts[mlooptri->tri[0]]],
|
||||
mr->vert_positions[mr->corner_verts[mlooptri->tri[1]]],
|
||||
mr->vert_positions[mr->corner_verts[mlooptri->tri[2]]]};
|
||||
float ray_co[3];
|
||||
float ray_no[3];
|
||||
|
||||
|
@ -342,7 +342,7 @@ static void statvis_calc_intersect(const MeshRenderData *mr, float *r_intersect)
|
|||
BVHTree *tree = BKE_bvhtree_from_mesh_get(&treeData, mr->me, BVHTREE_FROM_LOOPTRI, 4);
|
||||
|
||||
struct BVHTree_OverlapData data = {nullptr};
|
||||
data.positions = mr->positions;
|
||||
data.positions = mr->vert_positions;
|
||||
data.corner_verts = mr->corner_verts;
|
||||
data.mlooptri = mr->mlooptri;
|
||||
data.epsilon = BLI_bvhtree_get_epsilon(tree);
|
||||
|
@ -454,9 +454,9 @@ static void statvis_calc_distort(const MeshRenderData *mr, float *r_distort)
|
|||
const int corner_next = mp->loopstart + (i + 1) % mp->totloop;
|
||||
float no_corner[3];
|
||||
normal_tri_v3(no_corner,
|
||||
mr->positions[mr->corner_verts[corner_prev]],
|
||||
mr->positions[mr->corner_verts[corner_curr]],
|
||||
mr->positions[mr->corner_verts[corner_next]]);
|
||||
mr->vert_positions[mr->corner_verts[corner_prev]],
|
||||
mr->vert_positions[mr->corner_verts[corner_curr]],
|
||||
mr->vert_positions[mr->corner_verts[corner_next]]);
|
||||
/* simple way to detect (what is most likely) concave */
|
||||
if (dot_v3v3(f_no, no_corner) < 0.0f) {
|
||||
negate_v3(no_corner);
|
||||
|
@ -547,7 +547,7 @@ static void statvis_calc_sharp(const MeshRenderData *mr, float *r_sharp)
|
|||
const float *f2_no = static_cast<const float *>(*pval);
|
||||
angle = angle_normalized_v3v3(f1_no, f2_no);
|
||||
angle = is_edge_convex_v3(
|
||||
mr->positions[vert_curr], mr->positions[vert_next], f1_no, f2_no) ?
|
||||
mr->vert_positions[vert_curr], mr->vert_positions[vert_next], f1_no, f2_no) ?
|
||||
angle :
|
||||
-angle;
|
||||
/* Tag as manifold. */
|
||||
|
|
|
@ -95,7 +95,7 @@ static void extract_pos_nor_iter_poly_mesh(const MeshRenderData *mr,
|
|||
|
||||
PosNorLoop *vert = &data->vbo_data[ml_index];
|
||||
const bool vert_hidden = mr->hide_vert && mr->hide_vert[vert_i];
|
||||
copy_v3_v3(vert->pos, mr->positions[vert_i]);
|
||||
copy_v3_v3(vert->pos, mr->vert_positions[vert_i]);
|
||||
vert->nor = data->normals[vert_i].low;
|
||||
/* Flag for paint mode overlay. */
|
||||
if (poly_hidden || vert_hidden ||
|
||||
|
@ -134,8 +134,8 @@ static void extract_pos_nor_iter_ledge_mesh(const MeshRenderData *mr,
|
|||
MeshExtract_PosNor_Data *data = static_cast<MeshExtract_PosNor_Data *>(_data);
|
||||
const int ml_index = mr->loop_len + ledge_index * 2;
|
||||
PosNorLoop *vert = &data->vbo_data[ml_index];
|
||||
copy_v3_v3(vert[0].pos, mr->positions[med->v1]);
|
||||
copy_v3_v3(vert[1].pos, mr->positions[med->v2]);
|
||||
copy_v3_v3(vert[0].pos, mr->vert_positions[med->v1]);
|
||||
copy_v3_v3(vert[1].pos, mr->vert_positions[med->v2]);
|
||||
vert[0].nor = data->normals[med->v1].low;
|
||||
vert[1].nor = data->normals[med->v2].low;
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ static void extract_pos_nor_iter_lvert_mesh(const MeshRenderData *mr,
|
|||
const int ml_index = offset + lvert_index;
|
||||
const int v_index = mr->lverts[lvert_index];
|
||||
PosNorLoop *vert = &data->vbo_data[ml_index];
|
||||
copy_v3_v3(vert->pos, mr->positions[v_index]);
|
||||
copy_v3_v3(vert->pos, mr->vert_positions[v_index]);
|
||||
vert->nor = data->normals[v_index].low;
|
||||
}
|
||||
|
||||
|
@ -470,7 +470,7 @@ static void extract_pos_nor_hq_iter_poly_mesh(const MeshRenderData *mr,
|
|||
|
||||
const bool vert_hidden = mr->hide_vert && mr->hide_vert[vert_i];
|
||||
PosNorHQLoop *vert = &data->vbo_data[ml_index];
|
||||
copy_v3_v3(vert->pos, mr->positions[vert_i]);
|
||||
copy_v3_v3(vert->pos, mr->vert_positions[vert_i]);
|
||||
copy_v3_v3_short(vert->nor, data->normals[vert_i].high);
|
||||
|
||||
/* Flag for paint mode overlay. */
|
||||
|
@ -511,8 +511,8 @@ static void extract_pos_nor_hq_iter_ledge_mesh(const MeshRenderData *mr,
|
|||
MeshExtract_PosNorHQ_Data *data = static_cast<MeshExtract_PosNorHQ_Data *>(_data);
|
||||
const int ml_index = mr->loop_len + ledge_index * 2;
|
||||
PosNorHQLoop *vert = &data->vbo_data[ml_index];
|
||||
copy_v3_v3(vert[0].pos, mr->positions[med->v1]);
|
||||
copy_v3_v3(vert[1].pos, mr->positions[med->v2]);
|
||||
copy_v3_v3(vert[0].pos, mr->vert_positions[med->v1]);
|
||||
copy_v3_v3(vert[1].pos, mr->vert_positions[med->v2]);
|
||||
copy_v3_v3_short(vert[0].nor, data->normals[med->v1].high);
|
||||
vert[0].nor[3] = 0;
|
||||
copy_v3_v3_short(vert[1].nor, data->normals[med->v2].high);
|
||||
|
@ -544,7 +544,7 @@ static void extract_pos_nor_hq_iter_lvert_mesh(const MeshRenderData *mr,
|
|||
const int ml_index = offset + lvert_index;
|
||||
const int v_index = mr->lverts[lvert_index];
|
||||
PosNorHQLoop *vert = &data->vbo_data[ml_index];
|
||||
copy_v3_v3(vert->pos, mr->positions[v_index]);
|
||||
copy_v3_v3(vert->pos, mr->vert_positions[v_index]);
|
||||
copy_v3_v3_short(vert->nor, data->normals[v_index].high);
|
||||
vert->nor[3] = 0;
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ static void extract_tan_init_common(const MeshRenderData *mr,
|
|||
}
|
||||
else {
|
||||
for (int v = 0; v < mr->vert_len; v++) {
|
||||
copy_v3_v3(orco[v], mr->positions[v]);
|
||||
copy_v3_v3(orco[v], mr->vert_positions[v]);
|
||||
}
|
||||
}
|
||||
BKE_mesh_orco_verts_transform(mr->me, orco, mr->vert_len, 0);
|
||||
|
@ -113,7 +113,7 @@ static void extract_tan_init_common(const MeshRenderData *mr,
|
|||
&tangent_mask);
|
||||
}
|
||||
else {
|
||||
BKE_mesh_calc_loop_tangent_ex(reinterpret_cast<const float(*)[3]>(mr->positions),
|
||||
BKE_mesh_calc_loop_tangent_ex(reinterpret_cast<const float(*)[3]>(mr->vert_positions),
|
||||
mr->mpoly,
|
||||
mr->poly_len,
|
||||
mr->corner_verts,
|
||||
|
|
|
@ -3087,7 +3087,7 @@ static void ui_textedit_set_cursor_select(uiBut *but, uiHandleButtonData *data,
|
|||
but->selsta = but->pos;
|
||||
but->selend = data->sel_pos_init;
|
||||
if (but->selend < but->selsta) {
|
||||
std::swap(but->selsta, but->selend);
|
||||
std::swap(but->selsta, but->selend);
|
||||
}
|
||||
|
||||
ui_but_update(but);
|
||||
|
@ -3190,7 +3190,7 @@ static void ui_textedit_move(uiBut *but,
|
|||
but->selend = data->sel_pos_init;
|
||||
}
|
||||
if (but->selend < but->selsta) {
|
||||
std::swap( but->selsta, but->selend);
|
||||
std::swap(but->selsta, but->selend);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ static void join_mesh_single(Depsgraph *depsgraph,
|
|||
Object *ob_dst,
|
||||
Object *ob_src,
|
||||
const float imat[4][4],
|
||||
float3 **positions_pp,
|
||||
float3 **vert_positions_pp,
|
||||
MEdge **medge_pp,
|
||||
int **corner_verts_pp,
|
||||
int **corner_edges_pp,
|
||||
|
@ -98,7 +98,7 @@ static void join_mesh_single(Depsgraph *depsgraph,
|
|||
int a, b;
|
||||
|
||||
Mesh *me = static_cast<Mesh *>(ob_src->data);
|
||||
float3 *positions = *positions_pp;
|
||||
float3 *vert_positions = *vert_positions_pp;
|
||||
MEdge *medge = *medge_pp;
|
||||
int *corner_verts = *corner_verts_pp;
|
||||
int *corner_edges = *corner_edges_pp;
|
||||
|
@ -139,7 +139,7 @@ static void join_mesh_single(Depsgraph *depsgraph,
|
|||
|
||||
/* transform vertex coordinates into new space */
|
||||
for (a = 0; a < me->totvert; a++) {
|
||||
mul_m4_v3(cmat, positions[a]);
|
||||
mul_m4_v3(cmat, vert_positions[a]);
|
||||
}
|
||||
|
||||
/* For each shape-key in destination mesh:
|
||||
|
@ -168,7 +168,7 @@ static void join_mesh_single(Depsgraph *depsgraph,
|
|||
else {
|
||||
/* Copy this mesh's vertex coordinates to the destination shape-key. */
|
||||
for (a = 0; a < me->totvert; a++, cos++) {
|
||||
copy_v3_v3(*cos, positions[a]);
|
||||
copy_v3_v3(*cos, vert_positions[a]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ static void join_mesh_single(Depsgraph *depsgraph,
|
|||
else {
|
||||
/* Copy base-coordinates to the destination shape-key. */
|
||||
for (a = 0; a < me->totvert; a++, cos++) {
|
||||
copy_v3_v3(*cos, positions[a]);
|
||||
copy_v3_v3(*cos, vert_positions[a]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -290,7 +290,7 @@ static void join_mesh_single(Depsgraph *depsgraph,
|
|||
|
||||
/* these are used for relinking (cannot be set earlier, or else reattaching goes wrong) */
|
||||
*vertofs += me->totvert;
|
||||
*positions_pp += me->totvert;
|
||||
*vert_positions_pp += me->totvert;
|
||||
*edgeofs += me->totedge;
|
||||
*medge_pp += me->totedge;
|
||||
*loopofs += me->totloop;
|
||||
|
@ -583,7 +583,7 @@ int ED_mesh_join_objects_exec(bContext *C, wmOperator *op)
|
|||
CustomData_reset(&ldata);
|
||||
CustomData_reset(&pdata);
|
||||
|
||||
float3 *positions = (float3 *)CustomData_add_layer_named(
|
||||
float3 *vert_positions = (float3 *)CustomData_add_layer_named(
|
||||
&vdata, CD_PROP_FLOAT3, CD_SET_DEFAULT, nullptr, totvert, "position");
|
||||
medge = (MEdge *)CustomData_add_layer(&edata, CD_MEDGE, CD_SET_DEFAULT, nullptr, totedge);
|
||||
int *corner_verts = (int *)CustomData_add_layer_named(
|
||||
|
@ -612,7 +612,7 @@ int ED_mesh_join_objects_exec(bContext *C, wmOperator *op)
|
|||
ob,
|
||||
ob,
|
||||
imat,
|
||||
&positions,
|
||||
&vert_positions,
|
||||
&medge,
|
||||
&corner_verts,
|
||||
&corner_edges,
|
||||
|
@ -647,7 +647,7 @@ int ED_mesh_join_objects_exec(bContext *C, wmOperator *op)
|
|||
ob,
|
||||
ob_iter,
|
||||
imat,
|
||||
&positions,
|
||||
&vert_positions,
|
||||
&medge,
|
||||
&corner_verts,
|
||||
&corner_edges,
|
||||
|
@ -1141,12 +1141,12 @@ int *mesh_get_x_mirror_faces(Object *ob, BMEditMesh *em, Mesh *me_eval)
|
|||
mirrorverts = static_cast<int *>(MEM_callocN(sizeof(int) * totvert, "MirrorVerts"));
|
||||
mirrorfaces = static_cast<int *>(MEM_callocN(sizeof(int[2]) * totface, "MirrorFaces"));
|
||||
|
||||
const Span<float3> positions = me_eval ? me_eval->vert_positions() : me->vert_positions();
|
||||
const Span<float3> vert_positions = me_eval ? me_eval->vert_positions() : me->vert_positions();
|
||||
MFace *mface = (MFace *)CustomData_get_layer(&(me_eval ? me_eval : me)->fdata, CD_MFACE);
|
||||
|
||||
ED_mesh_mirror_spatial_table_begin(ob, em, me_eval);
|
||||
|
||||
for (const int i : positions.index_range()) {
|
||||
for (const int i : vert_positions.index_range()) {
|
||||
mirrorverts[i] = mesh_get_x_mirror_vert(ob, me_eval, i, use_topology);
|
||||
}
|
||||
|
||||
|
@ -1228,7 +1228,7 @@ static void ed_mesh_pick_face_vert__mpoly_find(
|
|||
const float mval[2],
|
||||
/* mesh data (evaluated) */
|
||||
const MPoly *mp,
|
||||
const Span<float3> positions,
|
||||
const Span<float3> vert_positions,
|
||||
const int *corner_verts,
|
||||
/* return values */
|
||||
float *r_len_best,
|
||||
|
@ -1237,7 +1237,7 @@ static void ed_mesh_pick_face_vert__mpoly_find(
|
|||
for (int j = mp->totloop; j--;) {
|
||||
float sco[2];
|
||||
const int v_idx = corner_verts[mp->loopstart + j];
|
||||
if (ED_view3d_project_float_object(region, positions[v_idx], sco, V3D_PROJ_TEST_NOP) ==
|
||||
if (ED_view3d_project_float_object(region, vert_positions[v_idx], sco, V3D_PROJ_TEST_NOP) ==
|
||||
V3D_PROJ_RET_OK) {
|
||||
const float len_test = len_manhattan_v2v2(mval, sco);
|
||||
if (len_test < *r_len_best) {
|
||||
|
@ -1271,7 +1271,7 @@ bool ED_mesh_pick_face_vert(
|
|||
const float mval_f[2] = {float(mval[0]), float(mval[1])};
|
||||
float len_best = FLT_MAX;
|
||||
|
||||
const Span<float3> positions = me_eval->vert_positions();
|
||||
const Span<float3> vert_positions = me_eval->vert_positions();
|
||||
const Span<MPoly> polys = me_eval->polys();
|
||||
const Span<int> corner_verts = me_eval->corner_verts();
|
||||
|
||||
|
@ -1281,8 +1281,13 @@ bool ED_mesh_pick_face_vert(
|
|||
if (index_mp_to_orig) {
|
||||
for (const int i : polys.index_range()) {
|
||||
if (index_mp_to_orig[i] == poly_index) {
|
||||
ed_mesh_pick_face_vert__mpoly_find(
|
||||
region, mval_f, &polys[i], positions, corner_verts.data(), &len_best, &v_idx_best);
|
||||
ed_mesh_pick_face_vert__mpoly_find(region,
|
||||
mval_f,
|
||||
&polys[i],
|
||||
vert_positions,
|
||||
corner_verts.data(),
|
||||
&len_best,
|
||||
&v_idx_best);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1291,7 +1296,7 @@ bool ED_mesh_pick_face_vert(
|
|||
ed_mesh_pick_face_vert__mpoly_find(region,
|
||||
mval_f,
|
||||
&polys[poly_index],
|
||||
positions,
|
||||
vert_positions,
|
||||
corner_verts.data(),
|
||||
&len_best,
|
||||
&v_idx_best);
|
||||
|
@ -1323,7 +1328,6 @@ bool ED_mesh_pick_face_vert(
|
|||
* \return boolean true == Found
|
||||
*/
|
||||
struct VertPickData {
|
||||
Span<float3> positions;
|
||||
const bool *hide_vert;
|
||||
const float *mval_f; /* [2] */
|
||||
ARegion *region;
|
||||
|
@ -1407,7 +1411,6 @@ bool ED_mesh_pick_vert(
|
|||
}
|
||||
|
||||
/* setup data */
|
||||
data.positions = me->vert_positions();
|
||||
data.region = region;
|
||||
data.mval_f = mval_f;
|
||||
data.len_best = FLT_MAX;
|
||||
|
|
|
@ -68,7 +68,7 @@ static void partialvis_update_mesh(Object *ob,
|
|||
float planes[4][4])
|
||||
{
|
||||
Mesh *me = ob->data;
|
||||
const float(*positions)[3] = BKE_pbvh_get_positions(pbvh);
|
||||
const float(*positions)[3] = BKE_pbvh_get_vert_positions(pbvh);
|
||||
const float *paint_mask;
|
||||
int totvert, i;
|
||||
bool any_changed = false, any_visible = false;
|
||||
|
|
|
@ -412,7 +412,7 @@ struct ProjPaintState {
|
|||
int totedge_eval;
|
||||
int totvert_eval;
|
||||
|
||||
const float (*positions_eval)[3];
|
||||
const float (*vert_positions_eval)[3];
|
||||
const float (*vert_normals)[3];
|
||||
const MEdge *medge_eval;
|
||||
const MPoly *mpoly_eval;
|
||||
|
@ -931,9 +931,9 @@ static bool project_bucket_point_occluded(const ProjPaintState *ps,
|
|||
|
||||
if (do_clip) {
|
||||
const float *vtri_co[3] = {
|
||||
ps->positions_eval[ps->corner_verts_eval[lt->tri[0]]],
|
||||
ps->positions_eval[ps->corner_verts_eval[lt->tri[1]]],
|
||||
ps->positions_eval[ps->corner_verts_eval[lt->tri[2]]],
|
||||
ps->vert_positions_eval[ps->corner_verts_eval[lt->tri[0]]],
|
||||
ps->vert_positions_eval[ps->corner_verts_eval[lt->tri[1]]],
|
||||
ps->vert_positions_eval[ps->corner_verts_eval[lt->tri[2]]],
|
||||
};
|
||||
isect_ret = project_paint_occlude_ptv_clip(
|
||||
pixelScreenCo, UNPACK3(vtri_ss), UNPACK3(vtri_co), w, ps->is_ortho, ps->rv3d);
|
||||
|
@ -1745,9 +1745,9 @@ static float project_paint_uvpixel_mask(const ProjPaintState *ps,
|
|||
/* In case the normalizing per pixel isn't optimal,
|
||||
* we could cache or access from evaluated mesh. */
|
||||
normal_tri_v3(no,
|
||||
ps->positions_eval[lt_vtri[0]],
|
||||
ps->positions_eval[lt_vtri[1]],
|
||||
ps->positions_eval[lt_vtri[2]]);
|
||||
ps->vert_positions_eval[lt_vtri[0]],
|
||||
ps->vert_positions_eval[lt_vtri[1]],
|
||||
ps->vert_positions_eval[lt_vtri[2]]);
|
||||
}
|
||||
|
||||
if (UNLIKELY(ps->is_flip_object)) {
|
||||
|
@ -1762,9 +1762,9 @@ static float project_paint_uvpixel_mask(const ProjPaintState *ps,
|
|||
/* Annoying but for the perspective view we need to get the pixels location in 3D space :/ */
|
||||
float viewDirPersp[3];
|
||||
const float *co1, *co2, *co3;
|
||||
co1 = ps->positions_eval[lt_vtri[0]];
|
||||
co2 = ps->positions_eval[lt_vtri[1]];
|
||||
co3 = ps->positions_eval[lt_vtri[2]];
|
||||
co1 = ps->vert_positions_eval[lt_vtri[0]];
|
||||
co2 = ps->vert_positions_eval[lt_vtri[1]];
|
||||
co3 = ps->vert_positions_eval[lt_vtri[2]];
|
||||
|
||||
/* Get the direction from the viewPoint to the pixel and normalize */
|
||||
viewDirPersp[0] = (ps->viewPos[0] - (w[0] * co1[0] + w[1] * co2[0] + w[2] * co3[0]));
|
||||
|
@ -3043,9 +3043,9 @@ static void project_paint_face_init(const ProjPaintState *ps,
|
|||
const bool do_backfacecull = ps->do_backfacecull;
|
||||
const bool do_clip = RV3D_CLIPPING_ENABLED(ps->v3d, ps->rv3d);
|
||||
|
||||
vCo[0] = ps->positions_eval[lt_vtri[0]];
|
||||
vCo[1] = ps->positions_eval[lt_vtri[1]];
|
||||
vCo[2] = ps->positions_eval[lt_vtri[2]];
|
||||
vCo[0] = ps->vert_positions_eval[lt_vtri[0]];
|
||||
vCo[1] = ps->vert_positions_eval[lt_vtri[1]];
|
||||
vCo[2] = ps->vert_positions_eval[lt_vtri[2]];
|
||||
|
||||
/* Use lt_uv_pxoffset instead of lt_tri_uv so we can offset the UV half a pixel
|
||||
* this is done so we can avoid offsetting all the pixels by 0.5 which causes
|
||||
|
@ -3142,9 +3142,9 @@ static void project_paint_face_init(const ProjPaintState *ps,
|
|||
* because it is a relatively expensive operation. */
|
||||
if (do_clip || do_3d_mapping) {
|
||||
interp_v3_v3v3v3(wco,
|
||||
ps->positions_eval[lt_vtri[0]],
|
||||
ps->positions_eval[lt_vtri[1]],
|
||||
ps->positions_eval[lt_vtri[2]],
|
||||
ps->vert_positions_eval[lt_vtri[0]],
|
||||
ps->vert_positions_eval[lt_vtri[1]],
|
||||
ps->vert_positions_eval[lt_vtri[2]],
|
||||
w);
|
||||
if (do_clip && ED_view3d_clipping_test(ps->rv3d, wco, true)) {
|
||||
/* Watch out that no code below this needs to run */
|
||||
|
@ -3815,7 +3815,7 @@ static void proj_paint_state_screen_coords_init(ProjPaintState *ps, const int di
|
|||
|
||||
if (ps->is_ortho) {
|
||||
for (a = 0; a < ps->totvert_eval; a++, projScreenCo += 4) {
|
||||
mul_v3_m4v3(projScreenCo, ps->projectMat, ps->positions_eval[a]);
|
||||
mul_v3_m4v3(projScreenCo, ps->projectMat, ps->vert_positions_eval[a]);
|
||||
|
||||
/* screen space, not clamped */
|
||||
projScreenCo[0] = float(ps->winx * 0.5f) + (ps->winx * 0.5f) * projScreenCo[0];
|
||||
|
@ -3825,7 +3825,7 @@ static void proj_paint_state_screen_coords_init(ProjPaintState *ps, const int di
|
|||
}
|
||||
else {
|
||||
for (a = 0; a < ps->totvert_eval; a++, projScreenCo += 4) {
|
||||
copy_v3_v3(projScreenCo, ps->positions_eval[a]);
|
||||
copy_v3_v3(projScreenCo, ps->vert_positions_eval[a]);
|
||||
projScreenCo[3] = 1.0f;
|
||||
|
||||
mul_m4_v4(ps->projectMat, projScreenCo);
|
||||
|
@ -3896,7 +3896,7 @@ static void proj_paint_state_cavity_init(ProjPaintState *ps)
|
|||
|
||||
for (a = 0, me = ps->medge_eval; a < ps->totedge_eval; a++, me++) {
|
||||
float e[3];
|
||||
sub_v3_v3v3(e, ps->positions_eval[me->v1], ps->positions_eval[me->v2]);
|
||||
sub_v3_v3v3(e, ps->vert_positions_eval[me->v1], ps->vert_positions_eval[me->v2]);
|
||||
normalize_v3(e);
|
||||
add_v3_v3(edges[me->v2], e);
|
||||
counter[me->v2]++;
|
||||
|
@ -3986,7 +3986,7 @@ static void proj_paint_state_vert_flags_init(ProjPaintState *ps)
|
|||
}
|
||||
}
|
||||
else {
|
||||
sub_v3_v3v3(viewDirPersp, ps->viewPos, ps->positions_eval[a]);
|
||||
sub_v3_v3v3(viewDirPersp, ps->viewPos, ps->vert_positions_eval[a]);
|
||||
normalize_v3(viewDirPersp);
|
||||
if (UNLIKELY(ps->is_flip_object)) {
|
||||
negate_v3(viewDirPersp);
|
||||
|
@ -4074,7 +4074,7 @@ static bool proj_paint_state_mesh_eval_init(const bContext *C, ProjPaintState *p
|
|||
}
|
||||
ps->mat_array[totmat - 1] = nullptr;
|
||||
|
||||
ps->positions_eval = BKE_mesh_vert_positions(ps->me_eval);
|
||||
ps->vert_positions_eval = BKE_mesh_vert_positions(ps->me_eval);
|
||||
ps->vert_normals = BKE_mesh_vertex_normals_ensure(ps->me_eval);
|
||||
if (ps->do_mask_cavity) {
|
||||
ps->medge_eval = BKE_mesh_edges(ps->me_eval);
|
||||
|
@ -5715,9 +5715,9 @@ static bool project_paint_op(void *state, const float lastpos[2], const float po
|
|||
UnifiedPaintSettings *ups = &ps->scene->toolsettings->unified_paint_settings;
|
||||
|
||||
interp_v3_v3v3v3(world,
|
||||
ps->positions_eval[lt_vtri[0]],
|
||||
ps->positions_eval[lt_vtri[1]],
|
||||
ps->positions_eval[lt_vtri[2]],
|
||||
ps->vert_positions_eval[lt_vtri[0]],
|
||||
ps->vert_positions_eval[lt_vtri[1]],
|
||||
ps->vert_positions_eval[lt_vtri[2]],
|
||||
w);
|
||||
|
||||
ups->average_stroke_counter++;
|
||||
|
|
|
@ -113,7 +113,7 @@ const float *SCULPT_vertex_co_get(SculptSession *ss, PBVHVertRef vertex)
|
|||
switch (BKE_pbvh_type(ss->pbvh)) {
|
||||
case PBVH_FACES: {
|
||||
if (ss->shapekey_active || ss->deform_modifiers_active) {
|
||||
const float(*positions)[3] = BKE_pbvh_get_positions(ss->pbvh);
|
||||
const float(*positions)[3] = BKE_pbvh_get_vert_positions(ss->pbvh);
|
||||
return positions[vertex.i];
|
||||
}
|
||||
return ss->vert_positions[vertex.i];
|
||||
|
@ -202,7 +202,7 @@ const float *SCULPT_vertex_co_for_grab_active_get(SculptSession *ss, PBVHVertRef
|
|||
if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES) {
|
||||
/* Always grab active shape key if the sculpt happens on shapekey. */
|
||||
if (ss->shapekey_active) {
|
||||
const float(*positions)[3] = BKE_pbvh_get_positions(ss->pbvh);
|
||||
const float(*positions)[3] = BKE_pbvh_get_vert_positions(ss->pbvh);
|
||||
return positions[vertex.i];
|
||||
}
|
||||
|
||||
|
@ -293,7 +293,7 @@ float (*SCULPT_mesh_deformed_positions_get(SculptSession *ss))[3]
|
|||
switch (BKE_pbvh_type(ss->pbvh)) {
|
||||
case PBVH_FACES:
|
||||
if (ss->shapekey_active || ss->deform_modifiers_active) {
|
||||
return BKE_pbvh_get_positions(ss->pbvh);
|
||||
return BKE_pbvh_get_vert_positions(ss->pbvh);
|
||||
}
|
||||
return ss->vert_positions;
|
||||
case PBVH_BMESH:
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#define SCULPT_GEODESIC_VERTEX_NONE -1
|
||||
|
||||
/* Propagate distance from v1 and v2 to v0. */
|
||||
static bool sculpt_geodesic_mesh_test_dist_add(const float (*positions)[3],
|
||||
static bool sculpt_geodesic_mesh_test_dist_add(const float (*vert_positions)[3],
|
||||
const int v0,
|
||||
const int v1,
|
||||
const int v2,
|
||||
|
@ -57,11 +57,11 @@ static bool sculpt_geodesic_mesh_test_dist_add(const float (*positions)[3],
|
|||
return false;
|
||||
}
|
||||
dist0 = geodesic_distance_propagate_across_triangle(
|
||||
positions[v0], positions[v1], positions[v2], dists[v1], dists[v2]);
|
||||
vert_positions[v0], vert_positions[v1], vert_positions[v2], dists[v1], dists[v2]);
|
||||
}
|
||||
else {
|
||||
float vec[3];
|
||||
sub_v3_v3v3(vec, positions[v1], positions[v0]);
|
||||
sub_v3_v3v3(vec, vert_positions[v1], vert_positions[v0]);
|
||||
dist0 = dists[v1] + len_v3(vec);
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ static float *SCULPT_geodesic_mesh_create(Object *ob,
|
|||
|
||||
const float limit_radius_sq = limit_radius * limit_radius;
|
||||
|
||||
float(*positions)[3] = SCULPT_mesh_deformed_positions_get(ss);
|
||||
float(*vert_positions)[3] = SCULPT_mesh_deformed_positions_get(ss);
|
||||
const MEdge *edges = BKE_mesh_edges(mesh);
|
||||
const MPoly *polys = BKE_mesh_polys(mesh);
|
||||
const int *corner_verts = BKE_mesh_corner_verts(mesh);
|
||||
|
@ -140,9 +140,9 @@ static float *SCULPT_geodesic_mesh_create(Object *ob,
|
|||
* number of vertices (usually just 1 or 2). */
|
||||
GSET_ITER (gs_iter, initial_verts) {
|
||||
const int v = POINTER_AS_INT(BLI_gsetIterator_getKey(&gs_iter));
|
||||
float *v_co = positions[v];
|
||||
float *v_co = vert_positions[v];
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
if (len_squared_v3v3(v_co, positions[i]) <= limit_radius_sq) {
|
||||
if (len_squared_v3v3(v_co, vert_positions[i]) <= limit_radius_sq) {
|
||||
BLI_BITMAP_ENABLE(affected_vertex, i);
|
||||
}
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ static float *SCULPT_geodesic_mesh_create(Object *ob,
|
|||
SWAP(int, v1, v2);
|
||||
}
|
||||
sculpt_geodesic_mesh_test_dist_add(
|
||||
positions, v2, v1, SCULPT_GEODESIC_VERTEX_NONE, dists, initial_verts);
|
||||
vert_positions, v2, v1, SCULPT_GEODESIC_VERTEX_NONE, dists, initial_verts);
|
||||
}
|
||||
|
||||
if (ss->epmap[e].count != 0) {
|
||||
|
@ -189,7 +189,7 @@ static float *SCULPT_geodesic_mesh_create(Object *ob,
|
|||
continue;
|
||||
}
|
||||
if (sculpt_geodesic_mesh_test_dist_add(
|
||||
positions, v_other, v1, v2, dists, initial_verts)) {
|
||||
vert_positions, v_other, v1, v2, dists, initial_verts)) {
|
||||
for (int edge_map_index = 0; edge_map_index < ss->vemap[v_other].count;
|
||||
edge_map_index++) {
|
||||
const int e_other = ss->vemap[v_other].indices[edge_map_index];
|
||||
|
|
|
@ -261,10 +261,10 @@ void *ED_image_paint_tile_push(PaintTileMap *paint_tile_map,
|
|||
ED_IMAGE_UNDO_TILE_SIZE);
|
||||
|
||||
if (has_float) {
|
||||
std::swap( ptile->rect.fp, (*tmpibuf)->rect_float);
|
||||
std::swap(ptile->rect.fp, (*tmpibuf)->rect_float);
|
||||
}
|
||||
else {
|
||||
std::swap(ptile->rect.uint, (*tmpibuf)->rect);
|
||||
std::swap(ptile->rect.uint, (*tmpibuf)->rect);
|
||||
}
|
||||
|
||||
PaintTileKey key = {};
|
||||
|
@ -299,10 +299,10 @@ static void ptile_restore_runtime_map(PaintTileMap *paint_tile_map)
|
|||
const bool has_float = (ibuf->rect_float != nullptr);
|
||||
|
||||
if (has_float) {
|
||||
std::swap( ptile->rect.fp, tmpibuf->rect_float);
|
||||
std::swap(ptile->rect.fp, tmpibuf->rect_float);
|
||||
}
|
||||
else {
|
||||
std::swap(ptile->rect.uint, tmpibuf->rect);
|
||||
std::swap(ptile->rect.uint, tmpibuf->rect);
|
||||
}
|
||||
|
||||
IMB_rectcpy(ibuf,
|
||||
|
@ -315,10 +315,10 @@ static void ptile_restore_runtime_map(PaintTileMap *paint_tile_map)
|
|||
ED_IMAGE_UNDO_TILE_SIZE);
|
||||
|
||||
if (has_float) {
|
||||
std::swap( ptile->rect.fp, tmpibuf->rect_float);
|
||||
std::swap(ptile->rect.fp, tmpibuf->rect_float);
|
||||
}
|
||||
else {
|
||||
std::swap(ptile->rect.uint, tmpibuf->rect);
|
||||
std::swap(ptile->rect.uint, tmpibuf->rect);
|
||||
}
|
||||
|
||||
/* Force OpenGL reload (maybe partial update will operate better?) */
|
||||
|
@ -380,19 +380,19 @@ static void utile_init_from_imbuf(
|
|||
const bool has_float = ibuf->rect_float;
|
||||
|
||||
if (has_float) {
|
||||
std::swap( utile->rect.fp, tmpibuf->rect_float);
|
||||
std::swap(utile->rect.fp, tmpibuf->rect_float);
|
||||
}
|
||||
else {
|
||||
std::swap(utile->rect.uint_ptr, tmpibuf->rect);
|
||||
std::swap(utile->rect.uint_ptr, tmpibuf->rect);
|
||||
}
|
||||
|
||||
IMB_rectcpy(tmpibuf, ibuf, 0, 0, x, y, ED_IMAGE_UNDO_TILE_SIZE, ED_IMAGE_UNDO_TILE_SIZE);
|
||||
|
||||
if (has_float) {
|
||||
std::swap( utile->rect.fp, tmpibuf->rect_float);
|
||||
std::swap(utile->rect.fp, tmpibuf->rect_float);
|
||||
}
|
||||
else {
|
||||
std::swap(utile->rect.uint_ptr, tmpibuf->rect);
|
||||
std::swap(utile->rect.uint_ptr, tmpibuf->rect);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -675,9 +675,9 @@ static void node_draw_mute_line(const bContext &C,
|
|||
{
|
||||
GPU_blend(GPU_BLEND_ALPHA);
|
||||
|
||||
for (const bNodeLink *link : node.internal_links()) {
|
||||
if (!nodeLinkIsHidden(link)) {
|
||||
node_draw_link_bezier(C, v2d, snode, *link, TH_WIRE_INNER, TH_WIRE_INNER, TH_WIRE, false);
|
||||
for (const bNodeLink &link : node.internal_links()) {
|
||||
if (!nodeLinkIsHidden(&link)) {
|
||||
node_draw_link_bezier(C, v2d, snode, link, TH_WIRE_INNER, TH_WIRE_INNER, TH_WIRE, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1744,7 +1744,7 @@ void NODE_OT_mute_toggle(wmOperatorType *ot)
|
|||
{
|
||||
/* identifiers */
|
||||
ot->name = "Toggle Node Mute";
|
||||
ot->description = "Toggle muting of the nodes";
|
||||
ot->description = "Toggle muting of selected nodes";
|
||||
ot->idname = "NODE_OT_mute_toggle";
|
||||
|
||||
/* callbacks */
|
||||
|
@ -1783,7 +1783,7 @@ void NODE_OT_delete(wmOperatorType *ot)
|
|||
{
|
||||
/* identifiers */
|
||||
ot->name = "Delete";
|
||||
ot->description = "Delete selected nodes";
|
||||
ot->description = "Remove selected nodes";
|
||||
ot->idname = "NODE_OT_delete";
|
||||
|
||||
/* api callbacks */
|
||||
|
@ -1871,7 +1871,7 @@ void NODE_OT_delete_reconnect(wmOperatorType *ot)
|
|||
{
|
||||
/* identifiers */
|
||||
ot->name = "Delete with Reconnect";
|
||||
ot->description = "Delete nodes; will reconnect nodes as if deletion was muted";
|
||||
ot->description = "Remove nodes and reconnect nodes as if deletion was muted";
|
||||
ot->idname = "NODE_OT_delete_reconnect";
|
||||
|
||||
/* api callbacks */
|
||||
|
@ -1975,7 +1975,7 @@ void NODE_OT_output_file_remove_active_socket(wmOperatorType *ot)
|
|||
{
|
||||
/* identifiers */
|
||||
ot->name = "Remove File Node Socket";
|
||||
ot->description = "Remove active input from a file output node";
|
||||
ot->description = "Remove the active input from a file output node";
|
||||
ot->idname = "NODE_OT_output_file_remove_active_socket";
|
||||
|
||||
/* callbacks */
|
||||
|
@ -2171,7 +2171,7 @@ void NODE_OT_tree_socket_add(wmOperatorType *ot)
|
|||
{
|
||||
/* identifiers */
|
||||
ot->name = "Add Node Tree Interface Socket";
|
||||
ot->description = "Add an input or output socket to the current node tree";
|
||||
ot->description = "Add an input or output to the active node tree";
|
||||
ot->idname = "NODE_OT_tree_socket_add";
|
||||
|
||||
/* api callbacks */
|
||||
|
@ -2222,7 +2222,7 @@ void NODE_OT_tree_socket_remove(wmOperatorType *ot)
|
|||
{
|
||||
/* identifiers */
|
||||
ot->name = "Remove Node Tree Interface Socket";
|
||||
ot->description = "Remove an input or output socket to the current node tree";
|
||||
ot->description = "Remove an input or output from the active node tree";
|
||||
ot->idname = "NODE_OT_tree_socket_remove";
|
||||
|
||||
/* api callbacks */
|
||||
|
@ -2321,7 +2321,7 @@ void NODE_OT_tree_socket_change_type(wmOperatorType *ot)
|
|||
|
||||
/* identifiers */
|
||||
ot->name = "Change Node Tree Interface Socket Type";
|
||||
ot->description = "Change the type of a socket of the current node tree";
|
||||
ot->description = "Change the type of an input or output of the active node tree";
|
||||
ot->idname = "NODE_OT_tree_socket_change_type";
|
||||
|
||||
/* api callbacks */
|
||||
|
@ -2402,7 +2402,7 @@ void NODE_OT_tree_socket_move(wmOperatorType *ot)
|
|||
{
|
||||
/* identifiers */
|
||||
ot->name = "Move Node Tree Socket";
|
||||
ot->description = "Move a socket up or down in the current node tree's sockets stack";
|
||||
ot->description = "Move a socket up or down in the active node tree's interface";
|
||||
ot->idname = "NODE_OT_tree_socket_move";
|
||||
|
||||
/* api callbacks */
|
||||
|
|
|
@ -285,10 +285,10 @@ static void gizmo_node_crop_prop_matrix_set(const wmGizmo *gz,
|
|||
rct_isect.ymax = 1;
|
||||
BLI_rctf_isect(&rct_isect, &rct, &rct);
|
||||
if (nx) {
|
||||
std::swap( rct.xmin, rct.xmax);
|
||||
std::swap(rct.xmin, rct.xmax);
|
||||
}
|
||||
if (ny) {
|
||||
std::swap( rct.ymin, rct.ymax);
|
||||
std::swap(rct.ymin, rct.ymax);
|
||||
}
|
||||
two_xy_from_rect(nxy, &rct, dims, is_relative);
|
||||
gizmo_node_crop_update(crop_group);
|
||||
|
|
|
@ -206,7 +206,6 @@ struct foreachScreenObjectVert_userData {
|
|||
void (*func)(void *userData, const float screen_co[2], int index);
|
||||
void *userData;
|
||||
ViewContext vc;
|
||||
float (*positions)[3];
|
||||
const bool *hide_vert;
|
||||
eV3DProjTest clip_flag;
|
||||
};
|
||||
|
@ -302,7 +301,6 @@ void meshobject_foreachScreenVert(ViewContext *vc,
|
|||
data.func = func;
|
||||
data.userData = userData;
|
||||
data.clip_flag = clip_flag;
|
||||
data.positions = BKE_mesh_vert_positions_for_write((Mesh *)vc->obact->data);
|
||||
data.hide_vert = (const bool *)CustomData_get_layer_named(
|
||||
&me->vdata, CD_PROP_BOOL, ".hide_vert");
|
||||
|
||||
|
|
|
@ -393,7 +393,7 @@ static void applyAxisConstraintVec(const TransInfo *t,
|
|||
if (!td && t->con.mode & CON_APPLY) {
|
||||
bool is_snap_to_point = false, is_snap_to_edge = false, is_snap_to_face = false;
|
||||
|
||||
if (activeSnap(t)) {
|
||||
if (transform_snap_is_active(t)) {
|
||||
if (validSnap(t)) {
|
||||
is_snap_to_edge = (t->tsnap.snapElem & SCE_SNAP_MODE_EDGE) != 0;
|
||||
is_snap_to_face = (t->tsnap.snapElem & SCE_SNAP_MODE_FACE_RAYCAST) != 0;
|
||||
|
|
|
@ -1193,7 +1193,7 @@ static void restoreBones(TransDataContainer *tc)
|
|||
static void recalcData_edit_armature(TransInfo *t)
|
||||
{
|
||||
if (t->state != TRANS_CANCEL) {
|
||||
applySnappingIndividual(t);
|
||||
transform_snap_project_individual_apply(t);
|
||||
}
|
||||
|
||||
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
|
||||
|
|
|
@ -419,7 +419,7 @@ static void createTransCurveVerts(bContext *UNUSED(C), TransInfo *t)
|
|||
static void recalcData_curve(TransInfo *t)
|
||||
{
|
||||
if (t->state != TRANS_CANCEL) {
|
||||
applySnappingIndividual(t);
|
||||
transform_snap_project_individual_apply(t);
|
||||
}
|
||||
|
||||
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
|
||||
|
|
|
@ -102,7 +102,7 @@ static void createTransLatticeVerts(bContext *UNUSED(C), TransInfo *t)
|
|||
static void recalcData_lattice(TransInfo *t)
|
||||
{
|
||||
if (t->state != TRANS_CANCEL) {
|
||||
applySnappingIndividual(t);
|
||||
transform_snap_project_individual_apply(t);
|
||||
}
|
||||
|
||||
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
|
||||
|
|
|
@ -123,7 +123,7 @@ static void createTransMBallVerts(bContext *UNUSED(C), TransInfo *t)
|
|||
static void recalcData_mball(TransInfo *t)
|
||||
{
|
||||
if (t->state != TRANS_CANCEL) {
|
||||
applySnappingIndividual(t);
|
||||
transform_snap_project_individual_apply(t);
|
||||
}
|
||||
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
|
||||
if (tc->data_len) {
|
||||
|
|
|
@ -1895,7 +1895,7 @@ static void tc_mesh_partial_types_calc(TransInfo *t, struct PartialTypeState *r_
|
|||
partial_for_looptri = PARTIAL_TYPE_GROUP;
|
||||
partial_for_normals = PARTIAL_TYPE_GROUP;
|
||||
/* Translation can rotate when snapping to normal. */
|
||||
if (activeSnap(t) && usingSnappingNormal(t) && validSnappingNormal(t)) {
|
||||
if (transform_snap_is_active(t) && usingSnappingNormal(t) && validSnappingNormal(t)) {
|
||||
partial_for_normals = PARTIAL_TYPE_ALL;
|
||||
}
|
||||
break;
|
||||
|
@ -1926,7 +1926,7 @@ static void tc_mesh_partial_types_calc(TransInfo *t, struct PartialTypeState *r_
|
|||
}
|
||||
|
||||
/* With projection, transform isn't affine. */
|
||||
if (activeSnap_SnappingIndividual(t)) {
|
||||
if (transform_snap_project_individual_is_active(t)) {
|
||||
if (partial_for_looptri == PARTIAL_TYPE_GROUP) {
|
||||
partial_for_looptri = PARTIAL_TYPE_ALL;
|
||||
}
|
||||
|
@ -2042,7 +2042,7 @@ static void recalcData_mesh(TransInfo *t)
|
|||
bool is_canceling = t->state == TRANS_CANCEL;
|
||||
/* Apply corrections. */
|
||||
if (!is_canceling) {
|
||||
applySnappingIndividual(t);
|
||||
transform_snap_project_individual_apply(t);
|
||||
|
||||
bool do_mirror = !(t->flag & T_NO_MIRROR);
|
||||
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
|
||||
|
|
|
@ -156,7 +156,8 @@ static void node_snap_grid_apply(TransInfo *t)
|
|||
{
|
||||
using namespace blender;
|
||||
|
||||
if (!(activeSnap(t) && (t->tsnap.mode & (SCE_SNAP_MODE_INCREMENT | SCE_SNAP_MODE_GRID)))) {
|
||||
if (!(transform_snap_is_active(t) &&
|
||||
(t->tsnap.mode & (SCE_SNAP_MODE_INCREMENT | SCE_SNAP_MODE_GRID)))) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -878,7 +878,7 @@ static void recalcData_objects(TransInfo *t)
|
|||
bool motionpath_update = false;
|
||||
|
||||
if (t->state != TRANS_CANCEL) {
|
||||
applySnappingIndividual(t);
|
||||
transform_snap_project_individual_apply(t);
|
||||
}
|
||||
|
||||
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
|
||||
|
|
|
@ -92,7 +92,7 @@ static void recalcData_texspace(TransInfo *t)
|
|||
{
|
||||
|
||||
if (t->state != TRANS_CANCEL) {
|
||||
applySnappingIndividual(t);
|
||||
transform_snap_project_individual_apply(t);
|
||||
}
|
||||
|
||||
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
|
||||
|
|
|
@ -241,7 +241,7 @@ static void flushTransParticles(TransInfo *t)
|
|||
static void recalcData_particles(TransInfo *t)
|
||||
{
|
||||
if (t->state != TRANS_CANCEL) {
|
||||
applySnappingIndividual(t);
|
||||
transform_snap_project_individual_apply(t);
|
||||
}
|
||||
flushTransParticles(t);
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ static void applyNormalRotation(TransInfo *t, const int UNUSED(mval[2]))
|
|||
|
||||
transform_snap_increment(t, &angle);
|
||||
|
||||
applySnappingAsGroup(t, &angle);
|
||||
transform_snap_mixed_apply(t, &angle);
|
||||
|
||||
applyNumInput(&t->num, &angle);
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ static void applySeqSlide(TransInfo *t, const int UNUSED(mval[2]))
|
|||
}
|
||||
else {
|
||||
copy_v2_v2(values_final, t->values);
|
||||
applySnappingAsGroup(t, values_final);
|
||||
transform_snap_mixed_apply(t, values_final);
|
||||
transform_convert_sequencer_channel_clamp(t, values_final);
|
||||
|
||||
if (t->con.mode & CON_APPLY) {
|
||||
|
|
|
@ -1447,7 +1447,7 @@ static void applyEdgeSlide(TransInfo *t, const int UNUSED(mval[2]))
|
|||
|
||||
final = t->values[0] + t->values_modal_offset[0];
|
||||
|
||||
applySnappingAsGroup(t, &final);
|
||||
transform_snap_mixed_apply(t, &final);
|
||||
if (!validSnap(t)) {
|
||||
transform_snap_increment(t, &final);
|
||||
}
|
||||
|
|
|
@ -203,7 +203,7 @@ static void applyResize(TransInfo *t, const int UNUSED(mval[2]))
|
|||
constraintNumInput(t, t->values_final);
|
||||
}
|
||||
|
||||
applySnappingAsGroup(t, t->values_final);
|
||||
transform_snap_mixed_apply(t, t->values_final);
|
||||
}
|
||||
|
||||
size_to_mat3(mat, t->values_final);
|
||||
|
|
|
@ -368,8 +368,8 @@ static void applyRotation(TransInfo *t, const int UNUSED(mval[2]))
|
|||
final = large_rotation_limit(final);
|
||||
}
|
||||
else {
|
||||
applySnappingAsGroup(t, &final);
|
||||
if (!(activeSnap(t) && validSnap(t))) {
|
||||
transform_snap_mixed_apply(t, &final);
|
||||
if (!(transform_snap_is_active(t) && validSnap(t))) {
|
||||
transform_snap_increment(t, &final);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ static void applySkinResize(TransInfo *t, const int UNUSED(mval[2]))
|
|||
constraintNumInput(t, t->values_final);
|
||||
}
|
||||
|
||||
applySnappingAsGroup(t, t->values_final);
|
||||
transform_snap_mixed_apply(t, t->values_final);
|
||||
}
|
||||
|
||||
size_to_mat3(mat_final, t->values_final);
|
||||
|
|
|
@ -398,7 +398,7 @@ static void translate_snap_grid_apply(TransInfo *t,
|
|||
|
||||
static bool translate_snap_grid(TransInfo *t, float *val)
|
||||
{
|
||||
if (!activeSnap(t)) {
|
||||
if (!transform_snap_is_active(t)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -475,7 +475,7 @@ static void applyTranslationValue(TransInfo *t, const float vec[3])
|
|||
|
||||
enum eTranslateRotateMode rotate_mode = TRANSLATE_ROTATE_OFF;
|
||||
|
||||
if (activeSnap(t) && usingSnappingNormal(t) && validSnappingNormal(t)) {
|
||||
if (transform_snap_is_active(t) && usingSnappingNormal(t) && validSnappingNormal(t)) {
|
||||
rotate_mode = TRANSLATE_ROTATE_ON;
|
||||
}
|
||||
|
||||
|
@ -610,7 +610,7 @@ static void applyTranslation(TransInfo *t, const int UNUSED(mval[2]))
|
|||
}
|
||||
|
||||
t->tsnap.snapElem = SCE_SNAP_MODE_NONE;
|
||||
applySnappingAsGroup(t, global_dir);
|
||||
transform_snap_mixed_apply(t, global_dir);
|
||||
translate_snap_grid(t, global_dir);
|
||||
|
||||
if (t->con.mode & CON_APPLY) {
|
||||
|
@ -621,7 +621,7 @@ static void applyTranslation(TransInfo *t, const int UNUSED(mval[2]))
|
|||
|
||||
float incr_dir[3];
|
||||
copy_v3_v3(incr_dir, global_dir);
|
||||
if (!(activeSnap(t) && validSnap(t)) &&
|
||||
if (!(transform_snap_is_active(t) && validSnap(t)) &&
|
||||
transform_snap_increment_ex(t, (t->con.mode & CON_APPLY) != 0, incr_dir)) {
|
||||
|
||||
/* Test for mixed snap with grid. */
|
||||
|
|
|
@ -562,7 +562,7 @@ static void applyVertSlide(TransInfo *t, const int UNUSED(mval[2]))
|
|||
|
||||
final = t->values[0] + t->values_modal_offset[0];
|
||||
|
||||
applySnappingAsGroup(t, &final);
|
||||
transform_snap_mixed_apply(t, &final);
|
||||
if (!validSnap(t)) {
|
||||
transform_snap_increment(t, &final);
|
||||
}
|
||||
|
|
|
@ -119,50 +119,12 @@ bool validSnap(const TransInfo *t)
|
|||
(t->tsnap.status & (MULTI_POINTS | TARGET_INIT)) == (MULTI_POINTS | TARGET_INIT);
|
||||
}
|
||||
|
||||
bool activeSnap(const TransInfo *t)
|
||||
bool transform_snap_is_active(const TransInfo *t)
|
||||
{
|
||||
return ((t->modifiers & (MOD_SNAP | MOD_SNAP_INVERT)) == MOD_SNAP) ||
|
||||
((t->modifiers & (MOD_SNAP | MOD_SNAP_INVERT)) == MOD_SNAP_INVERT);
|
||||
}
|
||||
|
||||
bool activeSnap_SnappingIndividual(const TransInfo *t)
|
||||
{
|
||||
if (!activeSnap(t) || (t->flag & T_NO_PROJECT)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(t->tsnap.project || (t->tsnap.mode & SCE_SNAP_MODE_FACE_NEAREST))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (doForceIncrementSnap(t)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool activeSnap_SnappingAsGroup(const TransInfo *t)
|
||||
{
|
||||
if (!activeSnap(t)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (t->tsnap.mode == SCE_SNAP_MODE_FACE_RAYCAST && t->tsnap.project) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (t->tsnap.mode == SCE_SNAP_MODE_FACE_NEAREST) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (doForceIncrementSnap(t)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool transformModeUseSnap(const TransInfo *t)
|
||||
{
|
||||
ToolSettings *ts = t->settings;
|
||||
|
@ -190,7 +152,7 @@ static bool doForceIncrementSnap(const TransInfo *t)
|
|||
void drawSnapping(const struct bContext *C, TransInfo *t)
|
||||
{
|
||||
uchar col[4], selectedCol[4], activeCol[4];
|
||||
if (!activeSnap(t)) {
|
||||
if (!transform_snap_is_active(t)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -483,9 +445,30 @@ static void applyFaceNearest(TransInfo *t, TransDataContainer *tc, TransData *td
|
|||
/* TODO: support snap alignment similar to #SCE_SNAP_MODE_FACE_RAYCAST? */
|
||||
}
|
||||
|
||||
void applySnappingIndividual(TransInfo *t)
|
||||
bool transform_snap_project_individual_is_active(const TransInfo *t)
|
||||
{
|
||||
if (!activeSnap_SnappingIndividual(t)) {
|
||||
if (!transform_snap_is_active(t)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (t->flag & T_NO_PROJECT) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(t->tsnap.project || (t->tsnap.mode & SCE_SNAP_MODE_FACE_NEAREST))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (doForceIncrementSnap(t)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void transform_snap_project_individual_apply(TransInfo *t)
|
||||
{
|
||||
if (!transform_snap_project_individual_is_active(t)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -514,9 +497,30 @@ void applySnappingIndividual(TransInfo *t)
|
|||
}
|
||||
}
|
||||
|
||||
void applySnappingAsGroup(TransInfo *t, float *vec)
|
||||
static bool transform_snap_mixed_is_active(const TransInfo *t)
|
||||
{
|
||||
if (!activeSnap_SnappingAsGroup(t)) {
|
||||
if (!transform_snap_is_active(t)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (t->tsnap.mode == SCE_SNAP_MODE_FACE_RAYCAST && t->tsnap.project) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (t->tsnap.mode == SCE_SNAP_MODE_FACE_NEAREST) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (doForceIncrementSnap(t)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void transform_snap_mixed_apply(TransInfo *t, float *vec)
|
||||
{
|
||||
if (!transform_snap_mixed_is_active(t)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -526,7 +530,7 @@ void applySnappingAsGroup(TransInfo *t, float *vec)
|
|||
t->tsnap.applySnap(t, vec);
|
||||
}
|
||||
else if (((t->tsnap.mode & ~(SCE_SNAP_MODE_INCREMENT | SCE_SNAP_MODE_GRID)) != 0) &&
|
||||
activeSnap(t)) {
|
||||
transform_snap_is_active(t)) {
|
||||
double current = PIL_check_seconds_timer();
|
||||
|
||||
/* Time base quirky code to go around find-nearest slowness. */
|
||||
|
@ -1628,7 +1632,7 @@ static void snap_increment_apply(const TransInfo *t,
|
|||
|
||||
bool transform_snap_increment_ex(const TransInfo *t, bool use_local_space, float *r_val)
|
||||
{
|
||||
if (!activeSnap(t)) {
|
||||
if (!transform_snap_is_active(t)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1664,8 +1668,9 @@ bool transform_snap_increment(const TransInfo *t, float *r_val)
|
|||
|
||||
float transform_snap_increment_get(const TransInfo *t)
|
||||
{
|
||||
if (activeSnap(t) && (!transformModeUseSnap(t) ||
|
||||
(t->tsnap.mode & (SCE_SNAP_MODE_INCREMENT | SCE_SNAP_MODE_GRID)))) {
|
||||
if (transform_snap_is_active(t) &&
|
||||
(!transformModeUseSnap(t) ||
|
||||
(t->tsnap.mode & (SCE_SNAP_MODE_INCREMENT | SCE_SNAP_MODE_GRID)))) {
|
||||
return (t->modifiers & MOD_PRECISION) ? t->snap[1] : t->snap[0];
|
||||
}
|
||||
|
||||
|
|
|
@ -43,16 +43,15 @@ bool transform_snap_increment_ex(const TransInfo *t, bool use_local_space, float
|
|||
bool transform_snap_increment(const TransInfo *t, float *val);
|
||||
float transform_snap_increment_get(const TransInfo *t);
|
||||
|
||||
bool activeSnap(const TransInfo *t);
|
||||
bool activeSnap_SnappingIndividual(const TransInfo *t);
|
||||
bool activeSnap_SnappingAsGroup(const TransInfo *t);
|
||||
bool transform_snap_is_active(const TransInfo *t);
|
||||
|
||||
bool validSnap(const TransInfo *t);
|
||||
|
||||
void initSnapping(struct TransInfo *t, struct wmOperator *op);
|
||||
void freeSnapping(struct TransInfo *t);
|
||||
void applySnappingIndividual(TransInfo *t);
|
||||
void applySnappingAsGroup(TransInfo *t, float *vec);
|
||||
bool transform_snap_project_individual_is_active(const TransInfo *t);
|
||||
void transform_snap_project_individual_apply(TransInfo *t);
|
||||
void transform_snap_mixed_apply(TransInfo *t, float *vec);
|
||||
void resetSnapping(TransInfo *t);
|
||||
eRedrawFlag handleSnapping(TransInfo *t, const struct wmEvent *event);
|
||||
void drawSnapping(const struct bContext *C, TransInfo *t);
|
||||
|
|
|
@ -34,7 +34,7 @@ short getAnimEdit_SnapMode(TransInfo *t)
|
|||
}
|
||||
}
|
||||
else if (t->spacetype == SPACE_GRAPH) {
|
||||
if ((t->mode == TFM_TRANSLATION) && activeSnap(t)) {
|
||||
if ((t->mode == TFM_TRANSLATION) && transform_snap_is_active(t)) {
|
||||
return autosnap;
|
||||
}
|
||||
SpaceGraph *sipo = (SpaceGraph *)t->area->spacedata.first;
|
||||
|
|
|
@ -241,7 +241,7 @@ static void snap_object_data_mesh_get(SnapObjectContext *sctx,
|
|||
bool use_hide,
|
||||
BVHTreeFromMesh *r_treedata)
|
||||
{
|
||||
const Span<float3> positions = me_eval->vert_positions();
|
||||
const Span<float3> vert_positions = me_eval->vert_positions();
|
||||
const Span<MPoly> polys = me_eval->polys();
|
||||
const Span<int> corner_verts = me_eval->corner_verts();
|
||||
|
||||
|
@ -259,7 +259,7 @@ static void snap_object_data_mesh_get(SnapObjectContext *sctx,
|
|||
BLI_assert(!polys.data() || r_treedata->looptri);
|
||||
BLI_assert(!r_treedata->tree || r_treedata->looptri);
|
||||
|
||||
UNUSED_VARS_NDEBUG(positions, polys, corner_verts);
|
||||
UNUSED_VARS_NDEBUG(vert_positions, polys, corner_verts);
|
||||
}
|
||||
|
||||
/* Searches for the #Mesh_Runtime associated with the object that is most likely to be updated due
|
||||
|
@ -620,12 +620,12 @@ static void mesh_looptri_raycast_backface_culling_cb(void *userdata,
|
|||
BVHTreeRayHit *hit)
|
||||
{
|
||||
const BVHTreeFromMesh *data = (BVHTreeFromMesh *)userdata;
|
||||
const float(*positions)[3] = data->vert_positions;
|
||||
const float(*vert_positions)[3] = data->vert_positions;
|
||||
const MLoopTri *lt = &data->looptri[index];
|
||||
const float *vtri_co[3] = {
|
||||
positions[data->corner_verts[lt->tri[0]]],
|
||||
positions[data->corner_verts[lt->tri[1]]],
|
||||
positions[data->corner_verts[lt->tri[2]]],
|
||||
vert_positions[data->corner_verts[lt->tri[0]]],
|
||||
vert_positions[data->corner_verts[lt->tri[1]]],
|
||||
vert_positions[data->corner_verts[lt->tri[2]]],
|
||||
};
|
||||
float dist = bvhtree_ray_tri_intersection(ray, hit->dist, UNPACK3(vtri_co));
|
||||
|
||||
|
@ -1424,7 +1424,7 @@ struct Nearest2dUserData {
|
|||
BMesh *bm;
|
||||
};
|
||||
struct {
|
||||
const float (*positions)[3];
|
||||
const float (*vert_positions)[3];
|
||||
const float (*vert_normals)[3];
|
||||
const MEdge *edge; /* only used for #BVHTreeFromMeshEdges */
|
||||
const int *corner_verts;
|
||||
|
@ -1439,7 +1439,7 @@ struct Nearest2dUserData {
|
|||
|
||||
static void cb_mvert_co_get(const int index, const Nearest2dUserData *data, const float **r_co)
|
||||
{
|
||||
*r_co = data->positions[index];
|
||||
*r_co = data->vert_positions[index];
|
||||
}
|
||||
|
||||
static void cb_bvert_co_get(const int index, const Nearest2dUserData *data, const float **r_co)
|
||||
|
@ -1715,7 +1715,7 @@ static void nearest2d_data_init_mesh(const Mesh *mesh,
|
|||
r_nearest2d->get_tri_verts_index = cb_mlooptri_verts_get;
|
||||
r_nearest2d->get_tri_edges_index = cb_mlooptri_edges_get;
|
||||
|
||||
r_nearest2d->positions = BKE_mesh_vert_positions(mesh);
|
||||
r_nearest2d->vert_positions = BKE_mesh_vert_positions(mesh);
|
||||
r_nearest2d->vert_normals = BKE_mesh_vertex_normals_ensure(mesh);
|
||||
r_nearest2d->edge = mesh->edges().data();
|
||||
r_nearest2d->corner_verts = mesh->corner_verts().data();
|
||||
|
|
|
@ -1669,7 +1669,7 @@ std::optional<Mesh *> mesh_merge_by_distance_connected(const Mesh &mesh,
|
|||
continue;
|
||||
}
|
||||
if (v1 > v2) {
|
||||
std::swap( v1, v2);
|
||||
std::swap(v1, v2);
|
||||
}
|
||||
WeldVertexCluster *v1_cluster = &vert_clusters[v1];
|
||||
WeldVertexCluster *v2_cluster = &vert_clusters[v2];
|
||||
|
|
|
@ -1881,7 +1881,7 @@ static void lineart_edge_neighbor_init_task(void *__restrict userdata,
|
|||
adj_e->v1 = corner_verts[looptri->tri[i % 3]];
|
||||
adj_e->v2 = corner_verts[looptri->tri[(i + 1) % 3]];
|
||||
if (adj_e->v1 > adj_e->v2) {
|
||||
std::swap( adj_e->v1, adj_e->v2);
|
||||
std::swap(adj_e->v1, adj_e->v2);
|
||||
}
|
||||
edge_nabr->e = -1;
|
||||
|
||||
|
@ -3271,7 +3271,7 @@ static void lineart_add_isec_thread(LineartIsecThread *th,
|
|||
isec_single->tri1 = tri1;
|
||||
isec_single->tri2 = tri2;
|
||||
if (tri1->target_reference > tri2->target_reference) {
|
||||
std::swap( isec_single->tri1, isec_single->tri2);
|
||||
std::swap(isec_single->tri1, isec_single->tri2);
|
||||
}
|
||||
th->current++;
|
||||
}
|
||||
|
|
|
@ -148,10 +148,10 @@ bool paint_is_grid_face_hidden(const uint * /*grid_hidden*/,
|
|||
* \{ */
|
||||
void BKE_mesh_calc_poly_normal(const struct MPoly * /*mpoly*/,
|
||||
const int * /*corner_verts*/,
|
||||
const float (*positions)[3],
|
||||
const float (*vert_positions)[3],
|
||||
float[3] /*col*/)
|
||||
{
|
||||
UNUSED_VARS(positions);
|
||||
UNUSED_VARS(vert_positions);
|
||||
BLI_assert_unreachable();
|
||||
}
|
||||
|
||||
|
|
|
@ -10,15 +10,15 @@
|
|||
/** \name Static constructors
|
||||
* \{ */
|
||||
|
||||
mat2x2 mat2x2__diagonal(float v)
|
||||
mat2x2 mat2x2_diagonal(float v)
|
||||
{
|
||||
return mat2x2(vec2(v, 0.0), vec2(0.0, v));
|
||||
}
|
||||
mat3x3 mat3x3__diagonal(float v)
|
||||
mat3x3 mat3x3_diagonal(float v)
|
||||
{
|
||||
return mat3x3(vec3(v, 0.0, 0.0), vec3(0.0, v, 0.0), vec3(0.0, 0.0, v));
|
||||
}
|
||||
mat4x4 mat4x4__diagonal(float v)
|
||||
mat4x4 mat4x4_diagonal(float v)
|
||||
{
|
||||
return mat4x4(vec4(v, 0.0, 0.0, 0.0),
|
||||
vec4(0.0, v, 0.0, 0.0),
|
||||
|
@ -26,43 +26,43 @@ mat4x4 mat4x4__diagonal(float v)
|
|||
vec4(0.0, 0.0, 0.0, v));
|
||||
}
|
||||
|
||||
mat2x2 mat2x2__all(float v)
|
||||
mat2x2 mat2x2_all(float v)
|
||||
{
|
||||
return mat2x2(vec2(v), vec2(v));
|
||||
}
|
||||
mat3x3 mat3x3__all(float v)
|
||||
mat3x3 mat3x3_all(float v)
|
||||
{
|
||||
return mat3x3(vec3(v), vec3(v), vec3(v));
|
||||
}
|
||||
mat4x4 mat4x4__all(float v)
|
||||
mat4x4 mat4x4_all(float v)
|
||||
{
|
||||
return mat4x4(vec4(v), vec4(v), vec4(v), vec4(v));
|
||||
}
|
||||
|
||||
mat2x2 mat2x2__zero(float v)
|
||||
mat2x2 mat2x2_zero(float v)
|
||||
{
|
||||
return mat2x2__all(0.0);
|
||||
return mat2x2_all(0.0);
|
||||
}
|
||||
mat3x3 mat3x3__zero(float v)
|
||||
mat3x3 mat3x3_zero(float v)
|
||||
{
|
||||
return mat3x3__all(0.0);
|
||||
return mat3x3_all(0.0);
|
||||
}
|
||||
mat4x4 mat4x4__zero(float v)
|
||||
mat4x4 mat4x4_zero(float v)
|
||||
{
|
||||
return mat4x4__all(0.0);
|
||||
return mat4x4_all(0.0);
|
||||
}
|
||||
|
||||
mat2x2 mat2x2__identity()
|
||||
mat2x2 mat2x2_identity()
|
||||
{
|
||||
return mat2x2__diagonal(1.0);
|
||||
return mat2x2_diagonal(1.0);
|
||||
}
|
||||
mat3x3 mat3x3__identity()
|
||||
mat3x3 mat3x3_identity()
|
||||
{
|
||||
return mat3x3__diagonal(1.0);
|
||||
return mat3x3_diagonal(1.0);
|
||||
}
|
||||
mat4x4 mat4x4__identity()
|
||||
mat4x4 mat4x4_identity()
|
||||
{
|
||||
return mat4x4__diagonal(1.0);
|
||||
return mat4x4_diagonal(1.0);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
@ -362,7 +362,7 @@ vec3 project_point(mat4x4 mat, vec3 point);
|
|||
* Maps each axis range to [-1..1] range for all axes.
|
||||
* The resulting matrix can be used with either #project_point or #transform_point.
|
||||
*/
|
||||
mat4x4 projection__orthographic(
|
||||
mat4x4 projection_orthographic(
|
||||
float left, float right, float bottom, float top, float near_clip, float far_clip);
|
||||
|
||||
/**
|
||||
|
@ -371,7 +371,7 @@ mat4x4 projection__orthographic(
|
|||
* `left`, `right`, `bottom`, `top` are frustum side distances at `z=near_clip`.
|
||||
* The resulting matrix can be used with #project_point.
|
||||
*/
|
||||
mat4x4 projection__perspective(
|
||||
mat4x4 projection_perspective(
|
||||
float left, float right, float bottom, float top, float near_clip, float far_clip);
|
||||
|
||||
/**
|
||||
|
@ -380,12 +380,12 @@ mat4x4 projection__perspective(
|
|||
* Uses field of view angles instead of plane distances.
|
||||
* The resulting matrix can be used with #project_point.
|
||||
*/
|
||||
mat4x4 projection__perspective_fov(float angle_left,
|
||||
float angle_right,
|
||||
float angle_bottom,
|
||||
float angle_top,
|
||||
float near_clip,
|
||||
float far_clip);
|
||||
mat4x4 projection_perspective_fov(float angle_left,
|
||||
float angle_right,
|
||||
float angle_bottom,
|
||||
float angle_top,
|
||||
float near_clip,
|
||||
float far_clip);
|
||||
|
||||
/** \} */
|
||||
|
||||
|
@ -469,20 +469,18 @@ mat4x4 invert(mat4x4 mat, out bool r_success)
|
|||
return r_success ? inverse(mat) : mat4x4(0.0);
|
||||
}
|
||||
|
||||
# ifdef GPU_METAL
|
||||
float2 normalize(float2 a)
|
||||
vec2 normalize(vec2 a)
|
||||
{
|
||||
return a * rsqrt(length_squared(a));
|
||||
return a * inversesqrt(length_squared(a));
|
||||
}
|
||||
float3 normalize(float3 a)
|
||||
vec3 normalize(vec3 a)
|
||||
{
|
||||
return a * rsqrt(length_squared(a));
|
||||
return a * inversesqrt(length_squared(a));
|
||||
}
|
||||
float4 normalize(float4 a)
|
||||
vec4 normalize(vec4 a)
|
||||
{
|
||||
return a * rsqrt(length_squared(a));
|
||||
return a * inversesqrt(length_squared(a));
|
||||
}
|
||||
# endif
|
||||
|
||||
mat2x2 normalize(mat2x2 mat)
|
||||
{
|
||||
|
@ -1013,7 +1011,7 @@ mat4x4 from_loc_rot_scale(vec3 location, AxisAngle rotation, vec3 scale)
|
|||
return ret;
|
||||
}
|
||||
|
||||
void detail__normalized_to_eul2(mat3 mat, out EulerXYZ eul1, out EulerXYZ eul2)
|
||||
void detail_normalized_to_eul2(mat3 mat, out EulerXYZ eul1, out EulerXYZ eul2)
|
||||
{
|
||||
float cy = hypot(mat[0][0], mat[0][1]);
|
||||
if (cy > 16.0f * FLT_EPSILON) {
|
||||
|
@ -1044,7 +1042,7 @@ EulerXYZ to_euler(mat3x3 mat, const bool normalized)
|
|||
mat = normalize(mat);
|
||||
}
|
||||
EulerXYZ eul1, eul2;
|
||||
detail__normalized_to_eul2(mat, eul1, eul2);
|
||||
detail_normalized_to_eul2(mat, eul1, eul2);
|
||||
/* Return best, which is just the one with lowest values it in. */
|
||||
return (length_manhattan(as_vec3(eul1)) > length_manhattan(as_vec3(eul2))) ? eul2 : eul1;
|
||||
}
|
||||
|
@ -1140,11 +1138,11 @@ Quaternion normalized_to_quat_fast(mat3 mat)
|
|||
return q;
|
||||
}
|
||||
|
||||
Quaternion detail__normalized_to_quat_with_checks(mat3x3 mat)
|
||||
Quaternion detail_normalized_to_quat_with_checks(mat3x3 mat)
|
||||
{
|
||||
float det = determinant(mat);
|
||||
if (!isfinite(det)) {
|
||||
return Quaternion__identity();
|
||||
return Quaternion_identity();
|
||||
}
|
||||
else if (det < 0.0) {
|
||||
return normalized_to_quat_fast(-mat);
|
||||
|
@ -1154,7 +1152,7 @@ Quaternion detail__normalized_to_quat_with_checks(mat3x3 mat)
|
|||
|
||||
Quaternion to_quaternion(mat3x3 mat)
|
||||
{
|
||||
return detail__normalized_to_quat_with_checks(normalize(mat));
|
||||
return detail_normalized_to_quat_with_checks(normalize(mat));
|
||||
}
|
||||
Quaternion to_quaternion(mat3x3 mat, const bool normalized)
|
||||
{
|
||||
|
@ -1310,7 +1308,7 @@ mat4x4 interpolate_fast(mat4x4 a, mat4x4 b, float t)
|
|||
return from_loc_rot_scale(location, rotation, scale);
|
||||
}
|
||||
|
||||
mat4x4 projection__orthographic(
|
||||
mat4x4 projection_orthographic(
|
||||
float left, float right, float bottom, float top, float near_clip, float far_clip)
|
||||
{
|
||||
float x_delta = right - left;
|
||||
|
@ -1329,7 +1327,7 @@ mat4x4 projection__orthographic(
|
|||
return mat;
|
||||
}
|
||||
|
||||
mat4x4 projection__perspective(
|
||||
mat4x4 projection_perspective(
|
||||
float left, float right, float bottom, float top, float near_clip, float far_clip)
|
||||
{
|
||||
float x_delta = right - left;
|
||||
|
@ -1349,14 +1347,14 @@ mat4x4 projection__perspective(
|
|||
return mat;
|
||||
}
|
||||
|
||||
mat4x4 projection__perspective_fov(float angle_left,
|
||||
float angle_right,
|
||||
float angle_bottom,
|
||||
float angle_top,
|
||||
float near_clip,
|
||||
float far_clip)
|
||||
mat4x4 projection_perspective_fov(float angle_left,
|
||||
float angle_right,
|
||||
float angle_bottom,
|
||||
float angle_top,
|
||||
float near_clip,
|
||||
float far_clip)
|
||||
{
|
||||
mat4x4 mat = projection__perspective(
|
||||
mat4x4 mat = projection_perspective(
|
||||
tan(angle_left), tan(angle_right), tan(angle_bottom), tan(angle_top), near_clip, far_clip);
|
||||
mat[0][0] /= near_clip;
|
||||
mat[1][1] /= near_clip;
|
||||
|
|
|
@ -29,7 +29,7 @@ struct AxisAngle {
|
|||
# endif
|
||||
};
|
||||
|
||||
AxisAngle AxisAngle__identity()
|
||||
AxisAngle AxisAngle_identity()
|
||||
{
|
||||
return AxisAngle(vec3(0, 1, 0), 0);
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ vec4 as_vec4(Quaternion quat)
|
|||
return vec4(quat.x, quat.y, quat.z, quat.w);
|
||||
}
|
||||
|
||||
Quaternion Quaternion__identity()
|
||||
Quaternion Quaternion_identity()
|
||||
{
|
||||
return Quaternion(1, 0, 0, 0);
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ vec3 as_vec3(EulerXYZ eul)
|
|||
return vec3(eul.x, eul.y, eul.z);
|
||||
}
|
||||
|
||||
EulerXYZ EulerXYZ__identity()
|
||||
EulerXYZ EulerXYZ_identity()
|
||||
{
|
||||
return EulerXYZ(0, 0, 0);
|
||||
}
|
||||
|
|
|
@ -12,15 +12,15 @@ void main()
|
|||
{
|
||||
TEST(math_matrix, MatrixInverse)
|
||||
{
|
||||
mat3x3 mat = mat3x3__diagonal(2);
|
||||
mat3x3 mat = mat3x3_diagonal(2);
|
||||
mat3x3 inv = invert(mat);
|
||||
mat3x3 expect = mat3x3__diagonal(0.5f);
|
||||
mat3x3 expect = mat3x3_diagonal(0.5f);
|
||||
EXPECT_NEAR(inv, expect, 1e-5f);
|
||||
|
||||
bool success;
|
||||
mat3x3 m2 = mat3x3__all(1);
|
||||
mat3x3 m2 = mat3x3_all(1);
|
||||
mat3x3 inv2 = invert(m2, success);
|
||||
mat3x3 expect2 = mat3x3__all(0);
|
||||
mat3x3 expect2 = mat3x3_all(0);
|
||||
EXPECT_NEAR(inv2, expect2, 1e-5f);
|
||||
EXPECT_FALSE(success);
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ void main()
|
|||
m = mat4(from_rotation(quat));
|
||||
EXPECT_NEAR(m, expect, 1e-5);
|
||||
m = mat4(from_rotation(axis_angle));
|
||||
EXPECT_NEAR(m, expect, 1e-5);
|
||||
EXPECT_NEAR(m, expect, 3e-4); /* Has some precision issue on some platform. */
|
||||
|
||||
m = from_scale(vec4(1, 2, 3, 4));
|
||||
expect = mat4x4(vec4(1, 0, 0, 0), vec4(0, 2, 0, 0), vec4(0, 0, 3, 0), vec4(0, 0, 0, 4));
|
||||
|
@ -211,9 +211,9 @@ void main()
|
|||
vec4(0.389669f, 0.647565f, 0.168130f, 0.200000f),
|
||||
vec4(-0.536231f, 0.330541f, 0.443163f, 0.300000f),
|
||||
vec4(0.000000f, 0.000000f, 0.000000f, 1.000000f)));
|
||||
mat4x4 m1 = mat4x4__identity();
|
||||
mat4x4 m1 = mat4x4_identity();
|
||||
mat4x4 result;
|
||||
const float epsilon = 1e-6;
|
||||
const float epsilon = 2e-5;
|
||||
result = interpolate_fast(m1, m2, 0.0f);
|
||||
EXPECT_NEAR(result, m1, epsilon);
|
||||
result = interpolate_fast(m1, m2, 1.0f);
|
||||
|
@ -235,7 +235,7 @@ void main()
|
|||
const vec3 p = vec3(1, 2, 3);
|
||||
mat4x4 m4 = from_loc_rot(vec3(10, 0, 0), EulerXYZ(M_PI_2, M_PI_2, M_PI_2));
|
||||
mat3x3 m3 = from_rotation(EulerXYZ(M_PI_2, M_PI_2, M_PI_2));
|
||||
mat4x4 pers4 = projection__perspective(-0.1f, 0.1f, -0.1f, 0.1f, -0.1f, -1.0f);
|
||||
mat4x4 pers4 = projection_perspective(-0.1f, 0.1f, -0.1f, 0.1f, -0.1f, -1.0f);
|
||||
mat3x3 pers3 = mat3x3(vec3(1, 0, 0.1f), vec3(0, 1, 0.1f), vec3(0, 0.1f, 1));
|
||||
|
||||
expect = vec3(13, 2, -1);
|
||||
|
@ -264,9 +264,9 @@ void main()
|
|||
TEST(math_matrix, MatrixProjection)
|
||||
{
|
||||
mat4x4 expect;
|
||||
mat4x4 ortho = projection__orthographic(-0.2f, 0.3f, -0.2f, 0.4f, -0.2f, -0.5f);
|
||||
mat4x4 pers1 = projection__perspective(-0.2f, 0.3f, -0.2f, 0.4f, -0.2f, -0.5f);
|
||||
mat4x4 pers2 = projection__perspective_fov(
|
||||
mat4x4 ortho = projection_orthographic(-0.2f, 0.3f, -0.2f, 0.4f, -0.2f, -0.5f);
|
||||
mat4x4 pers1 = projection_perspective(-0.2f, 0.3f, -0.2f, 0.4f, -0.2f, -0.5f);
|
||||
mat4x4 pers2 = projection_perspective_fov(
|
||||
atan(-0.2f), atan(0.3f), atan(-0.2f), atan(0.4f), -0.2f, -0.5f);
|
||||
|
||||
expect = transpose(mat4x4(vec4(4.0f, 0.0f, 0.0f, -0.2f),
|
||||
|
|
|
@ -375,7 +375,7 @@ typedef struct bNode {
|
|||
bool is_group_output() const;
|
||||
const blender::nodes::NodeDeclaration *declaration() const;
|
||||
/** A span containing all internal links when the node is muted. */
|
||||
blender::Span<const bNodeLink *> internal_links() const;
|
||||
blender::Span<bNodeLink> internal_links() const;
|
||||
|
||||
/* The following methods are only available when #bNodeTree.ensure_topology_cache has been
|
||||
* called. */
|
||||
|
|
|
@ -2377,10 +2377,10 @@ static void rna_Node_parent_set(PointerRNA *ptr,
|
|||
static void rna_Node_internal_links_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
||||
{
|
||||
bNode *node = ptr->data;
|
||||
bNodeLink **begin;
|
||||
bNodeLink *begin;
|
||||
int len;
|
||||
nodeInternalLinks(node, &begin, &len);
|
||||
rna_iterator_array_begin(iter, begin, sizeof(bNodeLink *), len, false, NULL);
|
||||
rna_iterator_array_begin(iter, begin, sizeof(bNodeLink), len, false, NULL);
|
||||
}
|
||||
|
||||
static bool rna_Node_parent_poll(PointerRNA *ptr, PointerRNA value)
|
||||
|
@ -12203,7 +12203,7 @@ static void rna_def_node(BlenderRNA *brna)
|
|||
"rna_Node_internal_links_begin",
|
||||
"rna_iterator_array_next",
|
||||
"rna_iterator_array_end",
|
||||
"rna_iterator_array_dereference_get",
|
||||
"rna_iterator_array_get",
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
|
|
|
@ -125,15 +125,15 @@ static int svert_sum_cmp(const void *e1, const void *e2)
|
|||
}
|
||||
|
||||
static void svert_from_mvert(SortVertsElem *sv,
|
||||
const float (*positions)[3],
|
||||
const float (*vert_positions)[3],
|
||||
const int i_begin,
|
||||
const int i_end)
|
||||
{
|
||||
int i;
|
||||
for (i = i_begin; i < i_end; i++, sv++) {
|
||||
sv->vertex_num = i;
|
||||
copy_v3_v3(sv->co, positions[i]);
|
||||
sv->sum_co = sum_v3(positions[i]);
|
||||
copy_v3_v3(sv->co, vert_positions[i]);
|
||||
sv->sum_co = sum_v3(vert_positions[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -145,7 +145,7 @@ static void svert_from_mvert(SortVertsElem *sv,
|
|||
* The `int doubles_map[verts_source_num]` array must have been allocated by caller.
|
||||
*/
|
||||
static void dm_mvert_map_doubles(int *doubles_map,
|
||||
const float (*positions)[3],
|
||||
const float (*vert_positions)[3],
|
||||
const int target_start,
|
||||
const int target_verts_num,
|
||||
const int source_start,
|
||||
|
@ -167,10 +167,10 @@ static void dm_mvert_map_doubles(int *doubles_map,
|
|||
MEM_malloc_arrayN(source_verts_num, sizeof(SortVertsElem), __func__));
|
||||
|
||||
/* Copy target vertices index and cos into SortVertsElem array */
|
||||
svert_from_mvert(sorted_verts_target, positions, target_start, target_end);
|
||||
svert_from_mvert(sorted_verts_target, vert_positions, target_start, target_end);
|
||||
|
||||
/* Copy source vertices index and cos into SortVertsElem array */
|
||||
svert_from_mvert(sorted_verts_source, positions, source_start, source_end);
|
||||
svert_from_mvert(sorted_verts_source, vert_positions, source_start, source_end);
|
||||
|
||||
/* sort arrays according to sum of vertex coordinates (sumco) */
|
||||
qsort(sorted_verts_target, target_verts_num, sizeof(SortVertsElem), svert_sum_cmp);
|
||||
|
@ -238,8 +238,8 @@ static void dm_mvert_map_doubles(int *doubles_map,
|
|||
* then there will be no mapping at all for this source. */
|
||||
while (best_target_vertex != -1 &&
|
||||
!ELEM(doubles_map[best_target_vertex], -1, best_target_vertex)) {
|
||||
if (compare_len_v3v3(positions[sve_source->vertex_num],
|
||||
positions[doubles_map[best_target_vertex]],
|
||||
if (compare_len_v3v3(vert_positions[sve_source->vertex_num],
|
||||
vert_positions[doubles_map[best_target_vertex]],
|
||||
dist)) {
|
||||
best_target_vertex = doubles_map[best_target_vertex];
|
||||
}
|
||||
|
|
|
@ -177,19 +177,16 @@ static void meshcache_do(MeshCacheModifierData *mcmd,
|
|||
}
|
||||
else {
|
||||
float(*vertexCos_New)[3] = MEM_malloc_arrayN(verts_num, sizeof(*vertexCos_New), __func__);
|
||||
const float(*positions)[3] = BKE_mesh_vert_positions(me);
|
||||
|
||||
BKE_mesh_calc_relative_deform(
|
||||
BKE_mesh_polys(me),
|
||||
me->totpoly,
|
||||
BKE_mesh_corner_verts(me),
|
||||
me->totvert,
|
||||
|
||||
(const float(*)[3])positions, /* From the original Mesh. */
|
||||
BKE_mesh_vert_positions(me), /* From the original Mesh. */
|
||||
(const float(*)[3])vertexCos_Real, /* the input we've been given (shape keys!) */
|
||||
|
||||
(const float(*)[3])vertexCos, /* The result of this modifier. */
|
||||
vertexCos_New /* The result of this function. */
|
||||
(const float(*)[3])vertexCos, /* The result of this modifier. */
|
||||
vertexCos_New /* The result of this function. */
|
||||
);
|
||||
|
||||
/* write the corrected locations back into the result */
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue