Alternative Upload geometry data in parallel to multiple GPUs using the "Multi-Device" #107552
|
@ -314,7 +314,7 @@ if(WITH_CYCLES AND WITH_CYCLES_OSL)
|
|||
endif()
|
||||
endif()
|
||||
|
||||
if(WITH_CYCLES AND (WITH_CYCLES_DEVICE_ONEAPI OR (WITH_CYCLES_EMBREE AND EMBREE_SYCL_SUPPORT)))
|
||||
if(WITH_CYCLES AND WITH_CYCLES_DEVICE_ONEAPI)
|
||||
set(CYCLES_LEVEL_ZERO ${LIBDIR}/level-zero CACHE PATH "Path to Level Zero installation")
|
||||
if(EXISTS ${CYCLES_LEVEL_ZERO} AND NOT LEVEL_ZERO_ROOT_DIR)
|
||||
set(LEVEL_ZERO_ROOT_DIR ${CYCLES_LEVEL_ZERO})
|
||||
|
@ -324,6 +324,13 @@ if(WITH_CYCLES AND (WITH_CYCLES_DEVICE_ONEAPI OR (WITH_CYCLES_EMBREE AND EMBREE_
|
|||
if(EXISTS ${CYCLES_SYCL} AND NOT SYCL_ROOT_DIR)
|
||||
set(SYCL_ROOT_DIR ${CYCLES_SYCL})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# add_bundled_libraries for SYCL, but custom since we need to filter the files.
|
||||
if(DEFINED LIBDIR)
|
||||
if(NOT DEFINED SYCL_ROOT_DIR)
|
||||
set(SYCL_ROOT_DIR ${LIBDIR}/dpcpp)
|
||||
endif()
|
||||
file(GLOB _sycl_runtime_libraries
|
||||
${SYCL_ROOT_DIR}/lib/libsycl.so
|
||||
${SYCL_ROOT_DIR}/lib/libsycl.so.*
|
||||
|
@ -1005,7 +1012,7 @@ if(PLATFORM_BUNDLED_LIBRARIES)
|
|||
|
||||
# Environment variables to run precompiled executables that needed libraries.
|
||||
list(JOIN PLATFORM_BUNDLED_LIBRARY_DIRS ":" _library_paths)
|
||||
set(PLATFORM_ENV_BUILD "LD_LIBRARY_PATH=\"${_library_paths};${LD_LIBRARY_PATH}\"")
|
||||
set(PLATFORM_ENV_BUILD "LD_LIBRARY_PATH=\"${_library_paths}:${LD_LIBRARY_PATH}\"")
|
||||
set(PLATFORM_ENV_INSTALL "LD_LIBRARY_PATH=${CMAKE_INSTALL_PREFIX_WITH_CONFIG}/lib/;$LD_LIBRARY_PATH")
|
||||
unset(_library_paths)
|
||||
endif()
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#define __WCWIDTH_H__
|
||||
|
||||
#ifndef __cplusplus
|
||||
# if defined(__APPLE__) || defined(__NetBSD__)
|
||||
# if defined(__APPLE__) || defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
/* The <uchar.h> standard header is missing on macOS. */
|
||||
#include <stddef.h>
|
||||
typedef unsigned int char32_t;
|
||||
|
|
|
@ -14,7 +14,6 @@ PassAccessorGPU::PassAccessorGPU(DeviceQueue *queue,
|
|||
float exposure,
|
||||
int num_samples)
|
||||
: PassAccessor(pass_access_info, exposure, num_samples), queue_(queue)
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -118,7 +118,9 @@ ccl_device_inline int bsdf_sample(KernelGlobals kg,
|
|||
{
|
||||
/* For curves use the smooth normal, particularly for ribbons the geometric
|
||||
* normal gives too much darkening otherwise. */
|
||||
int label;
|
||||
*eval = zero_spectrum();
|
||||
*pdf = 0.f;
|
||||
int label = LABEL_NONE;
|
||||
const float3 Ng = (sd->type & PRIMITIVE_CURVE) ? sc->N : sd->Ng;
|
||||
|
||||
switch (sc->type) {
|
||||
|
@ -536,6 +538,7 @@ ccl_device_inline
|
|||
ccl_private float *pdf)
|
||||
{
|
||||
Spectrum eval = zero_spectrum();
|
||||
*pdf = 0.f;
|
||||
|
||||
switch (sc->type) {
|
||||
case CLOSURE_BSDF_DIFFUSE_ID:
|
||||
|
|
|
@ -56,10 +56,14 @@ ccl_device_forceinline float3 integrate_surface_ray_offset(KernelGlobals kg,
|
|||
* or dot(sd->Ng, ray_D) is small. Detect such cases and skip test?
|
||||
* - Instead of ray offset, can we tweak P to lie within the triangle?
|
||||
*/
|
||||
const uint3 tri_vindex = kernel_data_fetch(tri_vindex, sd->prim);
|
||||
const packed_float3 tri_a = kernel_data_fetch(tri_verts, tri_vindex.x),
|
||||
tri_b = kernel_data_fetch(tri_verts, tri_vindex.y),
|
||||
tri_c = kernel_data_fetch(tri_verts, tri_vindex.z);
|
||||
float3 verts[3];
|
||||
if (sd->type == PRIMITIVE_TRIANGLE) {
|
||||
triangle_vertices(kg, sd->prim, verts);
|
||||
}
|
||||
else {
|
||||
kernel_assert(sd->type == PRIMITIVE_MOTION_TRIANGLE);
|
||||
motion_triangle_vertices(kg, sd->object, sd->prim, sd->time, verts);
|
||||
}
|
||||
|
||||
float3 local_ray_P = ray_P;
|
||||
float3 local_ray_D = ray_D;
|
||||
|
@ -70,7 +74,7 @@ ccl_device_forceinline float3 integrate_surface_ray_offset(KernelGlobals kg,
|
|||
local_ray_D = transform_direction(&itfm, local_ray_D);
|
||||
}
|
||||
|
||||
if (ray_triangle_intersect_self(local_ray_P, local_ray_D, tri_a, tri_b, tri_c)) {
|
||||
if (ray_triangle_intersect_self(local_ray_P, local_ray_D, verts)) {
|
||||
return ray_P;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
/* Adopted from Libmv. */
|
||||
|
||||
#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__NetBSD__)
|
||||
#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__)
|
||||
/* Needed for memalign on Linux and _aligned_alloc on Windows. */
|
||||
# ifdef FREE_WINDOWS
|
||||
/* Make sure _aligned_malloc is included. */
|
||||
|
@ -33,7 +33,7 @@ void *util_aligned_malloc(size_t size, int alignment)
|
|||
return MEM_mallocN_aligned(size, alignment, "Cycles Aligned Alloc");
|
||||
#elif defined(_WIN32)
|
||||
return _aligned_malloc(size, alignment);
|
||||
#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__APPLE__)
|
||||
#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
void *result;
|
||||
if (posix_memalign(&result, alignment, size)) {
|
||||
/* Non-zero means allocation error
|
||||
|
|
|
@ -216,17 +216,15 @@ ccl_device_forceinline bool ray_triangle_intersect(const float3 ray_P,
|
|||
|
||||
ccl_device_forceinline bool ray_triangle_intersect_self(const float3 ray_P,
|
||||
const float3 ray_D,
|
||||
const float3 tri_a,
|
||||
const float3 tri_b,
|
||||
const float3 tri_c)
|
||||
const float3 verts[3])
|
||||
{
|
||||
/* Matches logic in ray_triangle_intersect, self intersection test to validate
|
||||
* if a ray is going to hit self or might incorrectly hit a neighboring triangle. */
|
||||
|
||||
/* Calculate vertices relative to ray origin. */
|
||||
const float3 v0 = tri_a - ray_P;
|
||||
const float3 v1 = tri_b - ray_P;
|
||||
const float3 v2 = tri_c - ray_P;
|
||||
const float3 v0 = verts[0] - ray_P;
|
||||
const float3 v1 = verts[1] - ray_P;
|
||||
const float3 v2 = verts[2] - ray_P;
|
||||
|
||||
/* Calculate triangle edges. */
|
||||
const float3 e0 = v2 - v0;
|
||||
|
|
|
@ -59,7 +59,7 @@ void *aligned_malloc(size_t size, size_t alignment)
|
|||
|
||||
#ifdef _WIN32
|
||||
return _aligned_malloc(size, alignment);
|
||||
#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__APPLE__)
|
||||
#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
void *result;
|
||||
|
||||
if (posix_memalign(&result, alignment, size)) {
|
||||
|
|
|
@ -52,7 +52,7 @@ size_t malloc_usable_size(void *ptr);
|
|||
# define UNLIKELY(x) (x)
|
||||
#endif
|
||||
|
||||
#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__NetBSD__)
|
||||
#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__)
|
||||
// Needed for memalign on Linux and _aligned_alloc on Windows.
|
||||
|
||||
# include <malloc.h>
|
||||
|
|
|
@ -21,7 +21,8 @@
|
|||
#include "libmv/base/aligned_malloc.h"
|
||||
#include "libmv/logging/logging.h"
|
||||
|
||||
#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__NetBSD__)
|
||||
#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__NetBSD__) && \
|
||||
!defined(__OpenBSD__)
|
||||
// Needed for memalign on Linux and _aligned_alloc on Windows.
|
||||
# ifdef FREE_WINDOWS
|
||||
/* make sure _aligned_malloc is included */
|
||||
|
@ -44,7 +45,8 @@ namespace libmv {
|
|||
void* aligned_malloc(int size, int alignment) {
|
||||
#ifdef _WIN32
|
||||
return _aligned_malloc(size, alignment);
|
||||
#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__APPLE__)
|
||||
#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || \
|
||||
defined(__OpenBSD__)
|
||||
void* result;
|
||||
|
||||
if (posix_memalign(&result, alignment, size)) {
|
||||
|
|
|
@ -27,10 +27,14 @@ class PHYSICS_PT_geometry_nodes(Panel):
|
|||
layout = self.layout
|
||||
|
||||
if len(context.selected_editable_objects) > 1:
|
||||
calc_text = iface_("Calculate Selected to Frame")
|
||||
bake_text = iface_("Bake Selected")
|
||||
else:
|
||||
calc_text = iface_("Calculate to Frame")
|
||||
bake_text = iface_("Bake")
|
||||
|
||||
layout.operator("object.simulation_nodes_cache_calculate_to_frame", text=calc_text).selected = True
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.operator("object.simulation_nodes_cache_bake", text=bake_text).selected = True
|
||||
row.operator("object.simulation_nodes_cache_delete", text="", icon='TRASH').selected = True
|
||||
|
|
|
@ -62,6 +62,7 @@ set(SRC_DNA_INC
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_pointcloud_types.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_rigidbody_types.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_scene_types.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_scene_enums.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_screen_types.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_sdna_types.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_sequence_types.h
|
||||
|
|
|
@ -123,7 +123,7 @@ TEST_F(AssetLibraryServiceTest, library_from_reference)
|
|||
|
||||
Main dummy_main{};
|
||||
std::string dummy_filepath = asset_library_root_ + SEP + "dummy.blend";
|
||||
BLI_strncpy(dummy_main.filepath, dummy_filepath.c_str(), sizeof(dummy_main.filepath));
|
||||
STRNCPY(dummy_main.filepath, dummy_filepath.c_str());
|
||||
EXPECT_EQ(lib, service->get_asset_library(&dummy_main, ref))
|
||||
<< "Getting the local (current file) reference with a main saved on disk should return "
|
||||
"the an asset library for this directory";
|
||||
|
|
|
@ -82,7 +82,7 @@ class CurvesGeometryRuntime {
|
|||
mutable SharedCache<Vector<float3>> evaluated_position_cache;
|
||||
|
||||
/**
|
||||
* A cache of bounds shared between data-blocks with unchanged positions and radii.
|
||||
* A cache of bounds shared between data-blocks with unchanged positions.
|
||||
* When data changes affect the bounds, the cache is "un-shared" with other geometries.
|
||||
* See #SharedCache comments.
|
||||
*/
|
||||
|
|
|
@ -252,25 +252,15 @@ void IDP_Reset(struct IDProperty *prop, const struct IDProperty *reference);
|
|||
/* C11 const correctness for casts */
|
||||
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
|
||||
# define IDP_Float(prop) \
|
||||
_Generic((prop), \
|
||||
struct IDProperty *: (*(float *)&(prop)->data.val), \
|
||||
const struct IDProperty *: (*(const float *)&(prop)->data.val))
|
||||
_Generic((prop), struct IDProperty * : (*(float *)&(prop)->data.val), const struct IDProperty * : (*(const float *)&(prop)->data.val))
|
||||
# define IDP_Double(prop) \
|
||||
_Generic((prop), \
|
||||
struct IDProperty *: (*(double *)&(prop)->data.val), \
|
||||
const struct IDProperty *: (*(const double *)&(prop)->data.val))
|
||||
_Generic((prop), struct IDProperty * : (*(double *)&(prop)->data.val), const struct IDProperty * : (*(const double *)&(prop)->data.val))
|
||||
# define IDP_String(prop) \
|
||||
_Generic((prop), \
|
||||
struct IDProperty *: ((char *) (prop)->data.pointer), \
|
||||
const struct IDProperty *: ((const char *) (prop)->data.pointer))
|
||||
_Generic((prop), struct IDProperty * : ((char *)(prop)->data.pointer), const struct IDProperty * : ((const char *)(prop)->data.pointer))
|
||||
# define IDP_IDPArray(prop) \
|
||||
_Generic((prop), \
|
||||
struct IDProperty *: ((struct IDProperty *) (prop)->data.pointer), \
|
||||
const struct IDProperty *: ((const struct IDProperty *) (prop)->data.pointer))
|
||||
_Generic((prop), struct IDProperty * : ((struct IDProperty *)(prop)->data.pointer), const struct IDProperty * : ((const struct IDProperty *)(prop)->data.pointer))
|
||||
# define IDP_Id(prop) \
|
||||
_Generic((prop), \
|
||||
struct IDProperty *: ((ID *) (prop)->data.pointer), \
|
||||
const struct IDProperty *: ((const ID *) (prop)->data.pointer))
|
||||
_Generic((prop), struct IDProperty * : ((ID *)(prop)->data.pointer), const struct IDProperty * : ((const ID *)(prop)->data.pointer))
|
||||
#else
|
||||
# define IDP_Float(prop) (*(float *)&(prop)->data.val)
|
||||
# define IDP_Double(prop) (*(double *)&(prop)->data.val)
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
* used by painting and tools.
|
||||
*/
|
||||
|
||||
#include "DNA_scene_enums.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@ -92,7 +94,6 @@ void BKE_object_defgroup_index_map_apply(struct MDeformVert *dvert,
|
|||
|
||||
/* Select helpers. */
|
||||
|
||||
enum eVGroupSelect;
|
||||
/**
|
||||
* Return the subset type of the Vertex Group Selection.
|
||||
*/
|
||||
|
|
|
@ -720,7 +720,7 @@ typedef struct PBVHFaceIter {
|
|||
const struct BMesh *bm;
|
||||
CCGKey subdiv_key_;
|
||||
|
||||
int last_face_index_;
|
||||
int last_poly_index_;
|
||||
} PBVHFaceIter;
|
||||
|
||||
void BKE_pbvh_face_iter_init(PBVH *pbvh, PBVHNode *node, PBVHFaceIter *fd);
|
||||
|
|
|
@ -18,23 +18,16 @@ class SimulationStateItem {
|
|||
};
|
||||
|
||||
class GeometrySimulationStateItem : public SimulationStateItem {
|
||||
private:
|
||||
GeometrySet geometry_;
|
||||
|
||||
public:
|
||||
GeometrySimulationStateItem(GeometrySet geometry);
|
||||
|
||||
const GeometrySet &geometry() const
|
||||
{
|
||||
return geometry_;
|
||||
}
|
||||
|
||||
GeometrySet &geometry()
|
||||
{
|
||||
return geometry_;
|
||||
}
|
||||
GeometrySet geometry;
|
||||
};
|
||||
|
||||
/**
|
||||
* References a field input/output that becomes an attribute as part of the simulation state.
|
||||
* The attribute is actually stored in a #GeometrySimulationStateItem, so this just references
|
||||
* the attribute's name.
|
||||
*/
|
||||
class AttributeSimulationStateItem : public SimulationStateItem {
|
||||
private:
|
||||
std::string name_;
|
||||
|
@ -48,6 +41,7 @@ class AttributeSimulationStateItem : public SimulationStateItem {
|
|||
}
|
||||
};
|
||||
|
||||
/** Storage for a single value of a trivial type like `float`, `int`, etc. */
|
||||
class PrimitiveSimulationStateItem : public SimulationStateItem {
|
||||
private:
|
||||
const CPPType &type_;
|
||||
|
@ -81,12 +75,19 @@ class StringSimulationStateItem : public SimulationStateItem {
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Storage of values for a single simulation input and output node pair.
|
||||
* Used as a cache to allow random access in time, and as an intermediate form before data is
|
||||
* baked.
|
||||
*/
|
||||
class SimulationZoneState {
|
||||
public:
|
||||
Map<int, std::unique_ptr<SimulationStateItem>> item_by_identifier;
|
||||
};
|
||||
|
||||
/** Identifies a simulation zone (input and output node pair) used by a modifier. */
|
||||
struct SimulationZoneID {
|
||||
/** Every node identifier in the hierarchy of compute contexts. */
|
||||
Vector<int> node_ids;
|
||||
|
||||
uint64_t hash() const
|
||||
|
@ -100,6 +101,10 @@ struct SimulationZoneID {
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Stores a single frame of simulation states for all simulation zones in a modifier's node
|
||||
* hierarchy.
|
||||
*/
|
||||
class ModifierSimulationState {
|
||||
private:
|
||||
mutable bool bake_loaded_;
|
||||
|
@ -108,7 +113,9 @@ class ModifierSimulationState {
|
|||
ModifierSimulationCache *owner_;
|
||||
mutable std::mutex mutex_;
|
||||
Map<SimulationZoneID, std::unique_ptr<SimulationZoneState>> zone_states_;
|
||||
/** File path to folder containing baked meta-data. */
|
||||
std::optional<std::string> meta_path_;
|
||||
/** File path to folder containing baked data. */
|
||||
std::optional<std::string> bdata_dir_;
|
||||
|
||||
const SimulationZoneState *get_zone_state(const SimulationZoneID &zone_id) const;
|
||||
|
@ -122,8 +129,14 @@ struct ModifierSimulationStateAtFrame {
|
|||
};
|
||||
|
||||
enum class CacheState {
|
||||
/** The cache is up-to-date with the inputs. */
|
||||
Valid,
|
||||
/**
|
||||
* Nodes or input values have changed since the cache was created, i.e. the output would be
|
||||
* different if the simulation was run again.
|
||||
*/
|
||||
Invalid,
|
||||
/** The cache has been baked and will not be invalidated by changing inputs. */
|
||||
Baked,
|
||||
};
|
||||
|
||||
|
@ -135,7 +148,12 @@ struct StatesAroundFrame {
|
|||
|
||||
class ModifierSimulationCache {
|
||||
private:
|
||||
mutable std::mutex states_at_frames_mutex_;
|
||||
Vector<std::unique_ptr<ModifierSimulationStateAtFrame>> states_at_frames_;
|
||||
/**
|
||||
* Used for baking to deduplicate arrays when writing and writing from storage. Sharing info
|
||||
* must be kept alive for multiple frames to detect if each data array's version has changed.
|
||||
*/
|
||||
std::unique_ptr<BDataSharing> bdata_sharing_;
|
||||
|
||||
friend ModifierSimulationState;
|
||||
|
|
|
@ -776,11 +776,11 @@ struct MovieTrackingObject *BKE_tracking_find_object_for_plane_track(
|
|||
void BKE_tracking_get_rna_path_for_track(const struct MovieTracking *tracking,
|
||||
const struct MovieTrackingTrack *track,
|
||||
char *rna_path,
|
||||
size_t rna_path_len);
|
||||
size_t rna_path_maxncpy);
|
||||
void BKE_tracking_get_rna_path_prefix_for_track(const struct MovieTracking *tracking,
|
||||
const struct MovieTrackingTrack *track,
|
||||
char *rna_path,
|
||||
size_t rna_path_len);
|
||||
size_t rna_path_maxncpy);
|
||||
void BKE_tracking_get_rna_path_for_plane_track(const struct MovieTracking *tracking,
|
||||
const struct MovieTrackingPlaneTrack *plane_track,
|
||||
char *rna_path,
|
||||
|
@ -789,7 +789,7 @@ void BKE_tracking_get_rna_path_prefix_for_plane_track(
|
|||
const struct MovieTracking *tracking,
|
||||
const struct MovieTrackingPlaneTrack *plane_track,
|
||||
char *rna_path,
|
||||
size_t rna_path_len);
|
||||
size_t rna_path_maxncpy);
|
||||
|
||||
/* --------------------------------------------------------------------
|
||||
* Utility macros.
|
||||
|
|
|
@ -500,7 +500,7 @@ static void mesh_calc_finalize(const Mesh *mesh_input, Mesh *mesh_eval)
|
|||
{
|
||||
/* Make sure the name is the same. This is because mesh allocation from template does not
|
||||
* take care of naming. */
|
||||
BLI_strncpy(mesh_eval->id.name, mesh_input->id.name, sizeof(mesh_eval->id.name));
|
||||
STRNCPY(mesh_eval->id.name, mesh_input->id.name);
|
||||
/* Make evaluated mesh to share same edit mesh pointer as original and copied meshes. */
|
||||
mesh_eval->edit_mesh = mesh_input->edit_mesh;
|
||||
}
|
||||
|
|
|
@ -422,7 +422,7 @@ bActionGroup *action_groups_add_new(bAction *act, const char name[])
|
|||
|
||||
/* make it selected, with default name */
|
||||
agrp->flag = AGRP_SELECTED;
|
||||
BLI_strncpy(agrp->name, name[0] ? name : DATA_("Group"), sizeof(agrp->name));
|
||||
STRNCPY(agrp->name, name[0] ? name : DATA_("Group"));
|
||||
|
||||
/* add to action, and validate */
|
||||
BLI_addtail(&act->groups, agrp);
|
||||
|
@ -645,7 +645,7 @@ bPoseChannel *BKE_pose_channel_ensure(bPose *pose, const char *name)
|
|||
|
||||
BKE_pose_channel_session_uuid_generate(chan);
|
||||
|
||||
BLI_strncpy(chan->name, name, sizeof(chan->name));
|
||||
STRNCPY(chan->name, name);
|
||||
|
||||
copy_v3_fl(chan->custom_scale_xyz, 1.0f);
|
||||
zero_v3(chan->custom_translation);
|
||||
|
@ -1273,7 +1273,7 @@ bActionGroup *BKE_pose_add_group(bPose *pose, const char *name)
|
|||
}
|
||||
|
||||
grp = MEM_callocN(sizeof(bActionGroup), "PoseGroup");
|
||||
BLI_strncpy(grp->name, name, sizeof(grp->name));
|
||||
STRNCPY(grp->name, name);
|
||||
BLI_addtail(&pose->agroups, grp);
|
||||
BLI_uniquename(&pose->agroups, grp, name, '.', offsetof(bActionGroup, name), sizeof(grp->name));
|
||||
|
||||
|
@ -1772,10 +1772,10 @@ void what_does_obaction(Object *ob,
|
|||
}
|
||||
}
|
||||
|
||||
BLI_strncpy(workob->parsubstr, ob->parsubstr, sizeof(workob->parsubstr));
|
||||
STRNCPY(workob->parsubstr, ob->parsubstr);
|
||||
|
||||
/* we don't use real object name, otherwise RNA screws with the real thing */
|
||||
BLI_strncpy(workob->id.name, "OB<ConstrWorkOb>", sizeof(workob->id.name));
|
||||
STRNCPY(workob->id.name, "OB<ConstrWorkOb>");
|
||||
|
||||
/* If we're given a group to use, it's likely to be more efficient
|
||||
* (though a bit more dangerous). */
|
||||
|
|
|
@ -46,7 +46,7 @@ bAddon *BKE_addon_ensure(ListBase *addon_list, const char *module)
|
|||
bAddon *addon = BKE_addon_find(addon_list, module);
|
||||
if (addon == NULL) {
|
||||
addon = BKE_addon_new();
|
||||
BLI_strncpy(addon->module, module, sizeof(addon->module));
|
||||
STRNCPY(addon->module, module);
|
||||
BLI_addtail(addon_list, addon);
|
||||
}
|
||||
return addon;
|
||||
|
|
|
@ -767,7 +767,7 @@ static bool fcurves_path_rename_fix(ID *owner_id,
|
|||
bActionGroup *agrp = fcu->grp;
|
||||
is_changed = true;
|
||||
if (oldName != NULL && (agrp != NULL) && STREQ(oldName, agrp->name)) {
|
||||
BLI_strncpy(agrp->name, newName, sizeof(agrp->name));
|
||||
STRNCPY(agrp->name, newName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -819,7 +819,7 @@ static bool drivers_path_rename_fix(ID *owner_id,
|
|||
(dtar->pchan_name[0]) && STREQ(oldName, dtar->pchan_name))
|
||||
{
|
||||
is_changed = true;
|
||||
BLI_strncpy(dtar->pchan_name, newName, sizeof(dtar->pchan_name));
|
||||
STRNCPY(dtar->pchan_name, newName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -131,12 +131,8 @@ KeyingSet *BKE_keyingset_add(
|
|||
/* allocate new KeyingSet */
|
||||
ks = MEM_callocN(sizeof(KeyingSet), "KeyingSet");
|
||||
|
||||
BLI_strncpy(ks->idname,
|
||||
(idname) ? idname :
|
||||
(name) ? name :
|
||||
DATA_("KeyingSet"),
|
||||
sizeof(ks->idname));
|
||||
BLI_strncpy(ks->name, (name) ? name : (idname) ? idname : DATA_("Keying Set"), sizeof(ks->name));
|
||||
STRNCPY(ks->idname, (idname) ? idname : (name) ? name : DATA_("KeyingSet"));
|
||||
STRNCPY(ks->name, (name) ? name : (idname) ? idname : DATA_("Keying Set"));
|
||||
|
||||
ks->flag = flag;
|
||||
ks->keyingflag = keyingflag;
|
||||
|
@ -193,7 +189,7 @@ KS_Path *BKE_keyingset_add_path(KeyingSet *ks,
|
|||
/* just store absolute info */
|
||||
ksp->id = id;
|
||||
if (group_name) {
|
||||
BLI_strncpy(ksp->group, group_name, sizeof(ksp->group));
|
||||
STRNCPY(ksp->group, group_name);
|
||||
}
|
||||
else {
|
||||
ksp->group[0] = '\0';
|
||||
|
@ -608,39 +604,76 @@ static void animsys_evaluate_fcurves(PointerRNA *ptr,
|
|||
}
|
||||
}
|
||||
|
||||
/* This function assumes that the quaternion is fully keyed, and is stored in array index order. */
|
||||
static void animsys_quaternion_evaluate_fcurves(PathResolvedRNA quat_rna,
|
||||
FCurve *first_fcurve,
|
||||
const AnimationEvalContext *anim_eval_context,
|
||||
float r_quaternion[4])
|
||||
/**
|
||||
* This function assumes that the quaternion keys are sequential. They do not
|
||||
* have to be in array_index order. If the quaternion is only partially keyed,
|
||||
* the result is normalized. If it is fully keyed, the result is returned as-is.
|
||||
*
|
||||
* \return the number of FCurves used to construct this quaternion. This is so
|
||||
* that the caller knows how many FCurves can be skipped while iterating over
|
||||
* them. */
|
||||
static int animsys_quaternion_evaluate_fcurves(PathResolvedRNA quat_rna,
|
||||
FCurve *first_fcurve,
|
||||
const AnimationEvalContext *anim_eval_context,
|
||||
float r_quaternion[4])
|
||||
{
|
||||
FCurve *quat_curve_fcu = first_fcurve;
|
||||
for (int prop_index = 0; prop_index < 4; ++prop_index, quat_curve_fcu = quat_curve_fcu->next) {
|
||||
/* Big fat assumption that the quaternion is fully keyed, and stored in order. */
|
||||
BLI_assert(STREQ(quat_curve_fcu->rna_path, first_fcurve->rna_path) &&
|
||||
quat_curve_fcu->array_index == prop_index);
|
||||
|
||||
quat_rna.prop_index = prop_index;
|
||||
r_quaternion[prop_index] = calculate_fcurve(&quat_rna, quat_curve_fcu, anim_eval_context);
|
||||
/* Initialize r_quaternion to the unit quaternion so that half-keyed quaternions at least have
|
||||
* *some* value in there. */
|
||||
r_quaternion[0] = 1.0f;
|
||||
r_quaternion[1] = 0.0f;
|
||||
r_quaternion[2] = 0.0f;
|
||||
r_quaternion[3] = 0.0f;
|
||||
|
||||
int fcurve_offset = 0;
|
||||
for (; fcurve_offset < 4 && quat_curve_fcu;
|
||||
++fcurve_offset, quat_curve_fcu = quat_curve_fcu->next) {
|
||||
if (!STREQ(quat_curve_fcu->rna_path, first_fcurve->rna_path)) {
|
||||
/* This should never happen when the quaternion is fully keyed. Some
|
||||
* people do use half-keyed quaternions, though, so better to check. */
|
||||
break;
|
||||
}
|
||||
|
||||
const int array_index = quat_curve_fcu->array_index;
|
||||
quat_rna.prop_index = array_index;
|
||||
r_quaternion[array_index] = calculate_fcurve(&quat_rna, quat_curve_fcu, anim_eval_context);
|
||||
}
|
||||
|
||||
if (fcurve_offset < 4) {
|
||||
/* This quaternion was incompletely keyed, so the result is a mixture of the unit quaterion and
|
||||
* values from FCurves. This means that it's almost certainly no longer of unit length. */
|
||||
normalize_qt(r_quaternion);
|
||||
}
|
||||
|
||||
return fcurve_offset;
|
||||
}
|
||||
|
||||
/* This function assumes that the quaternion is fully keyed, and is stored in array index order. */
|
||||
static void animsys_blend_fcurves_quaternion(PathResolvedRNA *anim_rna,
|
||||
FCurve *first_fcurve,
|
||||
const AnimationEvalContext *anim_eval_context,
|
||||
const float blend_factor)
|
||||
/**
|
||||
* This function assumes that the quaternion keys are sequential. They do not
|
||||
* have to be in array_index order.
|
||||
*
|
||||
* \return the number of FCurves used to construct the quaternion, counting from
|
||||
* `first_fcurve`. This is so that the caller knows how many FCurves can be
|
||||
* skipped while iterating over them. */
|
||||
static int animsys_blend_fcurves_quaternion(PathResolvedRNA *anim_rna,
|
||||
FCurve *first_fcurve,
|
||||
const AnimationEvalContext *anim_eval_context,
|
||||
const float blend_factor)
|
||||
{
|
||||
float current_quat[4];
|
||||
RNA_property_float_get_array(&anim_rna->ptr, anim_rna->prop, current_quat);
|
||||
|
||||
float target_quat[4];
|
||||
animsys_quaternion_evaluate_fcurves(*anim_rna, first_fcurve, anim_eval_context, target_quat);
|
||||
const int num_fcurves_read = animsys_quaternion_evaluate_fcurves(
|
||||
*anim_rna, first_fcurve, anim_eval_context, target_quat);
|
||||
|
||||
float blended_quat[4];
|
||||
interp_qt_qtqt(blended_quat, current_quat, target_quat, blend_factor);
|
||||
|
||||
RNA_property_float_set_array(&anim_rna->ptr, anim_rna->prop, blended_quat);
|
||||
|
||||
return num_fcurves_read;
|
||||
}
|
||||
|
||||
/* LERP between current value (blend_factor=0.0) and the value from the FCurve (blend_factor=1.0)
|
||||
|
@ -675,12 +708,13 @@ static void animsys_blend_in_fcurves(PointerRNA *ptr,
|
|||
}
|
||||
|
||||
if (STREQ(RNA_property_identifier(anim_rna.prop), "rotation_quaternion")) {
|
||||
animsys_blend_fcurves_quaternion(&anim_rna, fcu, anim_eval_context, blend_factor);
|
||||
const int num_fcurves_read = animsys_blend_fcurves_quaternion(
|
||||
&anim_rna, fcu, anim_eval_context, blend_factor);
|
||||
|
||||
/* Skip the next three channels, because those have already been handled here. */
|
||||
MEM_SAFE_FREE(channel_to_skip);
|
||||
channel_to_skip = BLI_strdup(fcu->rna_path);
|
||||
num_channels_to_skip = 3;
|
||||
num_channels_to_skip = num_fcurves_read - 1;
|
||||
continue;
|
||||
}
|
||||
/* TODO(Sybren): do something similar as above for Euler and Axis/Angle representations. */
|
||||
|
|
|
@ -115,7 +115,7 @@ static char *blender_version_decimal(const int version)
|
|||
{
|
||||
static char version_str[5];
|
||||
BLI_assert(version < 1000);
|
||||
BLI_snprintf(version_str, sizeof(version_str), "%d.%d", version / 100, version % 100);
|
||||
SNPRINTF(version_str, "%d.%d", version / 100, version % 100);
|
||||
return version_str;
|
||||
}
|
||||
|
||||
|
@ -480,7 +480,7 @@ static bool get_path_user_ex(char *targetpath,
|
|||
|
||||
const char *user_base_path = GHOST_getUserDir(version, blender_version_decimal(version));
|
||||
if (user_base_path) {
|
||||
BLI_strncpy(user_path, user_base_path, FILE_MAX);
|
||||
STRNCPY(user_path, user_base_path);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -546,7 +546,7 @@ static bool get_path_system_ex(char *targetpath,
|
|||
system_path[0] = '\0';
|
||||
const char *system_base_path = GHOST_getSystemDir(version, blender_version_decimal(version));
|
||||
if (system_base_path) {
|
||||
BLI_strncpy(system_path, system_base_path, FILE_MAX);
|
||||
STRNCPY(system_path, system_base_path);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -708,7 +708,7 @@ bool bone_autoside_name(
|
|||
if (len == 0) {
|
||||
return false;
|
||||
}
|
||||
BLI_strncpy(basename, name, sizeof(basename));
|
||||
STRNCPY(basename, name);
|
||||
|
||||
/* Figure out extension to append:
|
||||
* - The extension to append is based upon the axis that we are working on.
|
||||
|
|
|
@ -52,7 +52,7 @@ AssetMetaData::~AssetMetaData()
|
|||
static AssetTag *asset_metadata_tag_add(AssetMetaData *asset_data, const char *const name)
|
||||
{
|
||||
AssetTag *tag = (AssetTag *)MEM_callocN(sizeof(*tag), __func__);
|
||||
BLI_strncpy(tag->name, name, sizeof(tag->name));
|
||||
STRNCPY(tag->name, name);
|
||||
|
||||
BLI_addtail(&asset_data->tags, tag);
|
||||
asset_data->tot_tags++;
|
||||
|
|
|
@ -217,7 +217,7 @@ bool BKE_id_attribute_rename(ID *id,
|
|||
BKE_id_attributes_default_color_set(id, result_name);
|
||||
}
|
||||
|
||||
BLI_strncpy_utf8(layer->name, result_name, sizeof(layer->name));
|
||||
STRNCPY_UTF8(layer->name, result_name);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -111,13 +111,12 @@ static void blender_version_init(void)
|
|||
BLI_assert_msg(0, "Invalid Blender version cycle");
|
||||
}
|
||||
|
||||
BLI_snprintf(blender_version_string,
|
||||
ARRAY_SIZE(blender_version_string),
|
||||
"%d.%01d.%d%s",
|
||||
BLENDER_VERSION / 100,
|
||||
BLENDER_VERSION % 100,
|
||||
BLENDER_VERSION_PATCH,
|
||||
version_cycle);
|
||||
SNPRINTF(blender_version_string,
|
||||
"%d.%01d.%d%s",
|
||||
BLENDER_VERSION / 100,
|
||||
BLENDER_VERSION % 100,
|
||||
BLENDER_VERSION_PATCH,
|
||||
version_cycle);
|
||||
}
|
||||
|
||||
const char *BKE_blender_version_string(void)
|
||||
|
|
|
@ -57,7 +57,7 @@ bool BKE_memfile_undo_decode(MemFileUndoData *mfu,
|
|||
char mainstr[sizeof(bmain->filepath)];
|
||||
int success = 0, fileflags;
|
||||
|
||||
BLI_strncpy(mainstr, BKE_main_blendfile_path(bmain), sizeof(mainstr)); /* temporal store */
|
||||
STRNCPY(mainstr, BKE_main_blendfile_path(bmain)); /* temporal store */
|
||||
|
||||
fileflags = G.fileflags;
|
||||
G.fileflags |= G_FILE_NO_UI;
|
||||
|
@ -116,14 +116,14 @@ MemFileUndoData *BKE_memfile_undo_encode(Main *bmain, MemFileUndoData *mfu_prev)
|
|||
counter++;
|
||||
counter = counter % U.undosteps;
|
||||
|
||||
BLI_snprintf(numstr, sizeof(numstr), "%d.blend", counter);
|
||||
SNPRINTF(numstr, "%d.blend", counter);
|
||||
BLI_path_join(filepath, sizeof(filepath), BKE_tempdir_session(), numstr);
|
||||
|
||||
const BlendFileWriteParams blend_file_write_params{};
|
||||
/* success = */ /* UNUSED */ BLO_write_file(
|
||||
bmain, filepath, fileflags, &blend_file_write_params, nullptr);
|
||||
|
||||
BLI_strncpy(mfu->filepath, filepath, sizeof(mfu->filepath));
|
||||
STRNCPY(mfu->filepath, filepath);
|
||||
}
|
||||
else {
|
||||
MemFile *prevfile = (mfu_prev) ? &(mfu_prev->memfile) : nullptr;
|
||||
|
|
|
@ -1116,9 +1116,9 @@ void BKE_blendfile_append(BlendfileLinkAppendContext *lapp_context, ReportList *
|
|||
|
||||
ID *local_appended_new_id = NULL;
|
||||
char lib_filepath[FILE_MAX];
|
||||
BLI_strncpy(lib_filepath, id->lib->filepath, sizeof(lib_filepath));
|
||||
STRNCPY(lib_filepath, id->lib->filepath);
|
||||
char lib_id_name[MAX_ID_NAME];
|
||||
BLI_strncpy(lib_id_name, id->name, sizeof(lib_id_name));
|
||||
STRNCPY(lib_id_name, id->name);
|
||||
|
||||
switch (item->action) {
|
||||
case LINK_APPEND_ACT_COPY_LOCAL:
|
||||
|
|
|
@ -1617,7 +1617,7 @@ BoidRule *boid_new_rule(int type)
|
|||
|
||||
rule->type = type;
|
||||
rule->flag |= BOIDRULE_IN_AIR | BOIDRULE_ON_LAND;
|
||||
BLI_strncpy(rule->name, DATA_(rna_enum_boidrule_type_items[type - 1].name), sizeof(rule->name));
|
||||
STRNCPY(rule->name, DATA_(rna_enum_boidrule_type_items[type - 1].name));
|
||||
|
||||
return rule;
|
||||
}
|
||||
|
@ -1653,7 +1653,7 @@ BoidState *boid_new_state(BoidSettings *boids)
|
|||
|
||||
state->id = boids->last_state_id++;
|
||||
if (state->id) {
|
||||
BLI_snprintf(state->name, sizeof(state->name), "State %i", state->id);
|
||||
SNPRINTF(state->name, "State %i", state->id);
|
||||
}
|
||||
else {
|
||||
strcpy(state->name, "State");
|
||||
|
|
|
@ -135,7 +135,7 @@ bool BKE_bpath_foreach_path_fixed_process(BPathForeachPathData *bpath_data, char
|
|||
char path_dst[FILE_MAX];
|
||||
|
||||
if (absolute_base_path) {
|
||||
BLI_strncpy(path_src_buf, path, sizeof(path_src_buf));
|
||||
STRNCPY(path_src_buf, path);
|
||||
BLI_path_abs(path_src_buf, absolute_base_path);
|
||||
path_src = path_src_buf;
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ bool BKE_bpath_foreach_path_fixed_process(BPathForeachPathData *bpath_data, char
|
|||
}
|
||||
|
||||
/* so functions can check old value */
|
||||
BLI_strncpy(path_dst, path, FILE_MAX);
|
||||
STRNCPY(path_dst, path);
|
||||
|
||||
if (bpath_data->callback_function(bpath_data, path_dst, path_src)) {
|
||||
BLI_strncpy(path, path_dst, FILE_MAX);
|
||||
|
@ -167,7 +167,7 @@ bool BKE_bpath_foreach_path_dirfile_fixed_process(BPathForeachPathData *bpath_da
|
|||
BLI_path_join(path_src, sizeof(path_src), path_dir, path_file);
|
||||
|
||||
/* So that functions can access the old value. */
|
||||
BLI_strncpy(path_dst, path_src, FILE_MAX);
|
||||
STRNCPY(path_dst, path_src);
|
||||
|
||||
if (absolute_base_path) {
|
||||
BLI_path_abs(path_src, absolute_base_path);
|
||||
|
@ -191,7 +191,7 @@ bool BKE_bpath_foreach_path_allocated_process(BPathForeachPathData *bpath_data,
|
|||
char path_dst[FILE_MAX];
|
||||
|
||||
if (absolute_base_path) {
|
||||
BLI_strncpy(path_src_buf, *path, sizeof(path_src_buf));
|
||||
STRNCPY(path_src_buf, *path);
|
||||
BLI_path_abs(path_src_buf, absolute_base_path);
|
||||
path_src = path_src_buf;
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ TEST_F(BPathTest, rebase_on_relative)
|
|||
text->filepath = BLI_strdup(TEXT_PATH_RELATIVE);
|
||||
|
||||
MovieClip *movie_clip = reinterpret_cast<MovieClip *>(bmain->movieclips.first);
|
||||
BLI_strncpy(movie_clip->filepath, MOVIECLIP_PATH_RELATIVE, sizeof(movie_clip->filepath));
|
||||
STRNCPY(movie_clip->filepath, MOVIECLIP_PATH_RELATIVE);
|
||||
|
||||
BKE_bpath_relative_rebase(bmain, BASE_DIR, REBASE_DIR, nullptr);
|
||||
|
||||
|
@ -97,7 +97,7 @@ TEST_F(BPathTest, rebase_on_absolute)
|
|||
text->filepath = BLI_strdup(TEXT_PATH_ABSOLUTE);
|
||||
|
||||
MovieClip *movie_clip = reinterpret_cast<MovieClip *>(bmain->movieclips.first);
|
||||
BLI_strncpy(movie_clip->filepath, MOVIECLIP_PATH_ABSOLUTE, sizeof(movie_clip->filepath));
|
||||
STRNCPY(movie_clip->filepath, MOVIECLIP_PATH_ABSOLUTE);
|
||||
|
||||
BKE_bpath_relative_rebase(bmain, BASE_DIR, REBASE_DIR, nullptr);
|
||||
|
||||
|
@ -111,7 +111,7 @@ TEST_F(BPathTest, convert_to_relative)
|
|||
text->filepath = BLI_strdup(TEXT_PATH_RELATIVE);
|
||||
|
||||
MovieClip *movie_clip = reinterpret_cast<MovieClip *>(bmain->movieclips.first);
|
||||
BLI_strncpy(movie_clip->filepath, MOVIECLIP_PATH_ABSOLUTE, sizeof(movie_clip->filepath));
|
||||
STRNCPY(movie_clip->filepath, MOVIECLIP_PATH_ABSOLUTE);
|
||||
|
||||
BKE_bpath_relative_convert(bmain, BASE_DIR, nullptr);
|
||||
|
||||
|
@ -127,7 +127,7 @@ TEST_F(BPathTest, convert_to_absolute)
|
|||
text->filepath = BLI_strdup(TEXT_PATH_RELATIVE);
|
||||
|
||||
MovieClip *movie_clip = reinterpret_cast<MovieClip *>(bmain->movieclips.first);
|
||||
BLI_strncpy(movie_clip->filepath, MOVIECLIP_PATH_ABSOLUTE, sizeof(movie_clip->filepath));
|
||||
STRNCPY(movie_clip->filepath, MOVIECLIP_PATH_ABSOLUTE);
|
||||
|
||||
BKE_bpath_absolute_convert(bmain, BASE_DIR, nullptr);
|
||||
|
||||
|
@ -143,7 +143,7 @@ TEST_F(BPathTest, list_backup_restore)
|
|||
text->filepath = BLI_strdup(TEXT_PATH_RELATIVE);
|
||||
|
||||
MovieClip *movie_clip = reinterpret_cast<MovieClip *>(bmain->movieclips.first);
|
||||
BLI_strncpy(movie_clip->filepath, MOVIECLIP_PATH_ABSOLUTE, sizeof(movie_clip->filepath));
|
||||
STRNCPY(movie_clip->filepath, MOVIECLIP_PATH_ABSOLUTE);
|
||||
|
||||
void *path_list_handle = BKE_bpath_list_backup(bmain, static_cast<eBPathForeachFlag>(0));
|
||||
|
||||
|
@ -152,7 +152,7 @@ TEST_F(BPathTest, list_backup_restore)
|
|||
|
||||
MEM_freeN(text->filepath);
|
||||
text->filepath = BLI_strdup(TEXT_PATH_ABSOLUTE);
|
||||
BLI_strncpy(movie_clip->filepath, MOVIECLIP_PATH_RELATIVE, sizeof(movie_clip->filepath));
|
||||
STRNCPY(movie_clip->filepath, MOVIECLIP_PATH_RELATIVE);
|
||||
|
||||
BKE_bpath_list_restore(bmain, static_cast<eBPathForeachFlag>(0), path_list_handle);
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ static void cache_file_init_data(ID *id)
|
|||
|
||||
cache_file->scale = 1.0f;
|
||||
cache_file->velocity_unit = CACHEFILE_VELOCITY_UNIT_SECOND;
|
||||
BLI_strncpy(cache_file->velocity_name, ".velocities", sizeof(cache_file->velocity_name));
|
||||
STRNCPY(cache_file->velocity_name, ".velocities");
|
||||
}
|
||||
|
||||
static void cache_file_copy_data(Main *UNUSED(bmain),
|
||||
|
@ -362,7 +362,7 @@ void BKE_cachefile_eval(Main *bmain, Depsgraph *depsgraph, CacheFile *cache_file
|
|||
cache_file->type = CACHEFILE_TYPE_ALEMBIC;
|
||||
cache_file->handle = ABC_create_handle(
|
||||
bmain, filepath, cache_file->layers.first, &cache_file->object_paths);
|
||||
BLI_strncpy(cache_file->handle_filepath, filepath, FILE_MAX);
|
||||
STRNCPY(cache_file->handle_filepath, filepath);
|
||||
}
|
||||
#endif
|
||||
#ifdef WITH_USD
|
||||
|
@ -441,7 +441,7 @@ CacheFileLayer *BKE_cachefile_add_layer(CacheFile *cache_file, const char filepa
|
|||
const int num_layers = BLI_listbase_count(&cache_file->layers);
|
||||
|
||||
CacheFileLayer *layer = MEM_callocN(sizeof(CacheFileLayer), "CacheFileLayer");
|
||||
BLI_strncpy(layer->filepath, filepath, sizeof(layer->filepath));
|
||||
STRNCPY(layer->filepath, filepath);
|
||||
|
||||
BLI_addtail(&cache_file->layers, layer);
|
||||
|
||||
|
|
|
@ -1034,7 +1034,7 @@ static Object *camera_multiview_advanced(const Scene *scene, Object *camera, con
|
|||
}
|
||||
|
||||
if (STREQ(camera_name + (len_name - len_suffix), srv->suffix)) {
|
||||
BLI_snprintf(name, sizeof(name), "%.*s%s", (len_name - len_suffix), camera_name, suffix);
|
||||
SNPRINTF(name, "%.*s%s", (len_name - len_suffix), camera_name, suffix);
|
||||
len_suffix_max = len_suffix;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1790,15 +1790,13 @@ void BKE_color_managed_display_settings_init(ColorManagedDisplaySettings *settin
|
|||
{
|
||||
const char *display_name = IMB_colormanagement_display_get_default_name();
|
||||
|
||||
BLI_strncpy(settings->display_device, display_name, sizeof(settings->display_device));
|
||||
STRNCPY(settings->display_device, display_name);
|
||||
}
|
||||
|
||||
void BKE_color_managed_display_settings_copy(ColorManagedDisplaySettings *new_settings,
|
||||
const ColorManagedDisplaySettings *settings)
|
||||
{
|
||||
BLI_strncpy(new_settings->display_device,
|
||||
settings->display_device,
|
||||
sizeof(new_settings->display_device));
|
||||
STRNCPY(new_settings->display_device, settings->display_device);
|
||||
}
|
||||
|
||||
void BKE_color_managed_view_settings_init_render(
|
||||
|
@ -1836,10 +1834,8 @@ void BKE_color_managed_view_settings_init_default(
|
|||
void BKE_color_managed_view_settings_copy(ColorManagedViewSettings *new_settings,
|
||||
const ColorManagedViewSettings *settings)
|
||||
{
|
||||
BLI_strncpy(new_settings->look, settings->look, sizeof(new_settings->look));
|
||||
BLI_strncpy(new_settings->view_transform,
|
||||
settings->view_transform,
|
||||
sizeof(new_settings->view_transform));
|
||||
STRNCPY(new_settings->look, settings->look);
|
||||
STRNCPY(new_settings->view_transform, settings->view_transform);
|
||||
|
||||
new_settings->flag = settings->flag;
|
||||
new_settings->exposure = settings->exposure;
|
||||
|
@ -1882,14 +1878,14 @@ void BKE_color_managed_view_settings_blend_read_data(BlendDataReader *reader,
|
|||
void BKE_color_managed_colorspace_settings_init(
|
||||
ColorManagedColorspaceSettings *colorspace_settings)
|
||||
{
|
||||
BLI_strncpy(colorspace_settings->name, "", sizeof(colorspace_settings->name));
|
||||
STRNCPY(colorspace_settings->name, "");
|
||||
}
|
||||
|
||||
void BKE_color_managed_colorspace_settings_copy(
|
||||
ColorManagedColorspaceSettings *colorspace_settings,
|
||||
const ColorManagedColorspaceSettings *settings)
|
||||
{
|
||||
BLI_strncpy(colorspace_settings->name, settings->name, sizeof(colorspace_settings->name));
|
||||
STRNCPY(colorspace_settings->name, settings->name);
|
||||
}
|
||||
|
||||
bool BKE_color_managed_colorspace_settings_equals(const ColorManagedColorspaceSettings *settings1,
|
||||
|
|
|
@ -859,7 +859,7 @@ static void default_get_tarmat_full_bbone(struct Depsgraph *UNUSED(depsgraph),
|
|||
ct = MEM_callocN(sizeof(bConstraintTarget), "tempConstraintTarget"); \
|
||||
\
|
||||
ct->tar = datatar; \
|
||||
BLI_strncpy(ct->subtarget, datasubtarget, sizeof(ct->subtarget)); \
|
||||
STRNCPY(ct->subtarget, datasubtarget); \
|
||||
ct->space = con->tarspace; \
|
||||
ct->flag = CONSTRAINT_TAR_TEMP; \
|
||||
\
|
||||
|
@ -916,7 +916,7 @@ static void default_get_tarmat_full_bbone(struct Depsgraph *UNUSED(depsgraph),
|
|||
bConstraintTarget *ctn = ct->next; \
|
||||
if (no_copy == 0) { \
|
||||
datatar = ct->tar; \
|
||||
BLI_strncpy(datasubtarget, ct->subtarget, sizeof(datasubtarget)); \
|
||||
STRNCPY(datasubtarget, ct->subtarget); \
|
||||
con->tarspace = (char)ct->space; \
|
||||
} \
|
||||
\
|
||||
|
@ -5403,7 +5403,7 @@ static void transformcache_copy(bConstraint *con, bConstraint *srccon)
|
|||
bTransformCacheConstraint *src = srccon->data;
|
||||
bTransformCacheConstraint *dst = con->data;
|
||||
|
||||
BLI_strncpy(dst->object_path, src->object_path, sizeof(dst->object_path));
|
||||
STRNCPY(dst->object_path, src->object_path);
|
||||
dst->cache_file = src->cache_file;
|
||||
dst->reader = NULL;
|
||||
dst->reader_object_path[0] = '\0';
|
||||
|
@ -5779,7 +5779,7 @@ static bConstraint *add_new_constraint_internal(const char *name, short type)
|
|||
}
|
||||
|
||||
/* copy the name */
|
||||
BLI_strncpy(con->name, newName, sizeof(con->name));
|
||||
STRNCPY(con->name, newName);
|
||||
|
||||
/* return the new constraint */
|
||||
return con;
|
||||
|
@ -6201,7 +6201,7 @@ void BKE_constraint_targets_flush(struct bConstraint *con, struct ListBase *targ
|
|||
|
||||
if (!no_copy) {
|
||||
con->space_object = ct->tar;
|
||||
BLI_strncpy(con->space_subtarget, ct->subtarget, sizeof(con->space_subtarget));
|
||||
STRNCPY(con->space_subtarget, ct->subtarget);
|
||||
}
|
||||
|
||||
BLI_freelinkN(targets, ct);
|
||||
|
|
|
@ -146,7 +146,7 @@ TEST(cryptomatte, session_from_stamp_data)
|
|||
|
||||
/* Create StampData from CryptomatteSession. */
|
||||
ViewLayer view_layer;
|
||||
BLI_strncpy(view_layer.name, "viewlayername", sizeof(view_layer.name));
|
||||
STRNCPY(view_layer.name, "viewlayername");
|
||||
RenderResult *render_result2 = static_cast<RenderResult *>(
|
||||
MEM_callocN(sizeof(RenderResult), __func__));
|
||||
BKE_cryptomatte_store_metadata(session.get(), render_result2, &view_layer);
|
||||
|
|
|
@ -2955,7 +2955,7 @@ static CustomDataLayer *customData_add_layer__internal(
|
|||
}
|
||||
|
||||
if (name) {
|
||||
BLI_strncpy(new_layer.name, name, sizeof(new_layer.name));
|
||||
STRNCPY(new_layer.name, name);
|
||||
CustomData_set_layer_unique_name(data, index);
|
||||
}
|
||||
else {
|
||||
|
@ -3669,7 +3669,7 @@ bool CustomData_set_layer_name(CustomData *data,
|
|||
return false;
|
||||
}
|
||||
|
||||
BLI_strncpy(data->layers[layer_index].name, name, sizeof(data->layers[layer_index].name));
|
||||
STRNCPY(data->layers[layer_index].name, name);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -4781,7 +4781,7 @@ void CustomData_external_add(CustomData *data,
|
|||
external = MEM_cnew<CustomDataExternal>(__func__);
|
||||
data->external = external;
|
||||
}
|
||||
BLI_strncpy(external->filepath, filepath, sizeof(external->filepath));
|
||||
STRNCPY(external->filepath, filepath);
|
||||
|
||||
layer->flag |= CD_FLAG_EXTERNAL | CD_FLAG_IN_MEMORY;
|
||||
}
|
||||
|
|
|
@ -444,7 +444,7 @@ CDataFileLayer *cdf_layer_add(CDataFile *cdf, int type, const char *name, size_t
|
|||
layer->datatype = CDF_DATA_FLOAT;
|
||||
layer->datasize = datasize;
|
||||
layer->type = type;
|
||||
BLI_strncpy(layer->name, name, CDF_LAYER_NAME_MAX);
|
||||
STRNCPY(layer->name, name);
|
||||
|
||||
return layer;
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ bDeformGroup *BKE_object_defgroup_new(Object *ob, const char *name)
|
|||
|
||||
defgroup = MEM_cnew<bDeformGroup>(__func__);
|
||||
|
||||
BLI_strncpy(defgroup->name, name, sizeof(defgroup->name));
|
||||
STRNCPY(defgroup->name, name);
|
||||
|
||||
ListBase *defbase = BKE_object_defgroup_list_mutable(ob);
|
||||
|
||||
|
|
|
@ -761,7 +761,7 @@ static GeometrySet curve_calc_modifiers_post(Depsgraph *depsgraph,
|
|||
|
||||
BKE_mesh_ensure_normals_for_display(final_mesh);
|
||||
|
||||
BLI_strncpy(final_mesh->id.name, cu->id.name, sizeof(final_mesh->id.name));
|
||||
STRNCPY(final_mesh->id.name, cu->id.name);
|
||||
*((short *)final_mesh->id.name) = ID_ME;
|
||||
}
|
||||
|
||||
|
|
|
@ -295,7 +295,7 @@ static Mesh *dynamicPaint_brush_mesh_get(DynamicPaintBrushSettings *brush)
|
|||
static bool setError(DynamicPaintCanvasSettings *canvas, const char *string)
|
||||
{
|
||||
/* Add error to canvas ui info label */
|
||||
BLI_strncpy(canvas->error, string, sizeof(canvas->error));
|
||||
STRNCPY(canvas->error, string);
|
||||
CLOG_STR_ERROR(&LOG, string);
|
||||
return false;
|
||||
}
|
||||
|
@ -369,7 +369,7 @@ static bool surface_duplicateOutputExists(void *arg, const char *name)
|
|||
static void surface_setUniqueOutputName(DynamicPaintSurface *surface, char *basename, int output)
|
||||
{
|
||||
char name[64];
|
||||
BLI_strncpy(name, basename, sizeof(name)); /* in case basename is surface->name use a copy */
|
||||
STRNCPY(name, basename); /* in case basename is surface->name use a copy */
|
||||
if (output == 0) {
|
||||
BLI_uniquename_cb(surface_duplicateOutputExists,
|
||||
surface,
|
||||
|
@ -405,7 +405,7 @@ static bool surface_duplicateNameExists(void *arg, const char *name)
|
|||
void dynamicPaintSurface_setUniqueName(DynamicPaintSurface *surface, const char *basename)
|
||||
{
|
||||
char name[64];
|
||||
BLI_strncpy(name, basename, sizeof(name)); /* in case basename is surface->name use a copy */
|
||||
STRNCPY(name, basename); /* in case basename is surface->name use a copy */
|
||||
BLI_uniquename_cb(
|
||||
surface_duplicateNameExists, surface, name, '.', surface->name, sizeof(surface->name));
|
||||
}
|
||||
|
@ -420,7 +420,7 @@ void dynamicPaintSurface_updateType(DynamicPaintSurface *surface)
|
|||
}
|
||||
else {
|
||||
strcpy(surface->output_name, "dp_");
|
||||
BLI_strncpy(surface->output_name2, surface->output_name, sizeof(surface->output_name2));
|
||||
STRNCPY(surface->output_name2, surface->output_name);
|
||||
surface->flags &= ~MOD_DPAINT_ANTIALIAS;
|
||||
surface->depth_clamp = 0.0f;
|
||||
}
|
||||
|
@ -1233,7 +1233,7 @@ void dynamicPaint_Modifier_copy(const DynamicPaintModifierData *pmd,
|
|||
t_surface->effector_weights = static_cast<EffectorWeights *>(
|
||||
MEM_dupallocN(surface->effector_weights));
|
||||
|
||||
BLI_strncpy(t_surface->name, surface->name, sizeof(t_surface->name));
|
||||
STRNCPY(t_surface->name, surface->name);
|
||||
t_surface->format = surface->format;
|
||||
t_surface->type = surface->type;
|
||||
t_surface->disp_type = surface->disp_type;
|
||||
|
@ -1250,8 +1250,7 @@ void dynamicPaint_Modifier_copy(const DynamicPaintModifierData *pmd,
|
|||
|
||||
copy_v4_v4(t_surface->init_color, surface->init_color);
|
||||
t_surface->init_texture = surface->init_texture;
|
||||
BLI_strncpy(
|
||||
t_surface->init_layername, surface->init_layername, sizeof(t_surface->init_layername));
|
||||
STRNCPY(t_surface->init_layername, surface->init_layername);
|
||||
|
||||
t_surface->dry_speed = surface->dry_speed;
|
||||
t_surface->diss_speed = surface->diss_speed;
|
||||
|
@ -1274,12 +1273,10 @@ void dynamicPaint_Modifier_copy(const DynamicPaintModifierData *pmd,
|
|||
t_surface->wave_spring = surface->wave_spring;
|
||||
t_surface->wave_smoothness = surface->wave_smoothness;
|
||||
|
||||
BLI_strncpy(t_surface->uvlayer_name, surface->uvlayer_name, sizeof(t_surface->uvlayer_name));
|
||||
BLI_strncpy(t_surface->image_output_path,
|
||||
surface->image_output_path,
|
||||
sizeof(t_surface->image_output_path));
|
||||
BLI_strncpy(t_surface->output_name, surface->output_name, sizeof(t_surface->output_name));
|
||||
BLI_strncpy(t_surface->output_name2, surface->output_name2, sizeof(t_surface->output_name2));
|
||||
STRNCPY(t_surface->uvlayer_name, surface->uvlayer_name);
|
||||
STRNCPY(t_surface->image_output_path, surface->image_output_path);
|
||||
STRNCPY(t_surface->output_name, surface->output_name);
|
||||
STRNCPY(t_surface->output_name2, surface->output_name2);
|
||||
}
|
||||
}
|
||||
if (tpmd->brush) {
|
||||
|
@ -3314,7 +3311,7 @@ void dynamicPaint_outputSurfaceImage(DynamicPaintSurface *surface,
|
|||
format = R_IMF_IMTYPE_PNG;
|
||||
}
|
||||
#endif
|
||||
BLI_strncpy(output_file, filepath, sizeof(output_file));
|
||||
STRNCPY(output_file, filepath);
|
||||
BKE_image_path_ext_from_imtype_ensure(output_file, sizeof(output_file), format);
|
||||
|
||||
/* Validate output file path */
|
||||
|
|
|
@ -1351,7 +1351,7 @@ void BKE_sim_debug_data_add_element(int type,
|
|||
zero_v3(elem->v2);
|
||||
}
|
||||
if (str) {
|
||||
BLI_strncpy(elem->str, str, sizeof(elem->str));
|
||||
STRNCPY(elem->str, str);
|
||||
}
|
||||
else {
|
||||
elem->str[0] = '\0';
|
||||
|
|
|
@ -161,7 +161,7 @@ void BKE_fcurves_copy(ListBase *dst, ListBase *src)
|
|||
void BKE_fmodifier_name_set(FModifier *fcm, const char *name)
|
||||
{
|
||||
/* Copy new Modifier name. */
|
||||
BLI_strncpy(fcm->name, name, sizeof(fcm->name));
|
||||
STRNCPY(fcm->name, name);
|
||||
|
||||
/* Set default modifier name when name parameter is an empty string.
|
||||
* Ensure the name is unique. */
|
||||
|
@ -1305,7 +1305,7 @@ void BKE_fcurve_handles_recalc_ex(FCurve *fcu, eBezTriple_Flag handle_sel_flag)
|
|||
if (a == 1) {
|
||||
next = cycle_offset_triple(cycle, &tmp, &fcu->bezt[1], first, last);
|
||||
}
|
||||
else {
|
||||
else if (next != NULL) {
|
||||
next++;
|
||||
}
|
||||
|
||||
|
|
|
@ -4455,12 +4455,12 @@ void BKE_fluid_particle_system_create(Main *bmain,
|
|||
part->phystype = PART_PHYS_NO; /* No physics needed, part system only used to display data. */
|
||||
psys->part = part;
|
||||
psys->pointcache = BKE_ptcache_add(&psys->ptcaches);
|
||||
BLI_strncpy(psys->name, parts_name, sizeof(psys->name));
|
||||
STRNCPY(psys->name, parts_name);
|
||||
BLI_addtail(&ob->particlesystem, psys);
|
||||
|
||||
/* add modifier */
|
||||
pfmd = (ParticleSystemModifierData *)BKE_modifier_new(eModifierType_ParticleSystem);
|
||||
BLI_strncpy(pfmd->modifier.name, psys_name, sizeof(pfmd->modifier.name));
|
||||
STRNCPY(pfmd->modifier.name, psys_name);
|
||||
pfmd->psys = psys;
|
||||
BLI_addtail(&ob->modifiers, pfmd);
|
||||
BKE_modifier_unique_name(&ob->modifiers, (ModifierData *)pfmd);
|
||||
|
@ -4968,7 +4968,7 @@ void BKE_fluid_modifier_copy(const FluidModifierData *fmd, FluidModifierData *tf
|
|||
tfds->cache_data_format = fds->cache_data_format;
|
||||
tfds->cache_particle_format = fds->cache_particle_format;
|
||||
tfds->cache_noise_format = fds->cache_noise_format;
|
||||
BLI_strncpy(tfds->cache_directory, fds->cache_directory, sizeof(tfds->cache_directory));
|
||||
STRNCPY(tfds->cache_directory, fds->cache_directory);
|
||||
|
||||
/* time options */
|
||||
tfds->time_scale = fds->time_scale;
|
||||
|
@ -5056,7 +5056,7 @@ void BKE_fluid_modifier_copy(const FluidModifierData *fmd, FluidModifierData *tf
|
|||
/* texture control */
|
||||
tffs->texture_size = ffs->texture_size;
|
||||
tffs->texture_offset = ffs->texture_offset;
|
||||
BLI_strncpy(tffs->uvlayer_name, ffs->uvlayer_name, sizeof(tffs->uvlayer_name));
|
||||
STRNCPY(tffs->uvlayer_name, ffs->uvlayer_name);
|
||||
tffs->vgroup_density = ffs->vgroup_density;
|
||||
|
||||
tffs->type = ffs->type;
|
||||
|
|
|
@ -180,10 +180,10 @@ FreestyleLineSet *BKE_freestyle_lineset_add(struct Main *bmain,
|
|||
lineset->exclude_edge_types = 0;
|
||||
lineset->group = NULL;
|
||||
if (name) {
|
||||
BLI_strncpy(lineset->name, name, sizeof(lineset->name));
|
||||
STRNCPY(lineset->name, name);
|
||||
}
|
||||
else if (lineset_index > 0) {
|
||||
BLI_snprintf(lineset->name, sizeof(lineset->name), "LineSet %i", lineset_index + 1);
|
||||
SNPRINTF(lineset->name, "LineSet %i", lineset_index + 1);
|
||||
}
|
||||
else {
|
||||
strcpy(lineset->name, "LineSet");
|
||||
|
|
|
@ -675,7 +675,7 @@ bGPDlayer *BKE_gpencil_layer_addnew(bGPdata *gpd,
|
|||
}
|
||||
|
||||
/* auto-name */
|
||||
BLI_strncpy(gpl->info, DATA_(name), sizeof(gpl->info));
|
||||
STRNCPY(gpl->info, DATA_(name));
|
||||
BLI_uniquename(&gpd->layers,
|
||||
gpl,
|
||||
(gpd->flag & GP_DATA_ANNOTATIONS) ? DATA_("Note") : DATA_("GP_Layer"),
|
||||
|
@ -1018,9 +1018,9 @@ void BKE_gpencil_layer_copy_settings(const bGPDlayer *gpl_src, bGPDlayer *gpl_ds
|
|||
gpl_dst->pass_index = gpl_src->pass_index;
|
||||
gpl_dst->parent = gpl_src->parent;
|
||||
copy_m4_m4(gpl_dst->inverse, gpl_src->inverse);
|
||||
BLI_strncpy(gpl_dst->parsubstr, gpl_src->parsubstr, 64);
|
||||
STRNCPY(gpl_dst->parsubstr, gpl_src->parsubstr);
|
||||
gpl_dst->partype = gpl_src->partype;
|
||||
BLI_strncpy(gpl_dst->viewlayername, gpl_src->viewlayername, 64);
|
||||
STRNCPY(gpl_dst->viewlayername, gpl_src->viewlayername);
|
||||
copy_v3_v3(gpl_dst->location, gpl_src->location);
|
||||
copy_v3_v3(gpl_dst->rotation, gpl_src->rotation);
|
||||
copy_v3_v3(gpl_dst->scale, gpl_src->scale);
|
||||
|
@ -1436,7 +1436,7 @@ bGPDlayer_Mask *BKE_gpencil_layer_mask_add(bGPDlayer *gpl, const char *name)
|
|||
|
||||
bGPDlayer_Mask *mask = MEM_callocN(sizeof(bGPDlayer_Mask), "bGPDlayer_Mask");
|
||||
BLI_addtail(&gpl->mask_layers, mask);
|
||||
BLI_strncpy(mask->name, name, sizeof(mask->name));
|
||||
STRNCPY(mask->name, name);
|
||||
gpl->act_mask++;
|
||||
|
||||
return mask;
|
||||
|
|
|
@ -356,7 +356,7 @@ GpencilModifierData *BKE_gpencil_modifier_new(int type)
|
|||
GpencilModifierData *md = MEM_callocN(mti->struct_size, mti->struct_name);
|
||||
|
||||
/* NOTE: this name must be made unique later. */
|
||||
BLI_strncpy(md->name, DATA_(mti->name), sizeof(md->name));
|
||||
STRNCPY(md->name, DATA_(mti->name));
|
||||
|
||||
md->type = type;
|
||||
md->mode = eGpencilModifierMode_Realtime | eGpencilModifierMode_Render;
|
||||
|
|
|
@ -65,7 +65,7 @@ IDProperty *IDP_NewIDPArray(const char *name)
|
|||
IDProperty *prop = MEM_callocN(sizeof(IDProperty), "IDProperty prop array");
|
||||
prop->type = IDP_IDPARRAY;
|
||||
prop->len = 0;
|
||||
BLI_strncpy(prop->name, name, MAX_IDPROP_NAME);
|
||||
STRNCPY(prop->name, name);
|
||||
|
||||
return prop;
|
||||
}
|
||||
|
@ -300,7 +300,7 @@ static IDProperty *idp_generic_copy(const IDProperty *prop, const int UNUSED(fla
|
|||
{
|
||||
IDProperty *newp = MEM_callocN(sizeof(IDProperty), __func__);
|
||||
|
||||
BLI_strncpy(newp->name, prop->name, MAX_IDPROP_NAME);
|
||||
STRNCPY(newp->name, prop->name);
|
||||
newp->type = prop->type;
|
||||
newp->flag = prop->flag;
|
||||
newp->data.val = prop->data.val;
|
||||
|
@ -369,7 +369,7 @@ IDProperty *IDP_NewStringMaxSize(const char *st, const char *name, int maxncpy)
|
|||
}
|
||||
|
||||
prop->type = IDP_STRING;
|
||||
BLI_strncpy(prop->name, name, MAX_IDPROP_NAME);
|
||||
STRNCPY(prop->name, name);
|
||||
|
||||
return prop;
|
||||
}
|
||||
|
@ -1005,7 +1005,7 @@ IDProperty *IDP_New(const char type, const IDPropertyTemplate *val, const char *
|
|||
}
|
||||
|
||||
prop->type = type;
|
||||
BLI_strncpy(prop->name, name, MAX_IDPROP_NAME);
|
||||
STRNCPY(prop->name, name);
|
||||
|
||||
return prop;
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ static void idp_str_append_escape(struct ReprState *state,
|
|||
state->str_append_fn(state->user_data, str + i_prev, i - i_prev);
|
||||
}
|
||||
char buf[5];
|
||||
uint len = (uint)BLI_snprintf_rlen(buf, sizeof(buf), "\\x%02x", c);
|
||||
uint len = (uint)SNPRINTF_RLEN(buf, "\\x%02x", c);
|
||||
BLI_assert(len == 4);
|
||||
state->str_append_fn(state->user_data, buf, len);
|
||||
i_prev = i + 1;
|
||||
|
@ -90,9 +90,7 @@ static void idp_repr_fn_recursive(struct ReprState *state, const IDProperty *pro
|
|||
|
||||
#define STR_APPEND_FMT(format, ...) \
|
||||
state->str_append_fn( \
|
||||
state->user_data, \
|
||||
state->buf, \
|
||||
(uint)BLI_snprintf_rlen(state->buf, sizeof(state->buf), format, __VA_ARGS__))
|
||||
state->user_data, state->buf, (uint)SNPRINTF_RLEN(state->buf, format, __VA_ARGS__))
|
||||
|
||||
switch (prop->type) {
|
||||
case IDP_STRING: {
|
||||
|
|
|
@ -290,7 +290,7 @@ static void image_foreach_path(ID *id, BPathForeachPathData *bpath_data)
|
|||
bool result = false;
|
||||
if (ima->source == IMA_SRC_TILED && (flag & BKE_BPATH_FOREACH_PATH_RESOLVE_TOKEN) != 0) {
|
||||
char temp_path[FILE_MAX], orig_file[FILE_MAXFILE];
|
||||
BLI_strncpy(temp_path, ima->filepath, sizeof(temp_path));
|
||||
STRNCPY(temp_path, ima->filepath);
|
||||
BLI_path_split_file_part(temp_path, orig_file, sizeof(orig_file));
|
||||
|
||||
eUDIM_TILE_FORMAT tile_format;
|
||||
|
@ -3195,7 +3195,7 @@ void BKE_image_signal(Main *bmain, Image *ima, ImageUser *iuser, int signal)
|
|||
int new_start, new_range;
|
||||
|
||||
char filepath[FILE_MAX];
|
||||
BLI_strncpy(filepath, ima->filepath, sizeof(filepath));
|
||||
STRNCPY(filepath, ima->filepath);
|
||||
BLI_path_abs(filepath, ID_BLEND_PATH_FROM_GLOBAL(&ima->id));
|
||||
bool result = BKE_image_get_tile_info(filepath, &new_tiles, &new_start, &new_range);
|
||||
if (result) {
|
||||
|
@ -3407,7 +3407,7 @@ ImageTile *BKE_image_add_tile(struct Image *ima, int tile_number, const char *la
|
|||
}
|
||||
|
||||
if (label) {
|
||||
BLI_strncpy(tile->label, label, sizeof(tile->label));
|
||||
STRNCPY(tile->label, label);
|
||||
}
|
||||
|
||||
for (int eye = 0; eye < 2; eye++) {
|
||||
|
@ -5561,11 +5561,11 @@ RenderSlot *BKE_image_add_renderslot(Image *ima, const char *name)
|
|||
{
|
||||
RenderSlot *slot = MEM_cnew<RenderSlot>("Image new Render Slot");
|
||||
if (name && name[0]) {
|
||||
BLI_strncpy(slot->name, name, sizeof(slot->name));
|
||||
STRNCPY(slot->name, name);
|
||||
}
|
||||
else {
|
||||
int n = BLI_listbase_count(&ima->renderslots) + 1;
|
||||
BLI_snprintf(slot->name, sizeof(slot->name), DATA_("Slot %d"), n);
|
||||
SNPRINTF(slot->name, DATA_("Slot %d"), n);
|
||||
}
|
||||
BLI_addtail(&ima->renderslots, slot);
|
||||
return slot;
|
||||
|
|
|
@ -167,7 +167,7 @@ bool BKE_image_save_options_init(ImageSaveOptions *opts,
|
|||
const bool is_prev_save = !STREQ(G.ima, "//");
|
||||
if (opts->save_as_render) {
|
||||
if (is_prev_save) {
|
||||
BLI_strncpy(opts->filepath, G.ima, sizeof(opts->filepath));
|
||||
STRNCPY(opts->filepath, G.ima);
|
||||
}
|
||||
else {
|
||||
BLI_path_join(opts->filepath, sizeof(opts->filepath), "//", DATA_("untitled"));
|
||||
|
@ -252,7 +252,7 @@ static void image_save_update_filepath(Image *ima,
|
|||
const ImageSaveOptions *opts)
|
||||
{
|
||||
if (opts->do_newpath) {
|
||||
BLI_strncpy(ima->filepath, filepath, sizeof(ima->filepath));
|
||||
STRNCPY(ima->filepath, filepath);
|
||||
|
||||
/* only image path, never ibuf */
|
||||
if (opts->relative) {
|
||||
|
@ -281,7 +281,7 @@ static void image_save_post(ReportList *reports,
|
|||
}
|
||||
|
||||
if (opts->do_newpath) {
|
||||
BLI_strncpy(ibuf->filepath, filepath, sizeof(ibuf->filepath));
|
||||
STRNCPY(ibuf->filepath, filepath);
|
||||
}
|
||||
|
||||
/* The tiled image code-path must call this on its own. */
|
||||
|
@ -776,7 +776,7 @@ bool BKE_image_render_write_exr(ReportList *reports,
|
|||
|
||||
if (multi_layer) {
|
||||
RE_render_result_full_channel_name(passname, nullptr, "Combined", nullptr, chan_id, a);
|
||||
BLI_strncpy(layname, "Composite", sizeof(layname));
|
||||
STRNCPY(layname, "Composite");
|
||||
}
|
||||
else {
|
||||
passname[0] = chan_id[a];
|
||||
|
@ -842,7 +842,7 @@ bool BKE_image_render_write_exr(ReportList *reports,
|
|||
|
||||
if (multi_layer) {
|
||||
RE_render_result_full_channel_name(passname, nullptr, rp->name, nullptr, rp->chan_id, a);
|
||||
BLI_strncpy(layname, rl->name, sizeof(layname));
|
||||
STRNCPY(layname, rl->name);
|
||||
}
|
||||
else {
|
||||
passname[0] = rp->chan_id[a];
|
||||
|
|
|
@ -17,7 +17,7 @@ TEST(udim, image_ensure_tile_token)
|
|||
auto verify = [](const char *original, const char *expected) {
|
||||
char result[FILE_MAX];
|
||||
|
||||
BLI_strncpy(result, original, sizeof(result));
|
||||
STRNCPY(result, original);
|
||||
BKE_image_ensure_tile_token_filename_only(result, sizeof(result));
|
||||
EXPECT_STREQ(result, expected);
|
||||
};
|
||||
|
@ -172,7 +172,7 @@ TEST(udim, image_set_filepath_from_tile_number)
|
|||
char filepath[FILE_MAX];
|
||||
|
||||
/* Parameter validation. */
|
||||
BLI_strncpy(filepath, "xxxx", FILE_MAX);
|
||||
STRNCPY(filepath, "xxxx");
|
||||
|
||||
BKE_image_set_filepath_from_tile_number(nullptr, udim_pattern, tile_format, 1028);
|
||||
BKE_image_set_filepath_from_tile_number(filepath, nullptr, tile_format, 1028);
|
||||
|
|
|
@ -445,7 +445,7 @@ static char *shapekey_adrcodes_to_paths(ID *id, int adrcode, int *UNUSED(array_i
|
|||
/* block will be attached to ID_KE block... */
|
||||
if (adrcode == 0) {
|
||||
/* adrcode=0 was the misnamed "speed" curve (now "evaluation time") */
|
||||
BLI_strncpy(buf, "eval_time", sizeof(buf));
|
||||
STRNCPY(buf, "eval_time");
|
||||
}
|
||||
else {
|
||||
/* Find the name of the ShapeKey (i.e. KeyBlock) to look for */
|
||||
|
@ -457,11 +457,11 @@ static char *shapekey_adrcodes_to_paths(ID *id, int adrcode, int *UNUSED(array_i
|
|||
/* Use the keyblock name, escaped, so that path lookups for this will work */
|
||||
char kb_name_esc[sizeof(kb->name) * 2];
|
||||
BLI_str_escape(kb_name_esc, kb->name, sizeof(kb_name_esc));
|
||||
BLI_snprintf(buf, sizeof(buf), "key_blocks[\"%s\"].value", kb_name_esc);
|
||||
SNPRINTF(buf, "key_blocks[\"%s\"].value", kb_name_esc);
|
||||
}
|
||||
else {
|
||||
/* Fallback - Use the adrcode as index directly, so that this can be manually fixed */
|
||||
BLI_snprintf(buf, sizeof(buf), "key_blocks[%d].value", adrcode);
|
||||
SNPRINTF(buf, "key_blocks[%d].value", adrcode);
|
||||
}
|
||||
}
|
||||
return buf;
|
||||
|
@ -580,7 +580,7 @@ static const char *mtex_adrcodes_to_paths(int adrcode, int *UNUSED(array_index))
|
|||
|
||||
/* only build and return path if there's a property */
|
||||
if (prop) {
|
||||
BLI_snprintf(buf, 128, "%s.%s", base, prop);
|
||||
SNPRINTF(buf, "%s.%s", base, prop);
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
@ -1154,8 +1154,7 @@ static char *get_rna_access(ID *id,
|
|||
char constname_esc[sizeof(((bConstraint *)NULL)->name) * 2];
|
||||
BLI_str_escape(actname_esc, actname, sizeof(actname_esc));
|
||||
BLI_str_escape(constname_esc, constname, sizeof(constname_esc));
|
||||
BLI_snprintf(
|
||||
buf, sizeof(buf), "pose.bones[\"%s\"].constraints[\"%s\"]", actname_esc, constname_esc);
|
||||
SNPRINTF(buf, "pose.bones[\"%s\"].constraints[\"%s\"]", actname_esc, constname_esc);
|
||||
}
|
||||
else if (actname && actname[0]) {
|
||||
if ((blocktype == ID_OB) && STREQ(actname, "Object")) {
|
||||
|
@ -1171,20 +1170,20 @@ static char *get_rna_access(ID *id,
|
|||
/* Pose-Channel */
|
||||
char actname_esc[sizeof(((bActionChannel *)NULL)->name) * 2];
|
||||
BLI_str_escape(actname_esc, actname, sizeof(actname_esc));
|
||||
BLI_snprintf(buf, sizeof(buf), "pose.bones[\"%s\"]", actname_esc);
|
||||
SNPRINTF(buf, "pose.bones[\"%s\"]", actname_esc);
|
||||
}
|
||||
}
|
||||
else if (constname && constname[0]) {
|
||||
/* Constraint in Object */
|
||||
char constname_esc[sizeof(((bConstraint *)NULL)->name) * 2];
|
||||
BLI_str_escape(constname_esc, constname, sizeof(constname_esc));
|
||||
BLI_snprintf(buf, sizeof(buf), "constraints[\"%s\"]", constname_esc);
|
||||
SNPRINTF(buf, "constraints[\"%s\"]", constname_esc);
|
||||
}
|
||||
else if (seq) {
|
||||
/* Sequence names in Scene */
|
||||
char seq_name_esc[(sizeof(seq->name) - 2) * 2];
|
||||
BLI_str_escape(seq_name_esc, seq->name + 2, sizeof(seq_name_esc));
|
||||
BLI_snprintf(buf, sizeof(buf), "sequence_editor.sequences_all[\"%s\"]", seq_name_esc);
|
||||
SNPRINTF(buf, "sequence_editor.sequences_all[\"%s\"]", seq_name_esc);
|
||||
}
|
||||
else {
|
||||
buf[0] = '\0'; /* empty string */
|
||||
|
@ -1202,7 +1201,7 @@ static char *get_rna_access(ID *id,
|
|||
|
||||
/* if there was no array index pointer provided, add it to the path */
|
||||
if (array_index == NULL) {
|
||||
BLI_snprintf(buf, sizeof(buf), "[\"%d\"]", dummy_index);
|
||||
SNPRINTF(buf, "[\"%d\"]", dummy_index);
|
||||
BLI_dynstr_append(path, buf);
|
||||
}
|
||||
|
||||
|
@ -1261,7 +1260,7 @@ static ChannelDriver *idriver_to_cdriver(IpoDriver *idriver)
|
|||
/* FIXME: expression will be useless due to API changes, but at least not totally lost */
|
||||
cdriver->type = DRIVER_TYPE_PYTHON;
|
||||
if (idriver->name[0]) {
|
||||
BLI_strncpy(cdriver->expression, idriver->name, sizeof(cdriver->expression));
|
||||
STRNCPY(cdriver->expression, idriver->name);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -1283,7 +1282,7 @@ static ChannelDriver *idriver_to_cdriver(IpoDriver *idriver)
|
|||
dtar->id = (ID *)idriver->ob;
|
||||
dtar->idtype = ID_OB;
|
||||
if (idriver->name[0]) {
|
||||
BLI_strncpy(dtar->pchan_name, idriver->name, sizeof(dtar->pchan_name));
|
||||
STRNCPY(dtar->pchan_name, idriver->name);
|
||||
}
|
||||
|
||||
/* second bone target (name was stored in same var as the first one) */
|
||||
|
@ -1291,8 +1290,7 @@ static ChannelDriver *idriver_to_cdriver(IpoDriver *idriver)
|
|||
dtar->id = (ID *)idriver->ob;
|
||||
dtar->idtype = ID_OB;
|
||||
if (idriver->name[0]) { /* XXX: for safety. */
|
||||
BLI_strncpy(
|
||||
dtar->pchan_name, idriver->name + DRIVER_NAME_OFFS, sizeof(dtar->pchan_name));
|
||||
STRNCPY(dtar->pchan_name, idriver->name + DRIVER_NAME_OFFS);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -1305,7 +1303,7 @@ static ChannelDriver *idriver_to_cdriver(IpoDriver *idriver)
|
|||
dtar->id = (ID *)idriver->ob;
|
||||
dtar->idtype = ID_OB;
|
||||
if (idriver->name[0]) {
|
||||
BLI_strncpy(dtar->pchan_name, idriver->name, sizeof(dtar->pchan_name));
|
||||
STRNCPY(dtar->pchan_name, idriver->name);
|
||||
}
|
||||
dtar->transChan = adrcode_to_dtar_transchan(idriver->adrcode);
|
||||
dtar->flag |= DTAR_FLAG_LOCALSPACE; /* old drivers took local space */
|
||||
|
@ -1362,7 +1360,7 @@ static void fcurve_add_to_list(
|
|||
agrp->flag |= AGRP_MUTED;
|
||||
}
|
||||
|
||||
BLI_strncpy(agrp->name, grpname, sizeof(agrp->name));
|
||||
STRNCPY(agrp->name, grpname);
|
||||
|
||||
BLI_addtail(&tmp_act.groups, agrp);
|
||||
BLI_uniquename(&tmp_act.groups,
|
||||
|
@ -1876,7 +1874,7 @@ static void ipo_to_animdata(
|
|||
if (adt->action == NULL) {
|
||||
char nameBuf[MAX_ID_NAME];
|
||||
|
||||
BLI_snprintf(nameBuf, sizeof(nameBuf), "CDA:%s", ipo->id.name + 2);
|
||||
SNPRINTF(nameBuf, "CDA:%s", ipo->id.name + 2);
|
||||
|
||||
adt->action = BKE_action_add(bmain, nameBuf);
|
||||
if (G.debug & G_DEBUG) {
|
||||
|
|
|
@ -1841,14 +1841,14 @@ KeyBlock *BKE_keyblock_add(Key *key, const char *name)
|
|||
|
||||
tot = BLI_listbase_count(&key->block);
|
||||
if (name) {
|
||||
BLI_strncpy(kb->name, name, sizeof(kb->name));
|
||||
STRNCPY(kb->name, name);
|
||||
}
|
||||
else {
|
||||
if (tot == 1) {
|
||||
BLI_strncpy(kb->name, DATA_("Basis"), sizeof(kb->name));
|
||||
STRNCPY(kb->name, DATA_("Basis"));
|
||||
}
|
||||
else {
|
||||
BLI_snprintf(kb->name, sizeof(kb->name), DATA_("Key %d"), tot - 1);
|
||||
SNPRINTF(kb->name, DATA_("Key %d"), tot - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1961,7 +1961,7 @@ void BKE_keyblock_copy_settings(KeyBlock *kb_dst, const KeyBlock *kb_src)
|
|||
kb_dst->curval = kb_src->curval;
|
||||
kb_dst->type = kb_src->type;
|
||||
kb_dst->relative = kb_src->relative;
|
||||
BLI_strncpy(kb_dst->vgroup, kb_src->vgroup, sizeof(kb_dst->vgroup));
|
||||
STRNCPY(kb_dst->vgroup, kb_src->vgroup);
|
||||
kb_dst->slidermin = kb_src->slidermin;
|
||||
kb_dst->slidermax = kb_src->slidermax;
|
||||
}
|
||||
|
|
|
@ -161,7 +161,7 @@ static ViewLayer *view_layer_add(const char *name)
|
|||
ViewLayer *view_layer = MEM_cnew<ViewLayer>("View Layer");
|
||||
view_layer->flag = VIEW_LAYER_RENDER | VIEW_LAYER_FREESTYLE;
|
||||
|
||||
BLI_strncpy_utf8(view_layer->name, name, sizeof(view_layer->name));
|
||||
STRNCPY_UTF8(view_layer->name, name);
|
||||
|
||||
/* Pure rendering pipeline settings. */
|
||||
view_layer->layflag = SCE_LAY_FLAG_DEFAULT;
|
||||
|
@ -210,7 +210,7 @@ ViewLayer *BKE_view_layer_add(Scene *scene,
|
|||
BKE_view_layer_copy_data(scene, scene, view_layer_new, view_layer_source, 0);
|
||||
BLI_addtail(&scene->view_layers, view_layer_new);
|
||||
|
||||
BLI_strncpy_utf8(view_layer_new->name, name, sizeof(view_layer_new->name));
|
||||
STRNCPY_UTF8(view_layer_new->name, name);
|
||||
break;
|
||||
}
|
||||
case VIEWLAYER_ADD_EMPTY: {
|
||||
|
@ -553,9 +553,9 @@ void BKE_view_layer_rename(Main *bmain, Scene *scene, ViewLayer *view_layer, con
|
|||
{
|
||||
char oldname[sizeof(view_layer->name)];
|
||||
|
||||
BLI_strncpy(oldname, view_layer->name, sizeof(view_layer->name));
|
||||
STRNCPY(oldname, view_layer->name);
|
||||
|
||||
BLI_strncpy_utf8(view_layer->name, newname, sizeof(view_layer->name));
|
||||
STRNCPY_UTF8(view_layer->name, newname);
|
||||
BLI_uniquename(&scene->view_layers,
|
||||
view_layer,
|
||||
DATA_("ViewLayer"),
|
||||
|
@ -570,7 +570,7 @@ void BKE_view_layer_rename(Main *bmain, Scene *scene, ViewLayer *view_layer, con
|
|||
for (node = static_cast<bNode *>(scene->nodetree->nodes.first); node; node = node->next) {
|
||||
if (node->type == CMP_NODE_R_LAYERS && node->id == nullptr) {
|
||||
if (node->custom1 == index) {
|
||||
BLI_strncpy(node->name, view_layer->name, NODE_MAXSTR);
|
||||
STRNCPY(node->name, view_layer->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2522,7 +2522,7 @@ ViewLayerAOV *BKE_view_layer_add_aov(ViewLayer *view_layer)
|
|||
ViewLayerAOV *aov;
|
||||
aov = MEM_cnew<ViewLayerAOV>(__func__);
|
||||
aov->type = AOV_TYPE_COLOR;
|
||||
BLI_strncpy(aov->name, DATA_("AOV"), sizeof(aov->name));
|
||||
STRNCPY(aov->name, DATA_("AOV"));
|
||||
BLI_addtail(&view_layer->aovs, aov);
|
||||
viewlayer_aov_active_set(view_layer, aov);
|
||||
viewlayer_aov_make_name_unique(view_layer);
|
||||
|
@ -2643,10 +2643,10 @@ ViewLayerLightgroup *BKE_view_layer_add_lightgroup(ViewLayer *view_layer, const
|
|||
ViewLayerLightgroup *lightgroup;
|
||||
lightgroup = MEM_cnew<ViewLayerLightgroup>(__func__);
|
||||
if (name && name[0]) {
|
||||
BLI_strncpy(lightgroup->name, name, sizeof(lightgroup->name));
|
||||
STRNCPY(lightgroup->name, name);
|
||||
}
|
||||
else {
|
||||
BLI_strncpy(lightgroup->name, DATA_("Lightgroup"), sizeof(lightgroup->name));
|
||||
STRNCPY(lightgroup->name, DATA_("Lightgroup"));
|
||||
}
|
||||
BLI_addtail(&view_layer->lightgroups, lightgroup);
|
||||
viewlayer_lightgroup_active_set(view_layer, lightgroup);
|
||||
|
@ -2690,8 +2690,8 @@ void BKE_view_layer_rename_lightgroup(Scene *scene,
|
|||
const char *name)
|
||||
{
|
||||
char old_name[64];
|
||||
BLI_strncpy_utf8(old_name, lightgroup->name, sizeof(old_name));
|
||||
BLI_strncpy_utf8(lightgroup->name, name, sizeof(lightgroup->name));
|
||||
STRNCPY_UTF8(old_name, lightgroup->name);
|
||||
STRNCPY_UTF8(lightgroup->name, name);
|
||||
viewlayer_lightgroup_make_name_unique(view_layer, lightgroup);
|
||||
|
||||
if (scene != nullptr) {
|
||||
|
@ -2700,7 +2700,7 @@ void BKE_view_layer_rename_lightgroup(Scene *scene,
|
|||
if (!ID_IS_LINKED(ob) && ob->lightgroup != nullptr) {
|
||||
LightgroupMembership *lgm = ob->lightgroup;
|
||||
if (STREQ(lgm->name, old_name)) {
|
||||
BLI_strncpy_utf8(lgm->name, lightgroup->name, sizeof(lgm->name));
|
||||
STRNCPY_UTF8(lgm->name, lightgroup->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2711,7 +2711,7 @@ void BKE_view_layer_rename_lightgroup(Scene *scene,
|
|||
scene->world->lightgroup != nullptr) {
|
||||
LightgroupMembership *lgm = scene->world->lightgroup;
|
||||
if (STREQ(lgm->name, old_name)) {
|
||||
BLI_strncpy_utf8(lgm->name, lightgroup->name, sizeof(lgm->name));
|
||||
STRNCPY_UTF8(lgm->name, lightgroup->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ TEST(view_layer, aov_unique_names)
|
|||
EXPECT_TRUE(STREQ(aov2->name, "AOV_001"));
|
||||
|
||||
/* Revert previous resolution */
|
||||
BLI_strncpy(aov2->name, "AOV", MAX_NAME);
|
||||
STRNCPY(aov2->name, "AOV");
|
||||
BKE_view_layer_verify_aov(engine, &scene, view_layer);
|
||||
EXPECT_TRUE(BKE_view_layer_has_valid_aov(view_layer));
|
||||
EXPECT_FALSE((aov1->flag & AOV_CONFLICT) != 0);
|
||||
|
@ -97,7 +97,7 @@ static void test_render_pass_conflict(Scene *scene,
|
|||
RNA_boolean_set(&ptr, rna_prop_name, false);
|
||||
|
||||
/* Rename to Conflicting name */
|
||||
BLI_strncpy(aov->name, render_pass_name, MAX_NAME);
|
||||
STRNCPY(aov->name, render_pass_name);
|
||||
BKE_view_layer_verify_aov(engine, scene, view_layer);
|
||||
EXPECT_TRUE(BKE_view_layer_has_valid_aov(view_layer));
|
||||
EXPECT_FALSE((aov->flag & AOV_CONFLICT) != 0);
|
||||
|
|
|
@ -1361,7 +1361,7 @@ void BKE_libblock_copy_ex(Main *bmain, const ID *id, ID **r_newid, const int ori
|
|||
if ((flag & LIB_ID_CREATE_NO_ALLOCATE) != 0) {
|
||||
/* r_newid already contains pointer to allocated memory. */
|
||||
/* TODO: do we want to memset(0) whole mem before filling it? */
|
||||
BLI_strncpy(new_id->name, id->name, sizeof(new_id->name));
|
||||
STRNCPY(new_id->name, id->name);
|
||||
new_id->us = 0;
|
||||
new_id->tag |= LIB_TAG_NOT_ALLOCATED | LIB_TAG_NO_MAIN | LIB_TAG_NO_USER_REFCOUNT;
|
||||
/* TODO: Do we want/need to copy more from ID struct itself? */
|
||||
|
@ -1597,11 +1597,11 @@ bool BKE_id_new_name_validate(
|
|||
tname = id->name + 2;
|
||||
}
|
||||
/* Make a copy of given name (tname args can be const). */
|
||||
BLI_strncpy(name, tname, sizeof(name));
|
||||
STRNCPY(name, tname);
|
||||
|
||||
if (name[0] == '\0') {
|
||||
/* Disallow empty names. */
|
||||
BLI_strncpy(name, DATA_(BKE_idtype_idcode_to_name(GS(id->name))), sizeof(name));
|
||||
STRNCPY(name, DATA_(BKE_idtype_idcode_to_name(GS(id->name))));
|
||||
}
|
||||
else {
|
||||
/* disallow non utf8 chars,
|
||||
|
|
|
@ -39,8 +39,8 @@ TEST(lib_id_remapper, mapped)
|
|||
ID id1;
|
||||
ID id2;
|
||||
ID *idp = &id1;
|
||||
BLI_strncpy(id1.name, "OB1", sizeof(id1.name));
|
||||
BLI_strncpy(id2.name, "OB2", sizeof(id2.name));
|
||||
STRNCPY(id1.name, "OB1");
|
||||
STRNCPY(id2.name, "OB2");
|
||||
|
||||
IDRemapper *remapper = BKE_id_remapper_create();
|
||||
BKE_id_remapper_add(remapper, &id1, &id2);
|
||||
|
@ -55,7 +55,7 @@ TEST(lib_id_remapper, unassigned)
|
|||
{
|
||||
ID id1;
|
||||
ID *idp = &id1;
|
||||
BLI_strncpy(id1.name, "OB2", sizeof(id1.name));
|
||||
STRNCPY(id1.name, "OB2");
|
||||
|
||||
IDRemapper *remapper = BKE_id_remapper_create();
|
||||
BKE_id_remapper_add(remapper, &id1, nullptr);
|
||||
|
@ -73,9 +73,9 @@ TEST(lib_id_remapper, unassign_when_mapped_to_self)
|
|||
ID id2;
|
||||
ID *idp;
|
||||
|
||||
BLI_strncpy(id_self.name, "OBSelf", sizeof(id1.name));
|
||||
BLI_strncpy(id1.name, "OB1", sizeof(id1.name));
|
||||
BLI_strncpy(id2.name, "OB2", sizeof(id2.name));
|
||||
STRNCPY(id_self.name, "OBSelf");
|
||||
STRNCPY(id1.name, "OB1");
|
||||
STRNCPY(id2.name, "OB2");
|
||||
|
||||
/* Default mapping behavior. Should just remap to id2. */
|
||||
idp = &id1;
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <map>
|
||||
#include <queue>
|
||||
|
||||
#include "CLG_log.h"
|
||||
|
||||
|
@ -1754,6 +1756,91 @@ static void lib_override_library_remap(Main *bmain,
|
|||
BLI_linklist_free(nomain_ids, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mapping to find suitable missing linked liboverrides to replace by the newly generated linked
|
||||
* liboverrides during resync process.
|
||||
*
|
||||
* \note About Order:
|
||||
* In most cases, if there are several virtual linked liboverrides generated with the same base
|
||||
* name (like `OBCube.001`, `OBCube.002`, etc.), this mapping system will find the correct one, for
|
||||
* the following reasons:
|
||||
* - Order of creation of these virtual IDs in resync process is expected to be stable (i.e.
|
||||
* several runs of resync code based on the same linked data would re-create the same virtual
|
||||
* liboverride IDs in the same order);
|
||||
* - Order of creation and usage of the mapping data (a FIFO queue) also ensures that the missing
|
||||
* placeholder `OBCube.001` is always 're-used' before `OBCube.002`.
|
||||
*
|
||||
* In case linked data keep being modified, these conditions may fail and the mapping may start to
|
||||
* return 'wrong' results. However, this is considered as an acceptable limitation here, since this
|
||||
* is mainly a 'best effort' to recover from situations that should not be hapenning in the first
|
||||
* place.
|
||||
*/
|
||||
|
||||
using LibOverrideMissingIDsData_Key = const std::pair<std::string, Library *>;
|
||||
using LibOverrideMissingIDsData_Value = std::deque<ID *>;
|
||||
using LibOverrideMissingIDsData =
|
||||
std::map<LibOverrideMissingIDsData_Key, LibOverrideMissingIDsData_Value>;
|
||||
|
||||
/* Return a key suitable for the missing IDs mapping, i.e. a pair of
|
||||
* `<full ID name (including first two ID type chars) without a potential numeric extension,
|
||||
* ID library>`.
|
||||
*
|
||||
* So e.g. returns `<"OBMyObject", lib>` for ID from `lib` with names like `"OBMyObject"`,
|
||||
* `"OBMyObject.002"`, `"OBMyObject.12345"`, and so on, but _not_ for e.g. `"OBMyObject.12.002"`.
|
||||
*/
|
||||
static LibOverrideMissingIDsData_Key lib_override_library_resync_missing_id_key(ID *id)
|
||||
{
|
||||
std::string id_name_key(id->name);
|
||||
const size_t last_key_index = id_name_key.find_last_not_of("0123456789");
|
||||
|
||||
BLI_assert(last_key_index != std::string::npos);
|
||||
|
||||
if (id_name_key[last_key_index] == '.') {
|
||||
id_name_key.resize(last_key_index);
|
||||
}
|
||||
|
||||
return LibOverrideMissingIDsData_Key(id_name_key, id->lib);
|
||||
}
|
||||
|
||||
static LibOverrideMissingIDsData lib_override_library_resync_build_missing_ids_data(Main *bmain)
|
||||
{
|
||||
LibOverrideMissingIDsData missing_ids;
|
||||
ID *id_iter;
|
||||
FOREACH_MAIN_ID_BEGIN (bmain, id_iter) {
|
||||
if (!ID_IS_LINKED(id_iter)) {
|
||||
continue;
|
||||
}
|
||||
const int required_tags = (LIB_TAG_MISSING | LIB_TAG_LIBOVERRIDE_NEED_RESYNC);
|
||||
if ((id_iter->tag & required_tags) != required_tags) {
|
||||
continue;
|
||||
}
|
||||
|
||||
LibOverrideMissingIDsData_Key key = lib_override_library_resync_missing_id_key(id_iter);
|
||||
std::pair<LibOverrideMissingIDsData::iterator, bool> value = missing_ids.try_emplace(
|
||||
key, LibOverrideMissingIDsData_Value());
|
||||
value.first->second.push_back(id_iter);
|
||||
}
|
||||
FOREACH_MAIN_ID_END;
|
||||
|
||||
return missing_ids;
|
||||
}
|
||||
|
||||
static ID *lib_override_library_resync_search_missing_ids_data(
|
||||
LibOverrideMissingIDsData &missing_ids, ID *id_override)
|
||||
{
|
||||
LibOverrideMissingIDsData_Key key = lib_override_library_resync_missing_id_key(id_override);
|
||||
const LibOverrideMissingIDsData::iterator value = missing_ids.find(key);
|
||||
if (value == missing_ids.end()) {
|
||||
return nullptr;
|
||||
}
|
||||
if (value->second.empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
ID *match_id = value->second.front();
|
||||
value->second.pop_front();
|
||||
return match_id;
|
||||
}
|
||||
|
||||
static bool lib_override_library_resync(Main *bmain,
|
||||
Scene *scene,
|
||||
ViewLayer *view_layer,
|
||||
|
@ -1969,6 +2056,11 @@ static bool lib_override_library_resync(Main *bmain,
|
|||
return success;
|
||||
}
|
||||
|
||||
/* Get a mapping of all missing linked IDs that were liboverrides, to search for 'old
|
||||
* liboverrides' for newly created ones that do not alredy have one, in next step. */
|
||||
LibOverrideMissingIDsData missing_ids_data = lib_override_library_resync_build_missing_ids_data(
|
||||
bmain);
|
||||
|
||||
ListBase *lb;
|
||||
FOREACH_MAIN_LISTBASE_BEGIN (bmain, lb) {
|
||||
FOREACH_MAIN_LISTBASE_ID_BEGIN (lb, id) {
|
||||
|
@ -1987,6 +2079,26 @@ static bool lib_override_library_resync(Main *bmain,
|
|||
BLI_assert(/*!ID_IS_LINKED(id_override_new) || */ id_override_new->lib == id->lib);
|
||||
BLI_assert(id_override_old == nullptr || id_override_old->lib == id_root->lib);
|
||||
id_override_new->lib = id_root->lib;
|
||||
|
||||
/* The old override may have been created as linked data and then referenced by local data
|
||||
* during a previous Blender session, in which case it became directly linked and a reference
|
||||
* to it was stored in the local .blend file. however, since that linked liboverride ID does
|
||||
* not actually exist in the original library file, on next file read it is lost and marked
|
||||
* as missing ID.*/
|
||||
if (id_override_old == nullptr && ID_IS_LINKED(id_override_new)) {
|
||||
id_override_old = lib_override_library_resync_search_missing_ids_data(missing_ids_data,
|
||||
id_override_new);
|
||||
BLI_assert(id_override_old == nullptr || id_override_old->lib == id_override_new->lib);
|
||||
if (id_override_old != nullptr) {
|
||||
BLI_ghash_insert(linkedref_to_old_override, id, id_override_old);
|
||||
CLOG_INFO(&LOG,
|
||||
2,
|
||||
"Found missing linked old override best-match %s for new linked override %s",
|
||||
id_override_old->name,
|
||||
id_override_new->name);
|
||||
}
|
||||
}
|
||||
|
||||
/* Remap step below will tag directly linked ones properly as needed. */
|
||||
if (ID_IS_LINKED(id_override_new)) {
|
||||
id_override_new->tag |= LIB_TAG_INDIRECT;
|
||||
|
@ -2005,7 +2117,12 @@ static bool lib_override_library_resync(Main *bmain,
|
|||
|
||||
lib_override_object_posemode_transfer(id_override_new, id_override_old);
|
||||
|
||||
if (ID_IS_OVERRIDE_LIBRARY_REAL(id_override_new)) {
|
||||
/* Missing old liboverrides cannot transfer their override rules to new liboverride.
|
||||
* This is fine though, since these are expected to only be 'virtual' linked overrides
|
||||
* generated by resync of linked overrides. So nothing is expected to be overridden here.
|
||||
*/
|
||||
if (ID_IS_OVERRIDE_LIBRARY_REAL(id_override_new) &&
|
||||
(id_override_old->tag & LIB_TAG_MISSING) == 0) {
|
||||
BLI_assert(ID_IS_OVERRIDE_LIBRARY_REAL(id_override_old));
|
||||
|
||||
id_override_new->override_library->flag = id_override_old->override_library->flag;
|
||||
|
@ -4206,7 +4323,7 @@ void BKE_lib_override_library_update(Main *bmain, ID *local)
|
|||
* different from reference linked ID. But local ID names need to be unique in a given type
|
||||
* list of Main, so we cannot always keep it identical, which is why we need this special
|
||||
* manual handling here. */
|
||||
BLI_strncpy(tmp_id->name, local->name, sizeof(tmp_id->name));
|
||||
STRNCPY(tmp_id->name, local->name);
|
||||
|
||||
/* Those ugly loop-back pointers again. Luckily we only need to deal with the shape keys here,
|
||||
* collections' parents are fully runtime and reconstructed later. */
|
||||
|
@ -4216,7 +4333,7 @@ void BKE_lib_override_library_update(Main *bmain, ID *local)
|
|||
tmp_key->id.flag |= (local_key->id.flag & LIB_EMBEDDED_DATA_LIB_OVERRIDE);
|
||||
BKE_main_namemap_remove_name(bmain, &tmp_key->id, tmp_key->id.name + 2);
|
||||
tmp_key->id.lib = local_key->id.lib;
|
||||
BLI_strncpy(tmp_key->id.name, local_key->id.name, sizeof(tmp_key->id.name));
|
||||
STRNCPY(tmp_key->id.name, local_key->id.name);
|
||||
}
|
||||
|
||||
PointerRNA rnaptr_src, rnaptr_dst, rnaptr_storage_stack, *rnaptr_storage = nullptr;
|
||||
|
|
|
@ -113,10 +113,10 @@ void BKE_library_filepath_set(Main *bmain, Library *lib, const char *filepath)
|
|||
/* in some cases this is used to update the absolute path from the
|
||||
* relative */
|
||||
if (lib->filepath != filepath) {
|
||||
BLI_strncpy(lib->filepath, filepath, sizeof(lib->filepath));
|
||||
STRNCPY(lib->filepath, filepath);
|
||||
}
|
||||
|
||||
BLI_strncpy(lib->filepath_abs, filepath, sizeof(lib->filepath_abs));
|
||||
STRNCPY(lib->filepath_abs, filepath);
|
||||
|
||||
/* Not essential but set `filepath_abs` is an absolute copy of value which
|
||||
* is more useful if its kept in sync. */
|
||||
|
|
|
@ -815,7 +815,7 @@ static LineStyleModifier *new_modifier(const char *name, int type, size_t size)
|
|||
}
|
||||
m = (LineStyleModifier *)MEM_callocN(size, "line style modifier");
|
||||
m->type = type;
|
||||
BLI_strncpy(m->name, name, sizeof(m->name));
|
||||
STRNCPY(m->name, name);
|
||||
m->influence = 1.0f;
|
||||
m->flags = LS_MODIFIER_ENABLED | LS_MODIFIER_EXPANDED;
|
||||
|
||||
|
|
|
@ -377,8 +377,8 @@ static LibWeakRefKey *lib_weak_key_create(LibWeakRefKey *key,
|
|||
if (key == NULL) {
|
||||
key = MEM_mallocN(sizeof(*key), __func__);
|
||||
}
|
||||
BLI_strncpy(key->filepath, lib_path, sizeof(key->filepath));
|
||||
BLI_strncpy(key->id_name, id_name, sizeof(key->id_name));
|
||||
STRNCPY(key->filepath, lib_path);
|
||||
STRNCPY(key->id_name, id_name);
|
||||
return key;
|
||||
}
|
||||
|
||||
|
@ -463,12 +463,8 @@ void BKE_main_library_weak_reference_add_item(GHash *library_weak_reference_mapp
|
|||
BLI_assert(!already_exist_in_mapping);
|
||||
UNUSED_VARS_NDEBUG(already_exist_in_mapping);
|
||||
|
||||
BLI_strncpy(new_id->library_weak_reference->library_filepath,
|
||||
library_filepath,
|
||||
sizeof(new_id->library_weak_reference->library_filepath));
|
||||
BLI_strncpy(new_id->library_weak_reference->library_id_name,
|
||||
library_id_name,
|
||||
sizeof(new_id->library_weak_reference->library_id_name));
|
||||
STRNCPY(new_id->library_weak_reference->library_filepath, library_filepath);
|
||||
STRNCPY(new_id->library_weak_reference->library_id_name, library_id_name);
|
||||
*id_p = new_id;
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ using namespace blender;
|
|||
static bool id_name_final_build(char *name, char *base_name, size_t base_name_len, int number)
|
||||
{
|
||||
char number_str[11]; /* Dot + nine digits + NULL terminator. */
|
||||
size_t number_str_len = BLI_snprintf_rlen(number_str, ARRAY_SIZE(number_str), ".%.3d", number);
|
||||
size_t number_str_len = SNPRINTF_RLEN(number_str, ".%.3d", number);
|
||||
|
||||
/* If the number would lead to an overflow of the maximum ID name length, we need to truncate
|
||||
* the base name part and do all the number checks again. */
|
||||
|
@ -229,7 +229,7 @@ static void main_namemap_populate(UniqueName_Map *name_map, struct Main *bmain,
|
|||
|
||||
/* Insert the full name into the set. */
|
||||
UniqueName_Key key;
|
||||
BLI_strncpy(key.name, id->name + 2, MAX_NAME);
|
||||
STRNCPY(key.name, id->name + 2);
|
||||
type_map->full_names.add(key);
|
||||
|
||||
/* Get the name and number parts ("name.number"). */
|
||||
|
@ -279,7 +279,7 @@ bool BKE_main_namemap_get_name(struct Main *bmain, struct ID *id, char *name)
|
|||
UniqueName_Key key;
|
||||
while (true) {
|
||||
/* Check if the full original name has a duplicate. */
|
||||
BLI_strncpy(key.name, name, MAX_NAME);
|
||||
STRNCPY(key.name, name);
|
||||
const bool has_dup = type_map->full_names.contains(key);
|
||||
|
||||
/* Get the name and number parts ("name.number"). */
|
||||
|
@ -299,7 +299,7 @@ bool BKE_main_namemap_get_name(struct Main *bmain, struct ID *id, char *name)
|
|||
val.mark_used(number);
|
||||
|
||||
if (!has_dup) {
|
||||
BLI_strncpy(key.name, name, MAX_NAME);
|
||||
STRNCPY(key.name, name);
|
||||
type_map->full_names.add(key);
|
||||
}
|
||||
return is_name_changed;
|
||||
|
@ -334,7 +334,7 @@ bool BKE_main_namemap_get_name(struct Main *bmain, struct ID *id, char *name)
|
|||
BLI_assert(number_to_use >= MIN_NUMBER);
|
||||
if (id_name_final_build(name, key.name, base_name_len, number_to_use)) {
|
||||
/* All good, add final name to the set. */
|
||||
BLI_strncpy(key.name, name, MAX_NAME);
|
||||
STRNCPY(key.name, name);
|
||||
type_map->full_names.add(key);
|
||||
break;
|
||||
}
|
||||
|
@ -369,7 +369,7 @@ void BKE_main_namemap_remove_name(struct Main *bmain, struct ID *id, const char
|
|||
|
||||
UniqueName_Key key;
|
||||
/* Remove full name from the set. */
|
||||
BLI_strncpy(key.name, name, MAX_NAME);
|
||||
STRNCPY(key.name, name);
|
||||
type_map->full_names.remove(key);
|
||||
|
||||
int number = MIN_NUMBER;
|
||||
|
@ -408,7 +408,7 @@ static bool main_namemap_validate_and_fix(Main *bmain, const bool do_fix)
|
|||
FOREACH_MAIN_LISTBASE_BEGIN (bmain, lb_iter) {
|
||||
LISTBASE_FOREACH_MUTABLE (ID *, id_iter, lb_iter) {
|
||||
Uniqueness_Key key;
|
||||
BLI_strncpy(key.name, id_iter->name, MAX_ID_NAME);
|
||||
STRNCPY(key.name, id_iter->name);
|
||||
key.lib = id_iter->lib;
|
||||
if (!id_names_libs.add(key)) {
|
||||
is_valid = false;
|
||||
|
@ -421,7 +421,7 @@ static bool main_namemap_validate_and_fix(Main *bmain, const bool do_fix)
|
|||
* not really an issue. */
|
||||
BKE_id_new_name_validate(
|
||||
bmain, which_libbase(bmain, GS(id_iter->name)), id_iter, nullptr, true);
|
||||
BLI_strncpy(key.name, id_iter->name, MAX_ID_NAME);
|
||||
STRNCPY(key.name, id_iter->name);
|
||||
if (!id_names_libs.add(key)) {
|
||||
CLOG_ERROR(&LOG,
|
||||
"\tID has been renamed to '%s', but it still seems to be already in use",
|
||||
|
@ -442,7 +442,7 @@ static bool main_namemap_validate_and_fix(Main *bmain, const bool do_fix)
|
|||
|
||||
UniqueName_Key key_namemap;
|
||||
/* Remove full name from the set. */
|
||||
BLI_strncpy(key_namemap.name, id_iter->name + 2, MAX_NAME);
|
||||
STRNCPY(key_namemap.name, id_iter->name + 2);
|
||||
if (!type_map->full_names.contains(key_namemap)) {
|
||||
is_valid = false;
|
||||
CLOG_ERROR(&LOG,
|
||||
|
|
|
@ -336,7 +336,7 @@ MaskLayer *BKE_mask_layer_new(Mask *mask, const char *name)
|
|||
MaskLayer *masklay = MEM_cnew<MaskLayer>(__func__);
|
||||
|
||||
if (name && name[0]) {
|
||||
BLI_strncpy(masklay->name, name, sizeof(masklay->name));
|
||||
STRNCPY(masklay->name, name);
|
||||
}
|
||||
else {
|
||||
strcpy(masklay->name, DATA_("MaskLayer"));
|
||||
|
@ -389,7 +389,7 @@ void BKE_mask_layer_unique_name(Mask *mask, MaskLayer *masklay)
|
|||
|
||||
void BKE_mask_layer_rename(Mask *mask, MaskLayer *masklay, char *oldname, char *newname)
|
||||
{
|
||||
BLI_strncpy(masklay->name, newname, sizeof(masklay->name));
|
||||
STRNCPY(masklay->name, newname);
|
||||
|
||||
BKE_mask_layer_unique_name(mask, masklay);
|
||||
|
||||
|
@ -401,7 +401,7 @@ MaskLayer *BKE_mask_layer_copy(const MaskLayer *masklay)
|
|||
{
|
||||
MaskLayer *masklay_new = MEM_cnew<MaskLayer>("new mask layer");
|
||||
|
||||
BLI_strncpy(masklay_new->name, masklay->name, sizeof(masklay_new->name));
|
||||
STRNCPY(masklay_new->name, masklay->name);
|
||||
|
||||
masklay_new->alpha = masklay->alpha;
|
||||
masklay_new->blend = masklay->blend;
|
||||
|
@ -1011,7 +1011,7 @@ Mask *BKE_mask_new(Main *bmain, const char *name)
|
|||
char mask_name[MAX_ID_NAME - 2];
|
||||
|
||||
if (name && name[0]) {
|
||||
BLI_strncpy(mask_name, name, sizeof(mask_name));
|
||||
STRNCPY(mask_name, name);
|
||||
}
|
||||
else {
|
||||
strcpy(mask_name, "Mask");
|
||||
|
|
|
@ -770,7 +770,7 @@ static Mesh *mesh_new_from_mesh(Object *object, Mesh *mesh)
|
|||
nullptr, &mesh->id, nullptr, LIB_ID_CREATE_NO_MAIN | LIB_ID_CREATE_NO_USER_REFCOUNT);
|
||||
/* NOTE: Materials should already be copied. */
|
||||
/* Copy original mesh name. This is because edit meshes might not have one properly set name. */
|
||||
BLI_strncpy(mesh_result->id.name, ((ID *)object->data)->name, sizeof(mesh_result->id.name));
|
||||
STRNCPY(mesh_result->id.name, ((ID *)object->data)->name);
|
||||
return mesh_result;
|
||||
}
|
||||
|
||||
|
|
|
@ -1331,8 +1331,10 @@ void normals_calc_loop(const Span<float3> vert_positions,
|
|||
MLoopNorSpace *lnor_spaces = nullptr;
|
||||
if (r_lnors_spacearr) {
|
||||
r_lnors_spacearr->spaces_num = single_corners.size() + fan_corners.size();
|
||||
lnor_spaces = static_cast<MLoopNorSpace *>(BLI_memarena_calloc(
|
||||
r_lnors_spacearr->mem, sizeof(MLoopNorSpace) * r_lnors_spacearr->spaces_num));
|
||||
if (r_lnors_spacearr->spaces_num > 0) {
|
||||
lnor_spaces = static_cast<MLoopNorSpace *>(BLI_memarena_calloc(
|
||||
r_lnors_spacearr->mem, sizeof(MLoopNorSpace) * r_lnors_spacearr->spaces_num));
|
||||
}
|
||||
}
|
||||
|
||||
threading::parallel_for(single_corners.index_range(), 1024, [&](const IndexRange range) {
|
||||
|
|
|
@ -162,7 +162,7 @@ static void mesh_recalc_looptri__single_threaded(const Span<int> corner_verts,
|
|||
const float (*poly_normals)[3])
|
||||
{
|
||||
MemArena *pf_arena = nullptr;
|
||||
uint tri_index = 0;
|
||||
uint looptri_i = 0;
|
||||
|
||||
if (poly_normals != nullptr) {
|
||||
for (const int64_t i : polys.index_range()) {
|
||||
|
@ -170,17 +170,17 @@ static void mesh_recalc_looptri__single_threaded(const Span<int> corner_verts,
|
|||
polys,
|
||||
positions,
|
||||
uint(i),
|
||||
&mlooptri[tri_index],
|
||||
&mlooptri[looptri_i],
|
||||
&pf_arena,
|
||||
poly_normals[i]);
|
||||
tri_index += uint(polys[i].size() - 2);
|
||||
looptri_i += uint(polys[i].size() - 2);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (const int64_t i : polys.index_range()) {
|
||||
mesh_calc_tessellation_for_face(
|
||||
corner_verts, polys, positions, uint(i), &mlooptri[tri_index], &pf_arena);
|
||||
tri_index += uint(polys[i].size() - 2);
|
||||
corner_verts, polys, positions, uint(i), &mlooptri[looptri_i], &pf_arena);
|
||||
looptri_i += uint(polys[i].size() - 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -188,7 +188,7 @@ static void mesh_recalc_looptri__single_threaded(const Span<int> corner_verts,
|
|||
BLI_memarena_free(pf_arena);
|
||||
pf_arena = nullptr;
|
||||
}
|
||||
BLI_assert(tri_index == uint(poly_to_tri_count(int(polys.size()), int(corner_verts.size()))));
|
||||
BLI_assert(looptri_i == uint(poly_to_tri_count(int(polys.size()), int(corner_verts.size()))));
|
||||
}
|
||||
|
||||
struct TessellationUserData {
|
||||
|
@ -213,12 +213,12 @@ static void mesh_calc_tessellation_for_face_fn(void *__restrict userdata,
|
|||
{
|
||||
const TessellationUserData *data = static_cast<const TessellationUserData *>(userdata);
|
||||
TessellationUserTLS *tls_data = static_cast<TessellationUserTLS *>(tls->userdata_chunk);
|
||||
const int tri_index = poly_to_tri_count(index, int(data->polys[index].start()));
|
||||
const int looptri_i = poly_to_tri_count(index, int(data->polys[index].start()));
|
||||
mesh_calc_tessellation_for_face_impl(data->corner_verts,
|
||||
data->polys,
|
||||
data->positions,
|
||||
uint(index),
|
||||
&data->mlooptri[tri_index],
|
||||
&data->mlooptri[looptri_i],
|
||||
&tls_data->pf_arena,
|
||||
false,
|
||||
nullptr);
|
||||
|
@ -230,12 +230,12 @@ static void mesh_calc_tessellation_for_face_with_normal_fn(void *__restrict user
|
|||
{
|
||||
const TessellationUserData *data = static_cast<const TessellationUserData *>(userdata);
|
||||
TessellationUserTLS *tls_data = static_cast<TessellationUserTLS *>(tls->userdata_chunk);
|
||||
const int tri_index = poly_to_tri_count(index, int(data->polys[index].start()));
|
||||
const int looptri_i = poly_to_tri_count(index, int(data->polys[index].start()));
|
||||
mesh_calc_tessellation_for_face_impl(data->corner_verts,
|
||||
data->polys,
|
||||
data->positions,
|
||||
uint(index),
|
||||
&data->mlooptri[tri_index],
|
||||
&data->mlooptri[looptri_i],
|
||||
&tls_data->pf_arena,
|
||||
true,
|
||||
data->poly_normals[index]);
|
||||
|
|
|
@ -137,7 +137,7 @@ static ModifierData *modifier_allocate_and_init(ModifierType type)
|
|||
ModifierData *md = static_cast<ModifierData *>(MEM_callocN(mti->structSize, mti->structName));
|
||||
|
||||
/* NOTE: this name must be made unique later. */
|
||||
BLI_strncpy(md->name, DATA_(mti->name), sizeof(md->name));
|
||||
STRNCPY(md->name, DATA_(mti->name));
|
||||
|
||||
md->type = type;
|
||||
md->mode = eModifierMode_Realtime | eModifierMode_Render;
|
||||
|
@ -329,7 +329,7 @@ ModifierData *BKE_modifier_copy_ex(const ModifierData *md, int flag)
|
|||
{
|
||||
ModifierData *md_dst = modifier_allocate_and_init(ModifierType(md->type));
|
||||
|
||||
BLI_strncpy(md_dst->name, md->name, sizeof(md_dst->name));
|
||||
STRNCPY(md_dst->name, md->name);
|
||||
BKE_modifier_copydata_ex(md, md_dst, flag);
|
||||
|
||||
return md_dst;
|
||||
|
|
|
@ -518,10 +518,10 @@ static void get_proxy_filepath(const MovieClip *clip,
|
|||
BLI_path_split_dir_file(clip->filepath, clipdir, FILE_MAX, clipfile, FILE_MAX);
|
||||
|
||||
if (clip->flag & MCLIP_USE_PROXY_CUSTOM_DIR) {
|
||||
BLI_strncpy(dir, clip->proxy.dir, sizeof(dir));
|
||||
STRNCPY(dir, clip->proxy.dir);
|
||||
}
|
||||
else {
|
||||
BLI_snprintf(dir, sizeof(dir), "%s" SEP_STR "BL_proxy", clipdir);
|
||||
SNPRINTF(dir, "%s" SEP_STR "BL_proxy", clipdir);
|
||||
}
|
||||
|
||||
if (undistorted) {
|
||||
|
@ -671,7 +671,7 @@ static void movieclip_open_anim_file(MovieClip *clip)
|
|||
char str[FILE_MAX];
|
||||
|
||||
if (!clip->anim) {
|
||||
BLI_strncpy(str, clip->filepath, FILE_MAX);
|
||||
STRNCPY(str, clip->filepath);
|
||||
BLI_path_abs(str, ID_BLEND_PATH_FROM_GLOBAL(&clip->id));
|
||||
|
||||
/* FIXME: make several stream accessible in image editor, too */
|
||||
|
@ -680,7 +680,7 @@ static void movieclip_open_anim_file(MovieClip *clip)
|
|||
if (clip->anim) {
|
||||
if (clip->flag & MCLIP_USE_PROXY_CUSTOM_DIR) {
|
||||
char dir[FILE_MAX];
|
||||
BLI_strncpy(dir, clip->proxy.dir, sizeof(dir));
|
||||
STRNCPY(dir, clip->proxy.dir);
|
||||
BLI_path_abs(dir, BKE_main_blendfile_path_from_global());
|
||||
IMB_anim_set_index_dir(clip->anim, dir);
|
||||
}
|
||||
|
@ -935,7 +935,7 @@ static bool put_imbuf_cache(
|
|||
struct MovieCache *moviecache;
|
||||
|
||||
// char cache_name[64];
|
||||
// BLI_snprintf(cache_name, sizeof(cache_name), "movie %s", clip->id.name);
|
||||
// SNPRINTF(cache_name, "movie %s", clip->id.name);
|
||||
|
||||
clip->cache = MEM_callocN(sizeof(MovieClipCache), "movieClipCache");
|
||||
|
||||
|
@ -1018,7 +1018,7 @@ static void detect_clip_source(Main *bmain, MovieClip *clip)
|
|||
ImBuf *ibuf;
|
||||
char filepath[FILE_MAX];
|
||||
|
||||
BLI_strncpy(filepath, clip->filepath, sizeof(filepath));
|
||||
STRNCPY(filepath, clip->filepath);
|
||||
BLI_path_abs(filepath, BKE_main_blendfile_path(bmain));
|
||||
|
||||
ibuf = IMB_testiffname(filepath, IB_rect | IB_multilayer);
|
||||
|
@ -1037,7 +1037,7 @@ MovieClip *BKE_movieclip_file_add(Main *bmain, const char *filepath)
|
|||
int file;
|
||||
char str[FILE_MAX];
|
||||
|
||||
BLI_strncpy(str, filepath, sizeof(str));
|
||||
STRNCPY(str, filepath);
|
||||
BLI_path_abs(str, BKE_main_blendfile_path(bmain));
|
||||
|
||||
/* exists? */
|
||||
|
@ -1051,7 +1051,7 @@ MovieClip *BKE_movieclip_file_add(Main *bmain, const char *filepath)
|
|||
|
||||
/* create a short library name */
|
||||
clip = movieclip_alloc(bmain, BLI_path_basename(filepath));
|
||||
BLI_strncpy(clip->filepath, filepath, sizeof(clip->filepath));
|
||||
STRNCPY(clip->filepath, filepath);
|
||||
|
||||
detect_clip_source(bmain, clip);
|
||||
|
||||
|
@ -1072,12 +1072,12 @@ MovieClip *BKE_movieclip_file_add_exists_ex(Main *bmain, const char *filepath, b
|
|||
MovieClip *clip;
|
||||
char str[FILE_MAX], strtest[FILE_MAX];
|
||||
|
||||
BLI_strncpy(str, filepath, sizeof(str));
|
||||
STRNCPY(str, filepath);
|
||||
BLI_path_abs(str, BKE_main_blendfile_path(bmain));
|
||||
|
||||
/* first search an identical filepath */
|
||||
for (clip = bmain->movieclips.first; clip; clip = clip->id.next) {
|
||||
BLI_strncpy(strtest, clip->filepath, sizeof(clip->filepath));
|
||||
STRNCPY(strtest, clip->filepath);
|
||||
BLI_path_abs(strtest, ID_BLEND_PATH(bmain, &clip->id));
|
||||
|
||||
if (BLI_path_cmp(strtest, str) == 0) {
|
||||
|
|
|
@ -517,7 +517,7 @@ NlaStrip *BKE_nlastack_add_strip(AnimData *adt, bAction *act, const bool is_libo
|
|||
nlt = BKE_nlatrack_new_tail(&adt->nla_tracks, is_liboverride);
|
||||
BKE_nlatrack_set_active(&adt->nla_tracks, nlt);
|
||||
BKE_nlatrack_add_strip(nlt, strip, is_liboverride);
|
||||
BLI_strncpy(nlt->name, act->id.name + 2, sizeof(nlt->name));
|
||||
STRNCPY(nlt->name, act->id.name + 2);
|
||||
}
|
||||
|
||||
/* automatically name it too */
|
||||
|
@ -1798,18 +1798,16 @@ void BKE_nlastrip_validate_name(AnimData *adt, NlaStrip *strip)
|
|||
if (strip->name[0] == 0) {
|
||||
switch (strip->type) {
|
||||
case NLASTRIP_TYPE_CLIP: /* act-clip */
|
||||
BLI_strncpy(strip->name,
|
||||
(strip->act) ? (strip->act->id.name + 2) : ("<No Action>"),
|
||||
sizeof(strip->name));
|
||||
STRNCPY(strip->name, (strip->act) ? (strip->act->id.name + 2) : ("<No Action>"));
|
||||
break;
|
||||
case NLASTRIP_TYPE_TRANSITION: /* transition */
|
||||
BLI_strncpy(strip->name, "Transition", sizeof(strip->name));
|
||||
STRNCPY(strip->name, "Transition");
|
||||
break;
|
||||
case NLASTRIP_TYPE_META: /* meta */
|
||||
BLI_strncpy(strip->name, "Meta", sizeof(strip->name));
|
||||
STRNCPY(strip->name, "Meta");
|
||||
break;
|
||||
default:
|
||||
BLI_strncpy(strip->name, "NLA Strip", sizeof(strip->name));
|
||||
STRNCPY(strip->name, "NLA Strip");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -2066,7 +2064,7 @@ bool BKE_nla_action_stash(AnimData *adt, const bool is_liboverride)
|
|||
BLI_addhead(&adt->nla_tracks, nlt);
|
||||
}
|
||||
|
||||
BLI_strncpy(nlt->name, STASH_TRACK_NAME, sizeof(nlt->name));
|
||||
STRNCPY(nlt->name, STASH_TRACK_NAME);
|
||||
BLI_uniquename(
|
||||
&adt->nla_tracks, nlt, STASH_TRACK_NAME, '.', offsetof(NlaTrack, name), sizeof(nlt->name));
|
||||
|
||||
|
|
|
@ -1159,7 +1159,7 @@ static void node_init(const bContext *C, bNodeTree *ntree, bNode *node)
|
|||
* Data have their own translation option!
|
||||
* This solution may be a bit rougher than nodeLabel()'s returned string, but it's simpler
|
||||
* than adding "do_translate" flags to this func (and labelfunc() as well). */
|
||||
BLI_strncpy(node->name, DATA_(ntype->ui_name), NODE_MAXSTR);
|
||||
STRNCPY(node->name, DATA_(ntype->ui_name));
|
||||
nodeUniqueName(ntree, node);
|
||||
|
||||
/* Generally sockets should be added after the initialization, because the set of sockets might
|
||||
|
@ -1596,11 +1596,11 @@ static bNodeSocket *make_socket(bNodeTree *ntree,
|
|||
|
||||
if (identifier && identifier[0] != '\0') {
|
||||
/* use explicit identifier */
|
||||
BLI_strncpy(auto_identifier, identifier, sizeof(auto_identifier));
|
||||
STRNCPY(auto_identifier, identifier);
|
||||
}
|
||||
else {
|
||||
/* if no explicit identifier is given, assign a unique identifier based on the name */
|
||||
BLI_strncpy(auto_identifier, name, sizeof(auto_identifier));
|
||||
STRNCPY(auto_identifier, name);
|
||||
}
|
||||
/* Make the identifier unique. */
|
||||
BLI_uniquename_cb(
|
||||
|
@ -1610,15 +1610,15 @@ static bNodeSocket *make_socket(bNodeTree *ntree,
|
|||
sock->runtime = MEM_new<bNodeSocketRuntime>(__func__);
|
||||
sock->in_out = in_out;
|
||||
|
||||
BLI_strncpy(sock->identifier, auto_identifier, NODE_MAXSTR);
|
||||
STRNCPY(sock->identifier, auto_identifier);
|
||||
sock->limit = (in_out == SOCK_IN ? 1 : 0xFFF);
|
||||
|
||||
BLI_strncpy(sock->name, name, NODE_MAXSTR);
|
||||
STRNCPY(sock->name, name);
|
||||
sock->storage = nullptr;
|
||||
sock->flag |= SOCK_COLLAPSED;
|
||||
sock->type = SOCK_CUSTOM; /* int type undefined by default */
|
||||
|
||||
BLI_strncpy(sock->idname, idname, sizeof(sock->idname));
|
||||
STRNCPY(sock->idname, idname);
|
||||
node_socket_set_typeinfo(ntree, sock, nodeSocketTypeFind(idname));
|
||||
|
||||
return sock;
|
||||
|
@ -1772,7 +1772,7 @@ void nodeModifySocketType(bNodeTree *ntree,
|
|||
}
|
||||
}
|
||||
|
||||
BLI_strncpy(sock->idname, idname, sizeof(sock->idname));
|
||||
STRNCPY(sock->idname, idname);
|
||||
node_socket_set_typeinfo(ntree, sock, socktype);
|
||||
}
|
||||
|
||||
|
@ -2327,7 +2327,7 @@ bNode *nodeAddNode(const bContext *C, bNodeTree *ntree, const char *idname)
|
|||
BLI_addtail(&ntree->nodes, node);
|
||||
nodeUniqueID(ntree, node);
|
||||
|
||||
BLI_strncpy(node->idname, idname, sizeof(node->idname));
|
||||
STRNCPY(node->idname, idname);
|
||||
node_set_typeinfo(C, ntree, node, nodeTypeFind(idname));
|
||||
|
||||
BKE_ntree_update_tag_node_new(ntree, node);
|
||||
|
@ -2898,7 +2898,7 @@ static bNodeTree *ntreeAddTree_do(
|
|||
BLI_assert(owner_id == nullptr);
|
||||
}
|
||||
|
||||
BLI_strncpy(ntree->idname, idname, sizeof(ntree->idname));
|
||||
STRNCPY(ntree->idname, idname);
|
||||
ntree_set_typeinfo(ntree, ntreeTypeFind(idname));
|
||||
|
||||
return ntree;
|
||||
|
@ -3283,7 +3283,7 @@ void nodeRemoveNode(Main *bmain, bNodeTree *ntree, bNode *node, const bool do_id
|
|||
char prefix[MAX_IDPROP_NAME * 2];
|
||||
|
||||
BLI_str_escape(propname_esc, node->name, sizeof(propname_esc));
|
||||
BLI_snprintf(prefix, sizeof(prefix), "nodes[\"%s\"]", propname_esc);
|
||||
SNPRINTF(prefix, "nodes[\"%s\"]", propname_esc);
|
||||
|
||||
if (BKE_animdata_fix_paths_remove(&ntree->id, prefix)) {
|
||||
if (bmain != nullptr) {
|
||||
|
@ -3538,7 +3538,7 @@ static bNodeSocket *make_socket_interface(bNodeTree *ntree,
|
|||
|
||||
bNodeSocket *sock = MEM_cnew<bNodeSocket>("socket template");
|
||||
sock->runtime = MEM_new<bNodeSocketRuntime>(__func__);
|
||||
BLI_strncpy(sock->idname, stype->idname, sizeof(sock->idname));
|
||||
STRNCPY(sock->idname, stype->idname);
|
||||
sock->in_out = int(in_out);
|
||||
sock->type = int(SOCK_CUSTOM); /* int type undefined by default */
|
||||
node_socket_set_typeinfo(ntree, sock, stype);
|
||||
|
@ -3547,15 +3547,15 @@ static bNodeSocket *make_socket_interface(bNodeTree *ntree,
|
|||
const int own_index = ntree->cur_index++;
|
||||
/* use the own_index as socket identifier */
|
||||
if (in_out == SOCK_IN) {
|
||||
BLI_snprintf(sock->identifier, MAX_NAME, "Input_%d", own_index);
|
||||
SNPRINTF(sock->identifier, "Input_%d", own_index);
|
||||
}
|
||||
else {
|
||||
BLI_snprintf(sock->identifier, MAX_NAME, "Output_%d", own_index);
|
||||
SNPRINTF(sock->identifier, "Output_%d", own_index);
|
||||
}
|
||||
|
||||
sock->limit = (in_out == SOCK_IN ? 1 : 0xFFF);
|
||||
|
||||
BLI_strncpy(sock->name, name, NODE_MAXSTR);
|
||||
STRNCPY(sock->name, name);
|
||||
sock->storage = nullptr;
|
||||
sock->flag |= SOCK_COLLAPSED;
|
||||
|
||||
|
@ -4158,7 +4158,7 @@ void node_type_base(bNodeType *ntype, const int type, const char *name, const sh
|
|||
*/
|
||||
#define DefNode(Category, ID, DefFunc, EnumName, StructName, UIName, UIDesc) \
|
||||
case ID: \
|
||||
BLI_strncpy(ntype->idname, #Category #StructName, sizeof(ntype->idname)); \
|
||||
STRNCPY(ntype->idname, #Category #StructName); \
|
||||
ntype->rna_ext.srna = RNA_struct_find(#Category #StructName); \
|
||||
BLI_assert(ntype->rna_ext.srna != nullptr); \
|
||||
RNA_struct_blender_type_set(ntype->rna_ext.srna, ntype); \
|
||||
|
@ -4172,7 +4172,7 @@ void node_type_base(bNodeType *ntype, const int type, const char *name, const sh
|
|||
BLI_assert(ntype->idname[0] != '\0');
|
||||
|
||||
ntype->type = type;
|
||||
BLI_strncpy(ntype->ui_name, name, sizeof(ntype->ui_name));
|
||||
STRNCPY(ntype->ui_name, name);
|
||||
ntype->nclass = nclass;
|
||||
|
||||
node_type_base_defaults(ntype);
|
||||
|
@ -4186,9 +4186,9 @@ void node_type_base_custom(bNodeType *ntype,
|
|||
const char *name,
|
||||
const short nclass)
|
||||
{
|
||||
BLI_strncpy(ntype->idname, idname, sizeof(ntype->idname));
|
||||
STRNCPY(ntype->idname, idname);
|
||||
ntype->type = NODE_CUSTOM;
|
||||
BLI_strncpy(ntype->ui_name, name, sizeof(ntype->ui_name));
|
||||
STRNCPY(ntype->ui_name, name);
|
||||
ntype->nclass = nclass;
|
||||
|
||||
node_type_base_defaults(ntype);
|
||||
|
@ -4247,7 +4247,7 @@ void node_type_socket_templates(bNodeType *ntype,
|
|||
}
|
||||
|
||||
for (bNodeSocketTemplate *ntemp = inputs; ntemp->type >= 0; ntemp++) {
|
||||
BLI_strncpy(ntemp->identifier, ntemp->name, sizeof(ntemp->identifier));
|
||||
STRNCPY(ntemp->identifier, ntemp->name);
|
||||
unique_socket_template_identifier(inputs, ntemp, ntemp->identifier, '_');
|
||||
}
|
||||
}
|
||||
|
@ -4258,7 +4258,7 @@ void node_type_socket_templates(bNodeType *ntype,
|
|||
}
|
||||
|
||||
for (bNodeSocketTemplate *ntemp = outputs; ntemp->type >= 0; ntemp++) {
|
||||
BLI_strncpy(ntemp->identifier, ntemp->name, sizeof(ntemp->identifier));
|
||||
STRNCPY(ntemp->identifier, ntemp->name);
|
||||
unique_socket_template_identifier(outputs, ntemp, ntemp->identifier, '_');
|
||||
}
|
||||
}
|
||||
|
@ -4302,7 +4302,7 @@ void node_type_storage(bNodeType *ntype,
|
|||
const bNode *src_node))
|
||||
{
|
||||
if (storagename) {
|
||||
BLI_strncpy(ntype->storagename, storagename, sizeof(ntype->storagename));
|
||||
STRNCPY(ntype->storagename, storagename);
|
||||
}
|
||||
else {
|
||||
ntype->storagename[0] = '\0';
|
||||
|
|
|
@ -216,7 +216,7 @@ static void object_copy_data(Main *bmain, ID *id_dst, const ID *id_src, const in
|
|||
BLI_listbase_clear(&ob_dst->shader_fx);
|
||||
LISTBASE_FOREACH (ShaderFxData *, fx, &ob_src->shader_fx) {
|
||||
ShaderFxData *nfx = BKE_shaderfx_new(fx->type);
|
||||
BLI_strncpy(nfx->name, fx->name, sizeof(nfx->name));
|
||||
STRNCPY(nfx->name, fx->name);
|
||||
BKE_shaderfx_copydata_ex(fx, nfx, flag_subdata);
|
||||
BLI_addtail(&ob_dst->shader_fx, nfx);
|
||||
}
|
||||
|
@ -1574,7 +1574,7 @@ bool BKE_object_copy_modifier(
|
|||
else {
|
||||
md_dst = BKE_modifier_new(md_src->type);
|
||||
|
||||
BLI_strncpy(md_dst->name, md_src->name, sizeof(md_dst->name));
|
||||
STRNCPY(md_dst->name, md_src->name);
|
||||
|
||||
if (md_src->type == eModifierType_Multires) {
|
||||
/* Has to be done after mod creation, but *before* we actually copy its settings! */
|
||||
|
@ -1618,7 +1618,7 @@ bool BKE_object_copy_gpencil_modifier(struct Object *ob_dst, GpencilModifierData
|
|||
BLI_assert(ob_dst->type == OB_GPENCIL_LEGACY);
|
||||
|
||||
GpencilModifierData *gmd_dst = BKE_gpencil_modifier_new(gmd_src->type);
|
||||
BLI_strncpy(gmd_dst->name, gmd_src->name, sizeof(gmd_dst->name));
|
||||
STRNCPY(gmd_dst->name, gmd_src->name);
|
||||
|
||||
const GpencilModifierTypeInfo *mti = BKE_gpencil_modifier_get_info(
|
||||
(GpencilModifierType)gmd_src->type);
|
||||
|
@ -1663,7 +1663,7 @@ bool BKE_object_modifier_stack_copy(Object *ob_dst,
|
|||
|
||||
LISTBASE_FOREACH (GpencilModifierData *, gmd_src, &ob_src->greasepencil_modifiers) {
|
||||
GpencilModifierData *gmd_dst = BKE_gpencil_modifier_new(gmd_src->type);
|
||||
BLI_strncpy(gmd_dst->name, gmd_src->name, sizeof(gmd_dst->name));
|
||||
STRNCPY(gmd_dst->name, gmd_src->name);
|
||||
BKE_gpencil_modifier_copydata_ex(gmd_src, gmd_dst, flag_subdata);
|
||||
BLI_addtail(&ob_dst->greasepencil_modifiers, gmd_dst);
|
||||
}
|
||||
|
@ -3595,7 +3595,7 @@ void BKE_object_workob_calc_parent(Depsgraph *depsgraph, Scene *scene, Object *o
|
|||
* object's local loc/rot/scale instead of after. For example, a "Copy Rotation" constraint would
|
||||
* rotate the object's local translation as well. See #82156. */
|
||||
|
||||
BLI_strncpy(workob->parsubstr, ob->parsubstr, sizeof(workob->parsubstr));
|
||||
STRNCPY(workob->parsubstr, ob->parsubstr);
|
||||
|
||||
BKE_object_where_is_calc(depsgraph, scene, workob);
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ bFaceMap *BKE_object_facemap_add_name(Object *ob, const char *name)
|
|||
|
||||
fmap = MEM_callocN(sizeof(bFaceMap), __func__);
|
||||
|
||||
BLI_strncpy(fmap->name, name, sizeof(fmap->name));
|
||||
STRNCPY(fmap->name, name);
|
||||
|
||||
BLI_addtail(&ob->fmaps, fmap);
|
||||
|
||||
|
|
|
@ -191,7 +191,7 @@ PackedFile *BKE_packedfile_new(ReportList *reports, const char *filepath_rel, co
|
|||
|
||||
/* convert relative filenames to absolute filenames */
|
||||
|
||||
BLI_strncpy(filepath, filepath_rel, sizeof(filepath));
|
||||
STRNCPY(filepath, filepath_rel);
|
||||
BLI_path_abs(filepath, basepath);
|
||||
|
||||
/* open the file
|
||||
|
@ -299,12 +299,12 @@ int BKE_packedfile_write_to_file(ReportList *reports,
|
|||
if (guimode) {
|
||||
} // XXX waitcursor(1);
|
||||
|
||||
BLI_strncpy(filepath, filepath_rel, sizeof(filepath));
|
||||
STRNCPY(filepath, filepath_rel);
|
||||
BLI_path_abs(filepath, ref_file_name);
|
||||
|
||||
if (BLI_exists(filepath)) {
|
||||
for (number = 1; number <= 999; number++) {
|
||||
BLI_snprintf(filepath_temp, sizeof(filepath_temp), "%s.%03d_", filepath, number);
|
||||
SNPRINTF(filepath_temp, "%s.%03d_", filepath, number);
|
||||
if (!BLI_exists(filepath_temp)) {
|
||||
if (BLI_copy(filepath, filepath_temp) == RET_OK) {
|
||||
remove_tmp = true;
|
||||
|
@ -365,7 +365,7 @@ enum ePF_FileCompare BKE_packedfile_compare_to_file(const char *ref_file_name,
|
|||
char buf[4096];
|
||||
char filepath[FILE_MAX];
|
||||
|
||||
BLI_strncpy(filepath, filepath_rel, sizeof(filepath));
|
||||
STRNCPY(filepath, filepath_rel);
|
||||
BLI_path_abs(filepath, ref_file_name);
|
||||
|
||||
if (BLI_stat(filepath, &st) == -1) {
|
||||
|
@ -429,7 +429,7 @@ char *BKE_packedfile_unpack_to_file(ReportList *reports,
|
|||
case PF_USE_LOCAL: {
|
||||
char temp_abs[FILE_MAX];
|
||||
|
||||
BLI_strncpy(temp_abs, local_name, sizeof(temp_abs));
|
||||
STRNCPY(temp_abs, local_name);
|
||||
BLI_path_abs(temp_abs, ref_file_name);
|
||||
|
||||
/* if file exists use it */
|
||||
|
@ -448,7 +448,7 @@ char *BKE_packedfile_unpack_to_file(ReportList *reports,
|
|||
case PF_USE_ORIGINAL: {
|
||||
char temp_abs[FILE_MAX];
|
||||
|
||||
BLI_strncpy(temp_abs, abs_name, sizeof(temp_abs));
|
||||
STRNCPY(temp_abs, abs_name);
|
||||
BLI_path_abs(temp_abs, ref_file_name);
|
||||
|
||||
/* if file exists use it */
|
||||
|
@ -494,7 +494,7 @@ static void unpack_generate_paths(const char *filepath,
|
|||
|
||||
if (temp_filename[0] == '\0') {
|
||||
/* NOTE: we generally do not have any real way to re-create extension out of data. */
|
||||
const size_t len = BLI_strncpy_rlen(temp_filename, id->name + 2, sizeof(temp_filename));
|
||||
const size_t len = STRNCPY_RLEN(temp_filename, id->name + 2);
|
||||
printf("%s\n", temp_filename);
|
||||
|
||||
/* For images ensure that the temporary filename contains tile number information as well as
|
||||
|
@ -507,7 +507,7 @@ static void unpack_generate_paths(const char *filepath,
|
|||
enum eImbFileType ftype = IMB_ispic_type_from_memory((const uchar *)pf->data, pf->size);
|
||||
if (ima->source == IMA_SRC_TILED) {
|
||||
char tile_number[6];
|
||||
BLI_snprintf(tile_number, sizeof(tile_number), ".%d", imapf->tile_number);
|
||||
SNPRINTF(tile_number, ".%d", imapf->tile_number);
|
||||
BLI_strncpy(temp_filename + len, tile_number, sizeof(temp_filename) - len);
|
||||
}
|
||||
if (ftype != IMB_FTYPE_NONE) {
|
||||
|
@ -523,7 +523,7 @@ static void unpack_generate_paths(const char *filepath,
|
|||
|
||||
if (temp_dirname[0] == '\0') {
|
||||
/* Fallback to relative dir. */
|
||||
BLI_strncpy(temp_dirname, "//", sizeof(temp_dirname));
|
||||
STRNCPY(temp_dirname, "//");
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -589,7 +589,7 @@ int BKE_packedfile_unpack_vfont(Main *bmain,
|
|||
ret_value = RET_OK;
|
||||
BKE_packedfile_free(vfont->packedfile);
|
||||
vfont->packedfile = NULL;
|
||||
BLI_strncpy(vfont->filepath, new_file_path, sizeof(vfont->filepath));
|
||||
STRNCPY(vfont->filepath, new_file_path);
|
||||
MEM_freeN(new_file_path);
|
||||
}
|
||||
}
|
||||
|
@ -608,7 +608,7 @@ int BKE_packedfile_unpack_sound(Main *bmain,
|
|||
char *new_file_path = BKE_packedfile_unpack(
|
||||
bmain, reports, (ID *)sound, sound->filepath, sound->packedfile, how);
|
||||
if (new_file_path != NULL) {
|
||||
BLI_strncpy(sound->filepath, new_file_path, sizeof(sound->filepath));
|
||||
STRNCPY(sound->filepath, new_file_path);
|
||||
MEM_freeN(new_file_path);
|
||||
|
||||
BKE_packedfile_free(sound->packedfile);
|
||||
|
@ -646,12 +646,12 @@ int BKE_packedfile_unpack_image(Main *bmain,
|
|||
/* update the new corresponding view filepath */
|
||||
iv = BLI_findstring(&ima->views, imapf->filepath, offsetof(ImageView, filepath));
|
||||
if (iv) {
|
||||
BLI_strncpy(iv->filepath, new_file_path, sizeof(imapf->filepath));
|
||||
STRNCPY(iv->filepath, new_file_path);
|
||||
}
|
||||
|
||||
/* keep the new name in the image for non-pack specific reasons */
|
||||
if (how != PF_REMOVE) {
|
||||
BLI_strncpy(ima->filepath, new_file_path, sizeof(imapf->filepath));
|
||||
STRNCPY(ima->filepath, new_file_path);
|
||||
if (ima->source == IMA_SRC_TILED) {
|
||||
/* Ensure that the Image filepath is kept in a tokenized format. */
|
||||
BKE_image_ensure_tile_token(ima->filepath, sizeof(ima->filepath));
|
||||
|
@ -686,7 +686,7 @@ int BKE_packedfile_unpack_volume(Main *bmain,
|
|||
char *new_file_path = BKE_packedfile_unpack(
|
||||
bmain, reports, (ID *)volume, volume->filepath, volume->packedfile, how);
|
||||
if (new_file_path != NULL) {
|
||||
BLI_strncpy(volume->filepath, new_file_path, sizeof(volume->filepath));
|
||||
STRNCPY(volume->filepath, new_file_path);
|
||||
MEM_freeN(new_file_path);
|
||||
|
||||
BKE_packedfile_free(volume->packedfile);
|
||||
|
|
|
@ -1660,7 +1660,7 @@ static void sculpt_update_persistent_base(Object *ob)
|
|||
}
|
||||
|
||||
static void sculpt_update_object(
|
||||
Depsgraph *depsgraph, Object *ob, Object *ob_eval, bool need_pmap, bool is_paint_tool)
|
||||
Depsgraph *depsgraph, Object *ob, Object *ob_eval, bool /*need_pmap*/, bool is_paint_tool)
|
||||
{
|
||||
Scene *scene = DEG_get_input_scene(depsgraph);
|
||||
Sculpt *sd = scene->toolsettings->sculpt;
|
||||
|
@ -1766,13 +1766,13 @@ static void sculpt_update_object(
|
|||
sculpt_attribute_update_refs(ob);
|
||||
sculpt_update_persistent_base(ob);
|
||||
|
||||
if (need_pmap && ob->type == OB_MESH && !ss->pmap) {
|
||||
if (ob->type == OB_MESH && !ss->pmap) {
|
||||
BKE_mesh_vert_poly_map_create(
|
||||
&ss->pmap, &ss->pmap_mem, me->polys(), me->corner_verts().data(), me->totvert);
|
||||
}
|
||||
|
||||
if (ss->pbvh) {
|
||||
BKE_pbvh_pmap_set(ss->pbvh, ss->pmap);
|
||||
}
|
||||
if (ss->pbvh) {
|
||||
BKE_pbvh_pmap_set(ss->pbvh, ss->pmap);
|
||||
}
|
||||
|
||||
if (ss->deform_modifiers_active) {
|
||||
|
@ -2428,7 +2428,7 @@ static bool sculpt_attribute_create(SculptSession *ss,
|
|||
out->params = *params;
|
||||
out->proptype = proptype;
|
||||
out->domain = domain;
|
||||
BLI_strncpy_utf8(out->name, name, sizeof(out->name));
|
||||
STRNCPY_UTF8(out->name, name);
|
||||
|
||||
/* Force non-CustomData simple_array mode if not PBVH_FACES. */
|
||||
if (pbvhtype == PBVH_GRIDS || (pbvhtype == PBVH_BMESH && flat_array_for_bmesh)) {
|
||||
|
@ -2696,7 +2696,7 @@ SculptAttribute *BKE_sculpt_attribute_get(struct Object *ob,
|
|||
attr->layer = cdata->layers + index;
|
||||
attr->elem_size = CustomData_get_elem_size(attr->layer);
|
||||
|
||||
BLI_strncpy_utf8(attr->name, name, sizeof(attr->name));
|
||||
STRNCPY_UTF8(attr->name, name);
|
||||
return attr;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4020,7 +4020,7 @@ static ModifierData *object_add_or_copy_particle_system(
|
|||
psys->part = BKE_particlesettings_add(bmain, DATA_("ParticleSettings"));
|
||||
}
|
||||
md = BKE_modifier_new(eModifierType_ParticleSystem);
|
||||
BLI_strncpy(md->name, psys->name, sizeof(md->name));
|
||||
STRNCPY(md->name, psys->name);
|
||||
BKE_modifier_unique_name(&ob->modifiers, md);
|
||||
|
||||
psmd = (ParticleSystemModifierData *)md;
|
||||
|
|
|
@ -11,10 +11,13 @@
|
|||
#include "BLI_bitmap.h"
|
||||
#include "BLI_ghash.h"
|
||||
#include "BLI_math.h"
|
||||
#include "BLI_math_vector.hh"
|
||||
#include "BLI_rand.h"
|
||||
#include "BLI_task.h"
|
||||
#include "BLI_task.hh"
|
||||
#include "BLI_utildefines.h"
|
||||
#include "BLI_vector.hh"
|
||||
#include "BLI_vector_set.hh"
|
||||
|
||||
#include "DNA_mesh_types.h"
|
||||
#include "DNA_meshdata_types.h"
|
||||
|
@ -199,10 +202,10 @@ static int partition_indices_faces(int *prim_indices,
|
|||
int i1 = lo, i2 = 0;
|
||||
|
||||
while (i1 < hi) {
|
||||
int poly = looptri_polys[prim_scratch[i2]];
|
||||
const int poly_i = looptri_polys[prim_scratch[i2]];
|
||||
bool side = prim_bbc[prim_scratch[i2]].bcentroid[axis] >= mid;
|
||||
|
||||
while (i1 < hi && looptri_polys[prim_scratch[i2]] == poly) {
|
||||
while (i1 < hi && looptri_polys[prim_scratch[i2]] == poly_i) {
|
||||
prim_indices[side ? hi2-- : lo2++] = prim_scratch[i2];
|
||||
i1++;
|
||||
i2++;
|
||||
|
@ -229,10 +232,10 @@ static int partition_indices_grids(int *prim_indices,
|
|||
int i1 = lo, i2 = 0;
|
||||
|
||||
while (i1 < hi) {
|
||||
int poly = BKE_subdiv_ccg_grid_to_face_index(subdiv_ccg, prim_scratch[i2]);
|
||||
int poly_i = BKE_subdiv_ccg_grid_to_face_index(subdiv_ccg, prim_scratch[i2]);
|
||||
bool side = prim_bbc[prim_scratch[i2]].bcentroid[axis] >= mid;
|
||||
|
||||
while (i1 < hi && BKE_subdiv_ccg_grid_to_face_index(subdiv_ccg, prim_scratch[i2]) == poly) {
|
||||
while (i1 < hi && BKE_subdiv_ccg_grid_to_face_index(subdiv_ccg, prim_scratch[i2]) == poly_i) {
|
||||
prim_indices[side ? hi2-- : lo2++] = prim_scratch[i2];
|
||||
i1++;
|
||||
i2++;
|
||||
|
@ -513,21 +516,21 @@ static void test_face_boundaries(PBVH *pbvh)
|
|||
switch (BKE_pbvh_type(pbvh)) {
|
||||
case PBVH_FACES: {
|
||||
for (int j = 0; j < node->totprim; j++) {
|
||||
int poly = pbvh->looptri_polys[node->prim_indices[j]];
|
||||
int poly_i = pbvh->looptri_polys[node->prim_indices[j]];
|
||||
|
||||
if (node_map[poly] >= 0 && node_map[poly] != i) {
|
||||
int old_i = node_map[poly];
|
||||
if (node_map[poly_i] >= 0 && node_map[poly_i] != i) {
|
||||
int old_i = node_map[poly_i];
|
||||
int prim_i = node->prim_indices - pbvh->prim_indices + j;
|
||||
|
||||
printf("PBVH split error; poly: %d, prim_i: %d, node1: %d, node2: %d, totprim: %d\n",
|
||||
poly,
|
||||
poly_i,
|
||||
prim_i,
|
||||
old_i,
|
||||
i,
|
||||
node->totprim);
|
||||
}
|
||||
|
||||
node_map[poly] = i;
|
||||
node_map[poly_i] = i;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -791,16 +794,16 @@ static void pbvh_validate_node_prims(PBVH *pbvh)
|
|||
}
|
||||
|
||||
for (int j = 0; j < node->totprim; j++) {
|
||||
int poly;
|
||||
int poly_i;
|
||||
|
||||
if (pbvh->header.type == PBVH_FACES) {
|
||||
poly = pbvh->looptri_polys[node->prim_indices[j]];
|
||||
poly_i = pbvh->looptri_polys[node->prim_indices[j]];
|
||||
}
|
||||
else {
|
||||
poly = BKE_subdiv_ccg_grid_to_face_index(pbvh->subdiv_ccg, node->prim_indices[j]);
|
||||
poly_i = BKE_subdiv_ccg_grid_to_face_index(pbvh->subdiv_ccg, node->prim_indices[j]);
|
||||
}
|
||||
|
||||
totface = max_ii(totface, poly + 1);
|
||||
totface = max_ii(totface, poly_i + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -818,23 +821,23 @@ static void pbvh_validate_node_prims(PBVH *pbvh)
|
|||
}
|
||||
|
||||
for (int j = 0; j < node->totprim; j++) {
|
||||
int poly;
|
||||
int poly_i;
|
||||
|
||||
if (pbvh->header.type == PBVH_FACES) {
|
||||
poly = pbvh->looptri_polys[node->prim_indices[j]];
|
||||
poly_i = pbvh->looptri_polys[node->prim_indices[j]];
|
||||
}
|
||||
else {
|
||||
poly = BKE_subdiv_ccg_grid_to_face_index(pbvh->subdiv_ccg, node->prim_indices[j]);
|
||||
poly_i = BKE_subdiv_ccg_grid_to_face_index(pbvh->subdiv_ccg, node->prim_indices[j]);
|
||||
}
|
||||
|
||||
if (facemap[poly] != -1 && facemap[poly] != i) {
|
||||
if (facemap[poly_i] != -1 && facemap[poly_i] != i) {
|
||||
printf("%s: error: face spanned multiple nodes (old: %d new: %d)\n",
|
||||
__func__,
|
||||
facemap[poly],
|
||||
facemap[poly_i],
|
||||
i);
|
||||
}
|
||||
|
||||
facemap[poly] = i;
|
||||
facemap[poly_i] = i;
|
||||
}
|
||||
}
|
||||
MEM_SAFE_FREE(facemap);
|
||||
|
@ -862,7 +865,10 @@ void BKE_pbvh_update_mesh_pointers(PBVH *pbvh, Mesh *mesh)
|
|||
|
||||
/* Make sure cached normals start out calculated. */
|
||||
mesh->vert_normals();
|
||||
mesh->poly_normals();
|
||||
|
||||
pbvh->vert_normals = BKE_mesh_vert_normals_for_write(mesh);
|
||||
pbvh->poly_normals = mesh->runtime->poly_normals;
|
||||
|
||||
pbvh->vdata = &mesh->vdata;
|
||||
pbvh->ldata = &mesh->ldata;
|
||||
|
@ -1367,7 +1373,6 @@ struct PBVHUpdateData {
|
|||
PBVH *pbvh;
|
||||
Span<PBVHNode *> nodes;
|
||||
|
||||
float (*vert_normals)[3] = nullptr;
|
||||
int flag = 0;
|
||||
bool show_sculpt_face_sets = false;
|
||||
PBVHAttrReq *attrs = nullptr;
|
||||
|
@ -1376,133 +1381,66 @@ struct PBVHUpdateData {
|
|||
PBVHUpdateData(PBVH *pbvh_, Span<PBVHNode *> nodes_) : pbvh(pbvh_), nodes(nodes_) {}
|
||||
};
|
||||
|
||||
static void pbvh_update_normals_clear_task_cb(void *__restrict userdata,
|
||||
const int n,
|
||||
const TaskParallelTLS *__restrict /*tls*/)
|
||||
{
|
||||
PBVHUpdateData *data = static_cast<PBVHUpdateData *>(userdata);
|
||||
PBVH *pbvh = data->pbvh;
|
||||
PBVHNode *node = data->nodes[n];
|
||||
float(*vert_normals)[3] = data->vert_normals;
|
||||
|
||||
if (node->flag & PBVH_UpdateNormals) {
|
||||
const int *verts = node->vert_indices;
|
||||
const int totvert = node->uniq_verts;
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
const int v = verts[i];
|
||||
if (pbvh->vert_bitmap[v]) {
|
||||
zero_v3(vert_normals[v]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void pbvh_update_normals_accum_task_cb(void *__restrict userdata,
|
||||
const int n,
|
||||
const TaskParallelTLS *__restrict /*tls*/)
|
||||
{
|
||||
PBVHUpdateData *data = static_cast<PBVHUpdateData *>(userdata);
|
||||
|
||||
PBVH *pbvh = data->pbvh;
|
||||
PBVHNode *node = data->nodes[n];
|
||||
float(*vert_normals)[3] = data->vert_normals;
|
||||
|
||||
if (node->flag & PBVH_UpdateNormals) {
|
||||
uint mpoly_prev = UINT_MAX;
|
||||
blender::float3 fn;
|
||||
|
||||
const int *faces = node->prim_indices;
|
||||
const int totface = node->totprim;
|
||||
|
||||
for (int i = 0; i < totface; i++) {
|
||||
const int tri_index = faces[i];
|
||||
const int poly_index = pbvh->looptri_polys[tri_index];
|
||||
const MLoopTri *lt = &pbvh->looptri[faces[i]];
|
||||
const int vtri[3] = {
|
||||
pbvh->corner_verts[lt->tri[0]],
|
||||
pbvh->corner_verts[lt->tri[1]],
|
||||
pbvh->corner_verts[lt->tri[2]],
|
||||
};
|
||||
const int sides = 3;
|
||||
|
||||
/* Face normal and mask */
|
||||
if (poly_index != mpoly_prev) {
|
||||
const blender::IndexRange poly = pbvh->polys[poly_index];
|
||||
fn = blender::bke::mesh::poly_normal_calc(
|
||||
{reinterpret_cast<const blender::float3 *>(pbvh->vert_positions), pbvh->totvert},
|
||||
{&pbvh->corner_verts[poly.start()], poly.size()});
|
||||
mpoly_prev = poly_index;
|
||||
}
|
||||
|
||||
for (int j = sides; j--;) {
|
||||
const int v = vtri[j];
|
||||
|
||||
if (pbvh->vert_bitmap[v]) {
|
||||
/* NOTE: This avoids `lock, add_v3_v3, unlock`
|
||||
* and is five to ten times quicker than a spin-lock.
|
||||
* Not exact equivalent though, since atomicity is only ensured for one component
|
||||
* of the vector at a time, but here it shall not make any sensible difference. */
|
||||
for (int k = 3; k--;) {
|
||||
atomic_add_and_fetch_fl(&vert_normals[v][k], fn[k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void pbvh_update_normals_store_task_cb(void *__restrict userdata,
|
||||
const int n,
|
||||
const TaskParallelTLS *__restrict /*tls*/)
|
||||
{
|
||||
PBVHUpdateData *data = static_cast<PBVHUpdateData *>(userdata);
|
||||
PBVH *pbvh = data->pbvh;
|
||||
PBVHNode *node = data->nodes[n];
|
||||
float(*vert_normals)[3] = data->vert_normals;
|
||||
|
||||
if (node->flag & PBVH_UpdateNormals) {
|
||||
const int *verts = node->vert_indices;
|
||||
const int totvert = node->uniq_verts;
|
||||
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
const int v = verts[i];
|
||||
|
||||
/* No atomics necessary because we are iterating over uniq_verts only,
|
||||
* so we know only this thread will handle this vertex. */
|
||||
if (pbvh->vert_bitmap[v]) {
|
||||
normalize_v3(vert_normals[v]);
|
||||
pbvh->vert_bitmap[v] = false;
|
||||
}
|
||||
}
|
||||
|
||||
node->flag &= ~PBVH_UpdateNormals;
|
||||
}
|
||||
}
|
||||
|
||||
static void pbvh_faces_update_normals(PBVH *pbvh, Span<PBVHNode *> nodes)
|
||||
{
|
||||
/* subtle assumptions:
|
||||
* - We know that for all edited vertices, the nodes with faces
|
||||
* adjacent to these vertices have been marked with PBVH_UpdateNormals.
|
||||
* This is true because if the vertex is inside the brush radius, the
|
||||
* bounding box of its adjacent faces will be as well.
|
||||
* - However this is only true for the vertices that have actually been
|
||||
* edited, not for all vertices in the nodes marked for update, so we
|
||||
* can only update vertices marked in the `vert_bitmap`.
|
||||
*/
|
||||
using namespace blender;
|
||||
using namespace blender::bke;
|
||||
const Span<float3> positions(reinterpret_cast<const float3 *>(pbvh->vert_positions),
|
||||
pbvh->totvert);
|
||||
const OffsetIndices polys = pbvh->polys;
|
||||
const Span<int> corner_verts(pbvh->corner_verts, pbvh->mesh->totloop);
|
||||
|
||||
PBVHUpdateData data(pbvh, nodes);
|
||||
data.pbvh = pbvh;
|
||||
data.nodes = nodes;
|
||||
data.vert_normals = pbvh->vert_normals;
|
||||
MutableSpan<bool> update_tags(pbvh->vert_bitmap, pbvh->totvert);
|
||||
|
||||
TaskParallelSettings settings;
|
||||
BKE_pbvh_parallel_range_settings(&settings, true, nodes.size());
|
||||
VectorSet<int> polys_to_update;
|
||||
for (const PBVHNode *node : nodes) {
|
||||
for (const int vert : Span(node->vert_indices, node->uniq_verts)) {
|
||||
if (update_tags[vert]) {
|
||||
polys_to_update.add_multiple({pbvh->pmap[vert].indices, pbvh->pmap[vert].count});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Zero normals before accumulation. */
|
||||
BLI_task_parallel_range(0, nodes.size(), &data, pbvh_update_normals_clear_task_cb, &settings);
|
||||
BLI_task_parallel_range(0, nodes.size(), &data, pbvh_update_normals_accum_task_cb, &settings);
|
||||
BLI_task_parallel_range(0, nodes.size(), &data, pbvh_update_normals_store_task_cb, &settings);
|
||||
if (polys_to_update.is_empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
MutableSpan<float3> vert_normals(reinterpret_cast<float3 *>(pbvh->vert_normals), pbvh->totvert);
|
||||
MutableSpan<float3> poly_normals = pbvh->poly_normals;
|
||||
|
||||
VectorSet<int> verts_to_update;
|
||||
threading::parallel_invoke(
|
||||
[&]() {
|
||||
threading::parallel_for(polys_to_update.index_range(), 512, [&](const IndexRange range) {
|
||||
for (const int i : polys_to_update.as_span().slice(range)) {
|
||||
poly_normals[i] = mesh::poly_normal_calc(positions, corner_verts.slice(polys[i]));
|
||||
}
|
||||
});
|
||||
},
|
||||
[&]() {
|
||||
/* Update all normals connected to affected faces faces, even if not explicitly tagged. */
|
||||
verts_to_update.reserve(polys_to_update.size());
|
||||
for (const int poly : polys_to_update) {
|
||||
verts_to_update.add_multiple(corner_verts.slice(polys[poly]));
|
||||
}
|
||||
|
||||
for (const int vert : verts_to_update) {
|
||||
update_tags[vert] = false;
|
||||
}
|
||||
for (PBVHNode *node : nodes) {
|
||||
node->flag &= ~PBVH_UpdateNormals;
|
||||
}
|
||||
});
|
||||
|
||||
threading::parallel_for(verts_to_update.index_range(), 1024, [&](const IndexRange range) {
|
||||
for (const int vert : verts_to_update.as_span().slice(range)) {
|
||||
float3 normal(0.0f);
|
||||
for (const int poly : Span(pbvh->pmap[vert].indices, pbvh->pmap[vert].count)) {
|
||||
normal += poly_normals[poly];
|
||||
}
|
||||
vert_normals[vert] = math::normalize(normal);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static void pbvh_update_mask_redraw_task_cb(void *__restrict userdata,
|
||||
|
@ -2532,17 +2470,17 @@ static bool pbvh_faces_node_raycast(PBVH *pbvh,
|
|||
{
|
||||
const float(*positions)[3] = pbvh->vert_positions;
|
||||
const int *corner_verts = pbvh->corner_verts;
|
||||
const int *faces = node->prim_indices;
|
||||
int totface = node->totprim;
|
||||
const int *looptris = node->prim_indices;
|
||||
int looptris_num = node->totprim;
|
||||
bool hit = false;
|
||||
float nearest_vertex_co[3] = {0.0f};
|
||||
|
||||
for (int i = 0; i < totface; i++) {
|
||||
const int tri_index = faces[i];
|
||||
const MLoopTri *lt = &pbvh->looptri[tri_index];
|
||||
for (int i = 0; i < looptris_num; i++) {
|
||||
const int looptri_i = looptris[i];
|
||||
const MLoopTri *lt = &pbvh->looptri[looptri_i];
|
||||
const int *face_verts = node->face_vert_indices[i];
|
||||
|
||||
if (paint_is_face_hidden(pbvh->looptri_polys, pbvh->hide_poly, tri_index)) {
|
||||
if (paint_is_face_hidden(pbvh->looptri_polys, pbvh->hide_poly, looptri_i)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -2578,7 +2516,7 @@ static bool pbvh_faces_node_raycast(PBVH *pbvh,
|
|||
len_squared_v3v3(location, co[j]) < len_squared_v3v3(location, nearest_vertex_co)) {
|
||||
copy_v3_v3(nearest_vertex_co, co[j]);
|
||||
r_active_vertex->i = corner_verts[lt->tri[j]];
|
||||
*r_active_face_index = pbvh->looptri_polys[tri_index];
|
||||
*r_active_face_index = pbvh->looptri_polys[looptri_i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2843,16 +2781,16 @@ static bool pbvh_faces_node_nearest_to_ray(PBVH *pbvh,
|
|||
{
|
||||
const float(*positions)[3] = pbvh->vert_positions;
|
||||
const int *corner_verts = pbvh->corner_verts;
|
||||
const int *faces = node->prim_indices;
|
||||
int i, totface = node->totprim;
|
||||
const int *looptris = node->prim_indices;
|
||||
int i, looptris_num = node->totprim;
|
||||
bool hit = false;
|
||||
|
||||
for (i = 0; i < totface; i++) {
|
||||
const int tri_index = faces[i];
|
||||
const MLoopTri *lt = &pbvh->looptri[tri_index];
|
||||
for (i = 0; i < looptris_num; i++) {
|
||||
const int looptri_i = looptris[i];
|
||||
const MLoopTri *lt = &pbvh->looptri[looptri_i];
|
||||
const int *face_verts = node->face_vert_indices[i];
|
||||
|
||||
if (paint_is_face_hidden(pbvh->looptri_polys, pbvh->hide_poly, tri_index)) {
|
||||
if (paint_is_face_hidden(pbvh->looptri_polys, pbvh->hide_poly, looptri_i)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -3635,15 +3573,15 @@ static void pbvh_face_iter_step(PBVHFaceIter *fd, bool do_step)
|
|||
}
|
||||
case PBVH_GRIDS:
|
||||
case PBVH_FACES: {
|
||||
int face_index = 0;
|
||||
int poly_i = 0;
|
||||
|
||||
if (do_step) {
|
||||
fd->prim_index_++;
|
||||
|
||||
while (fd->prim_index_ < fd->node_->totprim) {
|
||||
face_index = face_iter_prim_to_face(fd, fd->node_->prim_indices[fd->prim_index_]);
|
||||
poly_i = face_iter_prim_to_face(fd, fd->node_->prim_indices[fd->prim_index_]);
|
||||
|
||||
if (face_index != fd->last_face_index_) {
|
||||
if (poly_i != fd->last_poly_index_) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -3651,24 +3589,24 @@ static void pbvh_face_iter_step(PBVHFaceIter *fd, bool do_step)
|
|||
}
|
||||
}
|
||||
else if (fd->prim_index_ < fd->node_->totprim) {
|
||||
face_index = face_iter_prim_to_face(fd, fd->node_->prim_indices[fd->prim_index_]);
|
||||
poly_i = face_iter_prim_to_face(fd, fd->node_->prim_indices[fd->prim_index_]);
|
||||
}
|
||||
|
||||
if (fd->prim_index_ >= fd->node_->totprim) {
|
||||
return;
|
||||
}
|
||||
|
||||
fd->last_face_index_ = face_index;
|
||||
const int poly_start = fd->poly_offsets_[face_index];
|
||||
const int poly_size = fd->poly_offsets_[face_index + 1] - poly_start;
|
||||
fd->last_poly_index_ = poly_i;
|
||||
const int poly_start = fd->poly_offsets_[poly_i];
|
||||
const int poly_size = fd->poly_offsets_[poly_i + 1] - poly_start;
|
||||
|
||||
fd->face.i = fd->index = face_index;
|
||||
fd->face.i = fd->index = poly_i;
|
||||
|
||||
if (fd->face_sets_) {
|
||||
fd->face_set = fd->face_sets_ + face_index;
|
||||
fd->face_set = fd->face_sets_ + poly_i;
|
||||
}
|
||||
if (fd->hide_poly_) {
|
||||
fd->hide = fd->hide_poly_ + face_index;
|
||||
fd->hide = fd->hide_poly_ + poly_i;
|
||||
}
|
||||
|
||||
pbvh_face_iter_verts_reserve(fd, poly_size);
|
||||
|
@ -3715,7 +3653,7 @@ void BKE_pbvh_face_iter_init(PBVH *pbvh, PBVHNode *node, PBVHFaceIter *fd)
|
|||
fd->looptri_polys_ = pbvh->looptri_polys;
|
||||
fd->hide_poly_ = pbvh->hide_poly;
|
||||
fd->face_sets_ = pbvh->face_sets;
|
||||
fd->last_face_index_ = -1;
|
||||
fd->last_poly_index_ = -1;
|
||||
|
||||
break;
|
||||
case PBVH_BMESH:
|
||||
|
@ -3799,8 +3737,8 @@ void BKE_pbvh_sync_visibility_from_verts(PBVH *pbvh, Mesh *mesh)
|
|||
&mesh->pdata, CD_PROP_BOOL, ".hide_poly", mesh->totpoly));
|
||||
|
||||
bool delete_hide_poly = true;
|
||||
for (const int face_index : polys.index_range()) {
|
||||
const blender::IndexRange poly = polys[face_index];
|
||||
for (const int poly_i : polys.index_range()) {
|
||||
const blender::IndexRange poly = polys[poly_i];
|
||||
bool hidden = false;
|
||||
|
||||
for (int loop_index = 0; !hidden && loop_index < poly.size(); loop_index++) {
|
||||
|
@ -3827,7 +3765,7 @@ void BKE_pbvh_sync_visibility_from_verts(PBVH *pbvh, Mesh *mesh)
|
|||
|
||||
if (hide_poly) {
|
||||
delete_hide_poly = delete_hide_poly && !hidden;
|
||||
hide_poly[face_index] = hidden;
|
||||
hide_poly[poly_i] = hidden;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
#pragma once
|
||||
|
||||
#include "BLI_vector.hh"
|
||||
#include "BLI_math_vector_types.hh"
|
||||
#include "BLI_span.hh"
|
||||
|
||||
/** \file
|
||||
* \ingroup bke
|
||||
|
@ -155,6 +157,7 @@ struct PBVH {
|
|||
|
||||
/* NOTE: Normals are not `const` because they can be updated for drawing by sculpt code. */
|
||||
float (*vert_normals)[3];
|
||||
blender::MutableSpan<blender::float3> poly_normals;
|
||||
bool *hide_vert;
|
||||
float (*vert_positions)[3];
|
||||
blender::OffsetIndices<int> polys;
|
||||
|
|
|
@ -1288,7 +1288,7 @@ static int ptcache_frame_from_filename(const char *filename, const char *ext)
|
|||
if (len > ext_len) {
|
||||
/* using frame_len here gives compile error (vla) */
|
||||
char num[/* frame_len */ 6 + 1];
|
||||
BLI_strncpy(num, filename + len - ext_len, sizeof(num));
|
||||
STRNCPY(num, filename + len - ext_len);
|
||||
|
||||
return atoi(num);
|
||||
}
|
||||
|
@ -3503,24 +3503,24 @@ void BKE_ptcache_disk_cache_rename(PTCacheID *pid, const char *name_src, const c
|
|||
}
|
||||
|
||||
/* save old name */
|
||||
BLI_strncpy(old_name, pid->cache->name, sizeof(old_name));
|
||||
STRNCPY(old_name, pid->cache->name);
|
||||
|
||||
/* get "from" filename */
|
||||
BLI_strncpy(pid->cache->name, name_src, sizeof(pid->cache->name));
|
||||
STRNCPY(pid->cache->name, name_src);
|
||||
|
||||
len = ptcache_filepath(pid, old_filepath, 0, false, false); /* no path */
|
||||
|
||||
ptcache_path(pid, path);
|
||||
dir = opendir(path);
|
||||
if (dir == NULL) {
|
||||
BLI_strncpy(pid->cache->name, old_name, sizeof(pid->cache->name));
|
||||
STRNCPY(pid->cache->name, old_name);
|
||||
return;
|
||||
}
|
||||
|
||||
ptcache_filepath_ext_append(pid, ext, 0, false, 0);
|
||||
|
||||
/* put new name into cache */
|
||||
BLI_strncpy(pid->cache->name, name_dst, sizeof(pid->cache->name));
|
||||
STRNCPY(pid->cache->name, name_dst);
|
||||
|
||||
while ((de = readdir(dir)) != NULL) {
|
||||
if (strstr(de->d_name, ext)) { /* Do we have the right extension? */
|
||||
|
@ -3538,7 +3538,7 @@ void BKE_ptcache_disk_cache_rename(PTCacheID *pid, const char *name_src, const c
|
|||
}
|
||||
closedir(dir);
|
||||
|
||||
BLI_strncpy(pid->cache->name, old_name, sizeof(pid->cache->name));
|
||||
STRNCPY(pid->cache->name, old_name);
|
||||
}
|
||||
|
||||
void BKE_ptcache_load_external(PTCacheID *pid)
|
||||
|
@ -3573,10 +3573,10 @@ void BKE_ptcache_load_external(PTCacheID *pid)
|
|||
const char *fext = ptcache_file_extension(pid);
|
||||
|
||||
if (cache->index >= 0) {
|
||||
BLI_snprintf(ext, sizeof(ext), "_%02d%s", cache->index, fext);
|
||||
SNPRINTF(ext, "_%02d%s", cache->index, fext);
|
||||
}
|
||||
else {
|
||||
BLI_strncpy(ext, fext, sizeof(ext));
|
||||
STRNCPY(ext, fext);
|
||||
}
|
||||
|
||||
while ((de = readdir(dir)) != NULL) {
|
||||
|
@ -3674,13 +3674,13 @@ void BKE_ptcache_update_info(PTCacheID *pid)
|
|||
|
||||
/* smoke doesn't use frame 0 as info frame so can't check based on totpoint */
|
||||
if (pid->type == PTCACHE_TYPE_SMOKE_DOMAIN && totframes) {
|
||||
BLI_snprintf(cache->info, sizeof(cache->info), TIP_("%i frames found!"), totframes);
|
||||
SNPRINTF(cache->info, TIP_("%i frames found!"), totframes);
|
||||
}
|
||||
else if (totframes && cache->totpoint) {
|
||||
BLI_snprintf(cache->info, sizeof(cache->info), TIP_("%i points found!"), cache->totpoint);
|
||||
SNPRINTF(cache->info, TIP_("%i points found!"), cache->totpoint);
|
||||
}
|
||||
else {
|
||||
BLI_strncpy(cache->info, TIP_("No valid data to read!"), sizeof(cache->info));
|
||||
STRNCPY(cache->info, TIP_("No valid data to read!"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -3690,11 +3690,10 @@ void BKE_ptcache_update_info(PTCacheID *pid)
|
|||
int totpoint = pid->totpoint(pid->calldata, 0);
|
||||
|
||||
if (cache->totpoint > totpoint) {
|
||||
BLI_snprintf(
|
||||
mem_info, sizeof(mem_info), TIP_("%i cells + High Resolution cached"), totpoint);
|
||||
SNPRINTF(mem_info, TIP_("%i cells + High Resolution cached"), totpoint);
|
||||
}
|
||||
else {
|
||||
BLI_snprintf(mem_info, sizeof(mem_info), TIP_("%i cells cached"), totpoint);
|
||||
SNPRINTF(mem_info, TIP_("%i cells cached"), totpoint);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -3706,7 +3705,7 @@ void BKE_ptcache_update_info(PTCacheID *pid)
|
|||
}
|
||||
}
|
||||
|
||||
BLI_snprintf(mem_info, sizeof(mem_info), TIP_("%i frames on disk"), totframes);
|
||||
SNPRINTF(mem_info, TIP_("%i frames on disk"), totframes);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -3734,25 +3733,17 @@ void BKE_ptcache_update_info(PTCacheID *pid)
|
|||
BLI_str_format_int_grouped(formatted_tot, totframes);
|
||||
BLI_str_format_byte_unit(formatted_mem, bytes, false);
|
||||
|
||||
BLI_snprintf(mem_info,
|
||||
sizeof(mem_info),
|
||||
TIP_("%s frames in memory (%s)"),
|
||||
formatted_tot,
|
||||
formatted_mem);
|
||||
SNPRINTF(mem_info, TIP_("%s frames in memory (%s)"), formatted_tot, formatted_mem);
|
||||
}
|
||||
|
||||
if (cache->flag & PTCACHE_OUTDATED) {
|
||||
BLI_snprintf(cache->info, sizeof(cache->info), TIP_("%s, cache is outdated!"), mem_info);
|
||||
SNPRINTF(cache->info, TIP_("%s, cache is outdated!"), mem_info);
|
||||
}
|
||||
else if (cache->flag & PTCACHE_FRAMES_SKIPPED) {
|
||||
BLI_snprintf(cache->info,
|
||||
sizeof(cache->info),
|
||||
TIP_("%s, not exact since frame %i"),
|
||||
mem_info,
|
||||
cache->last_exact);
|
||||
SNPRINTF(cache->info, TIP_("%s, not exact since frame %i"), mem_info, cache->last_exact);
|
||||
}
|
||||
else {
|
||||
BLI_snprintf(cache->info, sizeof(cache->info), "%s.", mem_info);
|
||||
SNPRINTF(cache->info, "%s.", mem_info);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ bUserAssetLibrary *BKE_preferences_asset_library_add(UserDef *userdef,
|
|||
BKE_preferences_asset_library_name_set(userdef, library, name);
|
||||
}
|
||||
if (path) {
|
||||
BLI_strncpy(library->path, path, sizeof(library->path));
|
||||
STRNCPY(library->path, path);
|
||||
}
|
||||
|
||||
return library;
|
||||
|
@ -61,7 +61,7 @@ void BKE_preferences_asset_library_name_set(UserDef *userdef,
|
|||
bUserAssetLibrary *library,
|
||||
const char *name)
|
||||
{
|
||||
BLI_strncpy_utf8(library->name, name, sizeof(library->name));
|
||||
STRNCPY_UTF8(library->name, name);
|
||||
BLI_uniquename(&userdef->asset_libraries,
|
||||
library,
|
||||
name,
|
||||
|
@ -72,7 +72,7 @@ void BKE_preferences_asset_library_name_set(UserDef *userdef,
|
|||
|
||||
void BKE_preferences_asset_library_path_set(bUserAssetLibrary *library, const char *path)
|
||||
{
|
||||
BLI_strncpy(library->path, path, sizeof(library->path));
|
||||
STRNCPY(library->path, path);
|
||||
if (BLI_is_file(library->path)) {
|
||||
BLI_path_parent_dir(library->path);
|
||||
}
|
||||
|
|
|
@ -154,7 +154,7 @@ static void scene_init_data(ID *id)
|
|||
|
||||
MEMCPY_STRUCT_AFTER(scene, DNA_struct_default_get(Scene), id);
|
||||
|
||||
BLI_strncpy(scene->r.bake.filepath, U.renderdir, sizeof(scene->r.bake.filepath));
|
||||
STRNCPY(scene->r.bake.filepath, U.renderdir);
|
||||
|
||||
mblur_shutter_curve = &scene->r.mblur_shutter_curve;
|
||||
BKE_curvemapping_set_defaults(mblur_shutter_curve, 1, 0.0f, 0.0f, 1.0f, 1.0f);
|
||||
|
@ -203,9 +203,9 @@ static void scene_init_data(ID *id)
|
|||
pset->brush[PE_BRUSH_CUT].strength = 1.0f;
|
||||
}
|
||||
|
||||
BLI_strncpy(scene->r.engine, RE_engine_id_BLENDER_EEVEE, sizeof(scene->r.engine));
|
||||
STRNCPY(scene->r.engine, RE_engine_id_BLENDER_EEVEE);
|
||||
|
||||
BLI_strncpy(scene->r.pic, U.renderdir, sizeof(scene->r.pic));
|
||||
STRNCPY(scene->r.pic, U.renderdir);
|
||||
|
||||
/* NOTE: in header_info.c the scene copy happens...,
|
||||
* if you add more to renderdata it has to be checked there. */
|
||||
|
@ -213,11 +213,11 @@ static void scene_init_data(ID *id)
|
|||
/* multiview - stereo */
|
||||
BKE_scene_add_render_view(scene, STEREO_LEFT_NAME);
|
||||
srv = static_cast<SceneRenderView *>(scene->r.views.first);
|
||||
BLI_strncpy(srv->suffix, STEREO_LEFT_SUFFIX, sizeof(srv->suffix));
|
||||
STRNCPY(srv->suffix, STEREO_LEFT_SUFFIX);
|
||||
|
||||
BKE_scene_add_render_view(scene, STEREO_RIGHT_NAME);
|
||||
srv = static_cast<SceneRenderView *>(scene->r.views.last);
|
||||
BLI_strncpy(srv->suffix, STEREO_RIGHT_SUFFIX, sizeof(srv->suffix));
|
||||
STRNCPY(srv->suffix, STEREO_RIGHT_SUFFIX);
|
||||
|
||||
BKE_sound_reset_scene_runtime(scene);
|
||||
|
||||
|
@ -227,9 +227,7 @@ static void scene_init_data(ID *id)
|
|||
BKE_color_managed_display_settings_init(&scene->display_settings);
|
||||
BKE_color_managed_view_settings_init_render(
|
||||
&scene->view_settings, &scene->display_settings, "Filmic");
|
||||
BLI_strncpy(scene->sequencer_colorspace_settings.name,
|
||||
colorspace_name,
|
||||
sizeof(scene->sequencer_colorspace_settings.name));
|
||||
STRNCPY(scene->sequencer_colorspace_settings.name, colorspace_name);
|
||||
|
||||
BKE_image_format_init(&scene->r.im_format, true);
|
||||
BKE_image_format_init(&scene->r.bake.im_format, true);
|
||||
|
@ -2853,7 +2851,7 @@ SceneRenderView *BKE_scene_add_render_view(Scene *sce, const char *name)
|
|||
}
|
||||
|
||||
SceneRenderView *srv = MEM_cnew<SceneRenderView>(__func__);
|
||||
BLI_strncpy(srv->name, name, sizeof(srv->name));
|
||||
STRNCPY(srv->name, name);
|
||||
BLI_uniquename(&sce->r.views,
|
||||
srv,
|
||||
DATA_("RenderView"),
|
||||
|
@ -3018,14 +3016,12 @@ void BKE_scene_disable_color_management(Scene *scene)
|
|||
|
||||
none_display_name = IMB_colormanagement_display_get_none_name();
|
||||
|
||||
BLI_strncpy(display_settings->display_device,
|
||||
none_display_name,
|
||||
sizeof(display_settings->display_device));
|
||||
STRNCPY(display_settings->display_device, none_display_name);
|
||||
|
||||
view = IMB_colormanagement_view_get_default_name(display_settings->display_device);
|
||||
|
||||
if (view) {
|
||||
BLI_strncpy(view_settings->view_transform, view, sizeof(view_settings->view_transform));
|
||||
STRNCPY(view_settings->view_transform, view);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3303,10 +3299,10 @@ void BKE_scene_multiview_view_filepath_get(const RenderData *rd,
|
|||
srv = static_cast<SceneRenderView *>(
|
||||
BLI_findstring(&rd->views, viewname, offsetof(SceneRenderView, name)));
|
||||
if (srv) {
|
||||
BLI_strncpy(suffix, srv->suffix, sizeof(suffix));
|
||||
STRNCPY(suffix, srv->suffix);
|
||||
}
|
||||
else {
|
||||
BLI_strncpy(suffix, viewname, sizeof(suffix));
|
||||
STRNCPY(suffix, viewname);
|
||||
}
|
||||
|
||||
BLI_strncpy(r_filepath, filepath, FILE_MAX);
|
||||
|
@ -3543,7 +3539,7 @@ static Depsgraph **scene_ensure_depsgraph_p(Main *bmain, Scene *scene, ViewLayer
|
|||
* we will ever enable debug messages for this depsgraph.
|
||||
*/
|
||||
char name[1024];
|
||||
BLI_snprintf(name, sizeof(name), "%s :: %s", scene->id.name, view_layer->name);
|
||||
SNPRINTF(name, "%s :: %s", scene->id.name, view_layer->name);
|
||||
DEG_debug_name_set(*depsgraph_ptr, name);
|
||||
|
||||
/* These viewport depsgraphs communicate changes to the editors. */
|
||||
|
|
|
@ -65,7 +65,7 @@ ShaderFxData *BKE_shaderfx_new(int type)
|
|||
ShaderFxData *fx = MEM_callocN(fxi->struct_size, fxi->struct_name);
|
||||
|
||||
/* NOTE: this name must be made unique later. */
|
||||
BLI_strncpy(fx->name, DATA_(fxi->name), sizeof(fx->name));
|
||||
STRNCPY(fx->name, DATA_(fxi->name));
|
||||
|
||||
fx->type = type;
|
||||
fx->mode = eShaderFxMode_Realtime | eShaderFxMode_Render;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
namespace blender::bke::sim {
|
||||
|
||||
GeometrySimulationStateItem::GeometrySimulationStateItem(GeometrySet geometry)
|
||||
: geometry_(std::move(geometry))
|
||||
: geometry(std::move(geometry))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -59,24 +59,28 @@ void ModifierSimulationCache::try_discover_bake(const StringRefNull meta_dir,
|
|||
|
||||
this->reset();
|
||||
|
||||
for (const int i : IndexRange(dir_entries_num)) {
|
||||
const direntry &dir_entry = dir_entries[i];
|
||||
const StringRefNull dir_entry_path = dir_entry.path;
|
||||
if (!dir_entry_path.endswith(".json")) {
|
||||
continue;
|
||||
{
|
||||
std::lock_guard lock(states_at_frames_mutex_);
|
||||
|
||||
for (const int i : IndexRange(dir_entries_num)) {
|
||||
const direntry &dir_entry = dir_entries[i];
|
||||
const StringRefNull dir_entry_path = dir_entry.path;
|
||||
if (!dir_entry_path.endswith(".json")) {
|
||||
continue;
|
||||
}
|
||||
char modified_file_name[FILENAME_MAX];
|
||||
STRNCPY(modified_file_name, dir_entry.relname);
|
||||
BLI_str_replace_char(modified_file_name, '_', '.');
|
||||
|
||||
const SubFrame frame = std::stof(modified_file_name);
|
||||
|
||||
auto new_state_at_frame = std::make_unique<ModifierSimulationStateAtFrame>();
|
||||
new_state_at_frame->frame = frame;
|
||||
new_state_at_frame->state.bdata_dir_ = bdata_dir;
|
||||
new_state_at_frame->state.meta_path_ = dir_entry.path;
|
||||
new_state_at_frame->state.owner_ = this;
|
||||
states_at_frames_.append(std::move(new_state_at_frame));
|
||||
}
|
||||
char modified_file_name[FILENAME_MAX];
|
||||
BLI_strncpy(modified_file_name, dir_entry.relname, sizeof(modified_file_name));
|
||||
BLI_str_replace_char(modified_file_name, '_', '.');
|
||||
|
||||
const SubFrame frame = std::stof(modified_file_name);
|
||||
|
||||
auto new_state_at_frame = std::make_unique<ModifierSimulationStateAtFrame>();
|
||||
new_state_at_frame->frame = frame;
|
||||
new_state_at_frame->state.bdata_dir_ = bdata_dir;
|
||||
new_state_at_frame->state.meta_path_ = dir_entry.path;
|
||||
new_state_at_frame->state.owner_ = this;
|
||||
states_at_frames_.append(std::move(new_state_at_frame));
|
||||
}
|
||||
|
||||
bdata_sharing_ = std::make_unique<BDataSharing>();
|
||||
|
@ -86,6 +90,7 @@ void ModifierSimulationCache::try_discover_bake(const StringRefNull meta_dir,
|
|||
|
||||
bool ModifierSimulationCache::has_state_at_frame(const SubFrame &frame) const
|
||||
{
|
||||
std::lock_guard lock(states_at_frames_mutex_);
|
||||
for (const auto &item : states_at_frames_) {
|
||||
if (item->frame == frame) {
|
||||
return true;
|
||||
|
@ -96,12 +101,14 @@ bool ModifierSimulationCache::has_state_at_frame(const SubFrame &frame) const
|
|||
|
||||
bool ModifierSimulationCache::has_states() const
|
||||
{
|
||||
std::lock_guard lock(states_at_frames_mutex_);
|
||||
return !states_at_frames_.is_empty();
|
||||
}
|
||||
|
||||
const ModifierSimulationState *ModifierSimulationCache::get_state_at_exact_frame(
|
||||
const SubFrame &frame) const
|
||||
{
|
||||
std::lock_guard lock(states_at_frames_mutex_);
|
||||
for (const auto &item : states_at_frames_) {
|
||||
if (item->frame == frame) {
|
||||
return &item->state;
|
||||
|
@ -113,6 +120,7 @@ const ModifierSimulationState *ModifierSimulationCache::get_state_at_exact_frame
|
|||
ModifierSimulationState &ModifierSimulationCache::get_state_at_frame_for_write(
|
||||
const SubFrame &frame)
|
||||
{
|
||||
std::lock_guard lock(states_at_frames_mutex_);
|
||||
for (const auto &item : states_at_frames_) {
|
||||
if (item->frame == frame) {
|
||||
return item->state;
|
||||
|
@ -126,6 +134,7 @@ ModifierSimulationState &ModifierSimulationCache::get_state_at_frame_for_write(
|
|||
|
||||
StatesAroundFrame ModifierSimulationCache::get_states_around_frame(const SubFrame &frame) const
|
||||
{
|
||||
std::lock_guard lock(states_at_frames_mutex_);
|
||||
StatesAroundFrame states_around_frame;
|
||||
for (const auto &item : states_at_frames_) {
|
||||
if (item->frame < frame) {
|
||||
|
@ -195,6 +204,7 @@ void ModifierSimulationState::ensure_bake_loaded() const
|
|||
|
||||
void ModifierSimulationCache::reset()
|
||||
{
|
||||
std::lock_guard lock(states_at_frames_mutex_);
|
||||
states_at_frames_.clear();
|
||||
bdata_sharing_.reset();
|
||||
cache_state_ = CacheState::Valid;
|
||||
|
|
|
@ -835,8 +835,7 @@ void serialize_modifier_simulation_state(const ModifierSimulationState &state,
|
|||
{
|
||||
io_state_item->append_str("type", "GEOMETRY");
|
||||
|
||||
const GeometrySet &geometry = geometry_state_item->geometry();
|
||||
|
||||
const GeometrySet &geometry = geometry_state_item->geometry;
|
||||
auto io_geometry = serialize_geometry_set(geometry, bdata_writer, bdata_sharing);
|
||||
io_state_item->append("data", io_geometry);
|
||||
}
|
||||
|
|
|
@ -258,11 +258,11 @@ bSound *BKE_sound_new_file(Main *bmain, const char *filepath)
|
|||
const char *blendfile_path = BKE_main_blendfile_path(bmain);
|
||||
char str[FILE_MAX];
|
||||
|
||||
BLI_strncpy(str, filepath, sizeof(str));
|
||||
STRNCPY(str, filepath);
|
||||
BLI_path_abs(str, blendfile_path);
|
||||
|
||||
sound = BKE_libblock_alloc(bmain, ID_SO, BLI_path_basename(filepath), 0);
|
||||
BLI_strncpy(sound->filepath, filepath, FILE_MAX);
|
||||
STRNCPY(sound->filepath, filepath);
|
||||
/* sound->type = SOUND_TYPE_FILE; */ /* XXX unused currently */
|
||||
|
||||
/* Extract sound specs for bSound */
|
||||
|
@ -286,12 +286,12 @@ bSound *BKE_sound_new_file_exists_ex(Main *bmain, const char *filepath, bool *r_
|
|||
bSound *sound;
|
||||
char str[FILE_MAX], strtest[FILE_MAX];
|
||||
|
||||
BLI_strncpy(str, filepath, sizeof(str));
|
||||
STRNCPY(str, filepath);
|
||||
BLI_path_abs(str, BKE_main_blendfile_path(bmain));
|
||||
|
||||
/* first search an identical filepath */
|
||||
for (sound = bmain->sounds.first; sound; sound = sound->id.next) {
|
||||
BLI_strncpy(strtest, sound->filepath, sizeof(sound->filepath));
|
||||
STRNCPY(strtest, sound->filepath);
|
||||
BLI_path_abs(strtest, ID_BLEND_PATH(bmain, &sound->id));
|
||||
|
||||
if (BLI_path_cmp(strtest, str) == 0) {
|
||||
|
@ -551,7 +551,7 @@ static void sound_load_audio(Main *bmain, bSound *sound, bool free_waveform)
|
|||
PackedFile *pf = sound->packedfile;
|
||||
|
||||
/* don't modify soundact->sound->filepath, only change a copy */
|
||||
BLI_strncpy(fullpath, sound->filepath, sizeof(fullpath));
|
||||
STRNCPY(fullpath, sound->filepath);
|
||||
BLI_path_abs(fullpath, ID_BLEND_PATH(bmain, &sound->id));
|
||||
|
||||
/* but we need a packed file then */
|
||||
|
@ -1258,7 +1258,7 @@ bool BKE_sound_stream_info_get(struct Main *main,
|
|||
AUD_StreamInfo *stream_infos;
|
||||
int stream_count;
|
||||
|
||||
BLI_strncpy(str, filepath, sizeof(str));
|
||||
STRNCPY(str, filepath);
|
||||
BLI_path_abs(str, blendfile_path);
|
||||
|
||||
sound = AUD_Sound_file(str);
|
||||
|
|
|
@ -1407,7 +1407,7 @@ void BKE_studiolight_init(void)
|
|||
StudioLight *sl = studiolight_create(
|
||||
STUDIOLIGHT_INTERNAL | STUDIOLIGHT_SPHERICAL_HARMONICS_COEFFICIENTS_CALCULATED |
|
||||
STUDIOLIGHT_TYPE_STUDIO | STUDIOLIGHT_SPECULAR_HIGHLIGHT_PASS);
|
||||
BLI_strncpy(sl->name, "Default", FILE_MAXFILE);
|
||||
STRNCPY(sl->name, "Default");
|
||||
|
||||
BLI_addtail(&studiolights, sl);
|
||||
|
||||
|
|
|
@ -428,7 +428,7 @@ bool BKE_text_reload(Text *text)
|
|||
return false;
|
||||
}
|
||||
|
||||
BLI_strncpy(filepath_abs, text->filepath, FILE_MAX);
|
||||
STRNCPY(filepath_abs, text->filepath);
|
||||
BLI_path_abs(filepath_abs, ID_BLEND_PATH_FROM_GLOBAL(&text->id));
|
||||
|
||||
buffer = BLI_file_read_text_as_mem(filepath_abs, 0, &buffer_len);
|
||||
|
@ -465,7 +465,7 @@ Text *BKE_text_load_ex(Main *bmain,
|
|||
char filepath_abs[FILE_MAX];
|
||||
BLI_stat_t st;
|
||||
|
||||
BLI_strncpy(filepath_abs, filepath, FILE_MAX);
|
||||
STRNCPY(filepath_abs, filepath);
|
||||
BLI_path_abs(filepath_abs, relbase);
|
||||
|
||||
buffer = BLI_file_read_text_as_mem(filepath_abs, 0, &buffer_len);
|
||||
|
@ -537,7 +537,7 @@ int BKE_text_file_modified_check(Text *text)
|
|||
return 0;
|
||||
}
|
||||
|
||||
BLI_strncpy(filepath, text->filepath, FILE_MAX);
|
||||
STRNCPY(filepath, text->filepath);
|
||||
BLI_path_abs(filepath, ID_BLEND_PATH_FROM_GLOBAL(&text->id));
|
||||
|
||||
if (!BLI_exists(filepath)) {
|
||||
|
@ -571,7 +571,7 @@ void BKE_text_file_modified_ignore(Text *text)
|
|||
return;
|
||||
}
|
||||
|
||||
BLI_strncpy(filepath, text->filepath, FILE_MAX);
|
||||
STRNCPY(filepath, text->filepath);
|
||||
BLI_path_abs(filepath, ID_BLEND_PATH_FROM_GLOBAL(&text->id));
|
||||
|
||||
if (!BLI_exists(filepath)) {
|
||||
|
|
|
@ -1902,12 +1902,12 @@ MovieTrackingObject *BKE_tracking_object_add(MovieTracking *tracking, const char
|
|||
|
||||
if (tracking->tot_object == 0) {
|
||||
/* first object is always camera */
|
||||
BLI_strncpy(tracking_object->name, "Camera", sizeof(tracking_object->name));
|
||||
STRNCPY(tracking_object->name, "Camera");
|
||||
|
||||
tracking_object->flag |= TRACKING_OBJECT_CAMERA;
|
||||
}
|
||||
else {
|
||||
BLI_strncpy(tracking_object->name, name, sizeof(tracking_object->name));
|
||||
STRNCPY(tracking_object->name, name);
|
||||
}
|
||||
|
||||
BLI_addtail(&tracking->objects, tracking_object);
|
||||
|
@ -3194,10 +3194,10 @@ static void tracking_dopesheet_channels_calc(MovieTracking *tracking)
|
|||
channel->track = track;
|
||||
|
||||
if (reconstruction->flag & TRACKING_RECONSTRUCTED) {
|
||||
BLI_snprintf(channel->name, sizeof(channel->name), "%s (%.4f)", track->name, track->error);
|
||||
SNPRINTF(channel->name, "%s (%.4f)", track->name, track->error);
|
||||
}
|
||||
else {
|
||||
BLI_strncpy(channel->name, track->name, sizeof(channel->name));
|
||||
STRNCPY(channel->name, track->name);
|
||||
}
|
||||
|
||||
tracking_dopesheet_channels_segments_calc(channel);
|
||||
|
@ -3407,19 +3407,19 @@ MovieTrackingObject *BKE_tracking_find_object_for_plane_track(
|
|||
void BKE_tracking_get_rna_path_for_track(const struct MovieTracking *tracking,
|
||||
const struct MovieTrackingTrack *track,
|
||||
char *rna_path,
|
||||
size_t rna_path_len)
|
||||
size_t rna_path_maxncpy)
|
||||
{
|
||||
MovieTrackingObject *tracking_object = BKE_tracking_find_object_for_track(tracking, track);
|
||||
char track_name_esc[MAX_NAME * 2];
|
||||
BLI_str_escape(track_name_esc, track->name, sizeof(track_name_esc));
|
||||
if (tracking_object == nullptr) {
|
||||
BLI_snprintf(rna_path, rna_path_len, "tracking.tracks[\"%s\"]", track_name_esc);
|
||||
BLI_snprintf(rna_path, rna_path_maxncpy, "tracking.tracks[\"%s\"]", track_name_esc);
|
||||
}
|
||||
else {
|
||||
char object_name_esc[MAX_NAME * 2];
|
||||
BLI_str_escape(object_name_esc, tracking_object->name, sizeof(object_name_esc));
|
||||
BLI_snprintf(rna_path,
|
||||
rna_path_len,
|
||||
rna_path_maxncpy,
|
||||
"tracking.objects[\"%s\"].tracks[\"%s\"]",
|
||||
object_name_esc,
|
||||
track_name_esc);
|
||||
|
@ -3429,36 +3429,36 @@ void BKE_tracking_get_rna_path_for_track(const struct MovieTracking *tracking,
|
|||
void BKE_tracking_get_rna_path_prefix_for_track(const struct MovieTracking *tracking,
|
||||
const struct MovieTrackingTrack *track,
|
||||
char *rna_path,
|
||||
size_t rna_path_len)
|
||||
size_t rna_path_maxncpy)
|
||||
{
|
||||
MovieTrackingObject *tracking_object = BKE_tracking_find_object_for_track(tracking, track);
|
||||
if (tracking_object == nullptr) {
|
||||
BLI_strncpy(rna_path, "tracking.tracks", rna_path_len);
|
||||
BLI_strncpy(rna_path, "tracking.tracks", rna_path_maxncpy);
|
||||
}
|
||||
else {
|
||||
char object_name_esc[MAX_NAME * 2];
|
||||
BLI_str_escape(object_name_esc, tracking_object->name, sizeof(object_name_esc));
|
||||
BLI_snprintf(rna_path, rna_path_len, "tracking.objects[\"%s\"]", object_name_esc);
|
||||
BLI_snprintf(rna_path, rna_path_maxncpy, "tracking.objects[\"%s\"]", object_name_esc);
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_tracking_get_rna_path_for_plane_track(const struct MovieTracking *tracking,
|
||||
const struct MovieTrackingPlaneTrack *plane_track,
|
||||
char *rna_path,
|
||||
size_t rna_path_len)
|
||||
size_t rna_path_maxncpy)
|
||||
{
|
||||
MovieTrackingObject *tracking_object = BKE_tracking_find_object_for_plane_track(tracking,
|
||||
plane_track);
|
||||
char track_name_esc[MAX_NAME * 2];
|
||||
BLI_str_escape(track_name_esc, plane_track->name, sizeof(track_name_esc));
|
||||
if (tracking_object == nullptr) {
|
||||
BLI_snprintf(rna_path, rna_path_len, "tracking.plane_tracks[\"%s\"]", track_name_esc);
|
||||
BLI_snprintf(rna_path, rna_path_maxncpy, "tracking.plane_tracks[\"%s\"]", track_name_esc);
|
||||
}
|
||||
else {
|
||||
char object_name_esc[MAX_NAME * 2];
|
||||
BLI_str_escape(object_name_esc, tracking_object->name, sizeof(object_name_esc));
|
||||
BLI_snprintf(rna_path,
|
||||
rna_path_len,
|
||||
rna_path_maxncpy,
|
||||
"tracking.objects[\"%s\"].plane_tracks[\"%s\"]",
|
||||
object_name_esc,
|
||||
track_name_esc);
|
||||
|
@ -3469,16 +3469,17 @@ void BKE_tracking_get_rna_path_prefix_for_plane_track(
|
|||
const struct MovieTracking *tracking,
|
||||
const struct MovieTrackingPlaneTrack *plane_track,
|
||||
char *rna_path,
|
||||
size_t rna_path_len)
|
||||
size_t rna_path_maxncpy)
|
||||
{
|
||||
MovieTrackingObject *tracking_object = BKE_tracking_find_object_for_plane_track(tracking,
|
||||
plane_track);
|
||||
if (tracking_object == nullptr) {
|
||||
BLI_strncpy(rna_path, "tracking.plane_tracks", rna_path_len);
|
||||
BLI_strncpy(rna_path, "tracking.plane_tracks", rna_path_maxncpy);
|
||||
}
|
||||
else {
|
||||
char object_name_esc[MAX_NAME * 2];
|
||||
BLI_str_escape(object_name_esc, tracking_object->name, sizeof(object_name_esc));
|
||||
BLI_snprintf(rna_path, rna_path_len, "tracking.objects[\"%s\"].plane_tracks", object_name_esc);
|
||||
BLI_snprintf(
|
||||
rna_path, rna_path_maxncpy, "tracking.objects[\"%s\"].plane_tracks", object_name_esc);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -334,7 +334,7 @@ MovieReconstructContext *BKE_tracking_reconstruction_context_new(
|
|||
const int num_tracks = BLI_listbase_count(&tracking_object->tracks);
|
||||
int sfra = INT_MAX, efra = INT_MIN;
|
||||
|
||||
BLI_strncpy(context->object_name, tracking_object->name, sizeof(context->object_name));
|
||||
STRNCPY(context->object_name, tracking_object->name);
|
||||
context->motion_flag = tracking->settings.motion_flag;
|
||||
|
||||
context->select_keyframes = (tracking->settings.reconstruction_flag &
|
||||
|
@ -393,7 +393,7 @@ void BKE_tracking_reconstruction_report_error_message(MovieReconstructContext *c
|
|||
/* Only keep initial error message, the rest are inducted ones. */
|
||||
return;
|
||||
}
|
||||
BLI_strncpy(context->error_message, error_message, sizeof(context->error_message));
|
||||
STRNCPY(context->error_message, error_message);
|
||||
}
|
||||
|
||||
const char *BKE_tracking_reconstruction_error_message_get(const MovieReconstructContext *context)
|
||||
|
|
|
@ -52,7 +52,7 @@ TracksMap *tracks_map_new(const char *object_name, int num_tracks)
|
|||
{
|
||||
TracksMap *map = MEM_cnew<TracksMap>("TrackingsMap");
|
||||
|
||||
BLI_strncpy(map->object_name, object_name, sizeof(map->object_name));
|
||||
STRNCPY(map->object_name, object_name);
|
||||
|
||||
map->num_tracks = num_tracks;
|
||||
|
||||
|
|
|
@ -119,7 +119,7 @@ static void undosys_id_ref_store(void * /*user_data*/, UndoRefID *id_ref)
|
|||
{
|
||||
BLI_assert(id_ref->name[0] == '\0');
|
||||
if (id_ref->ptr) {
|
||||
BLI_strncpy(id_ref->name, id_ref->ptr->name, sizeof(id_ref->name));
|
||||
STRNCPY(id_ref->name, id_ref->ptr->name);
|
||||
/* Not needed, just prevents stale data access. */
|
||||
id_ref->ptr = nullptr;
|
||||
}
|
||||
|
@ -456,7 +456,7 @@ UndoStep *BKE_undosys_step_push_init_with_type(UndoStack *ustack,
|
|||
|
||||
UndoStep *us = static_cast<UndoStep *>(MEM_callocN(ut->step_size, __func__));
|
||||
if (name != nullptr) {
|
||||
BLI_strncpy(us->name, name, sizeof(us->name));
|
||||
STRNCPY(us->name, name);
|
||||
}
|
||||
us->type = ut;
|
||||
ustack->step_init = us;
|
||||
|
@ -541,7 +541,7 @@ eUndoPushReturn BKE_undosys_step_push_with_type(UndoStack *ustack,
|
|||
static_cast<UndoStep *>(MEM_callocN(ut->step_size, __func__));
|
||||
ustack->step_init = nullptr;
|
||||
if (us->name[0] == '\0') {
|
||||
BLI_strncpy(us->name, name, sizeof(us->name));
|
||||
STRNCPY(us->name, name);
|
||||
}
|
||||
us->type = ut;
|
||||
/* True by default, code needs to explicitly set it to false if necessary. */
|
||||
|
|
|
@ -1112,9 +1112,7 @@ bool BKE_unit_replace_string(
|
|||
|
||||
/* Apply the default unit on the whole expression, this allows to handle nasty cases like
|
||||
* '2+2in'. */
|
||||
if (BLI_snprintf(str_tmp, sizeof(str_tmp), "(%s)*%.9g", str, default_unit->scalar) <
|
||||
sizeof(str_tmp))
|
||||
{
|
||||
if (SNPRINTF(str_tmp, "(%s)*%.9g", str, default_unit->scalar) < sizeof(str_tmp)) {
|
||||
strncpy(str, str_tmp, str_maxncpy);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -66,7 +66,7 @@ static void vfont_init_data(ID *id)
|
|||
if (vfd) {
|
||||
vfont->data = vfd;
|
||||
|
||||
BLI_strncpy(vfont->filepath, FO_BUILTIN_NAME, sizeof(vfont->filepath));
|
||||
STRNCPY(vfont->filepath, FO_BUILTIN_NAME);
|
||||
}
|
||||
|
||||
/* Free the packed file */
|
||||
|
@ -321,7 +321,7 @@ VFont *BKE_vfont_load(Main *bmain, const char *filepath)
|
|||
bool is_builtin;
|
||||
|
||||
if (STREQ(filepath, FO_BUILTIN_NAME)) {
|
||||
BLI_strncpy(filename, filepath, sizeof(filename));
|
||||
STRNCPY(filename, filepath);
|
||||
|
||||
pf = get_builtin_packedfile();
|
||||
is_builtin = true;
|
||||
|
@ -341,7 +341,7 @@ VFont *BKE_vfont_load(Main *bmain, const char *filepath)
|
|||
/* If there's a font name, use it for the ID name. */
|
||||
vfont = BKE_libblock_alloc(bmain, ID_VF, vfd->name[0] ? vfd->name : filename, 0);
|
||||
vfont->data = vfd;
|
||||
BLI_strncpy(vfont->filepath, filepath, sizeof(vfont->filepath));
|
||||
STRNCPY(vfont->filepath, filepath);
|
||||
|
||||
/* if auto-pack is on store the packed-file in de font structure */
|
||||
if (!is_builtin && (G.fileflags & G_FILE_AUTOPACK)) {
|
||||
|
@ -368,12 +368,12 @@ VFont *BKE_vfont_load_exists_ex(struct Main *bmain, const char *filepath, bool *
|
|||
VFont *vfont;
|
||||
char str[FILE_MAX], strtest[FILE_MAX];
|
||||
|
||||
BLI_strncpy(str, filepath, sizeof(str));
|
||||
STRNCPY(str, filepath);
|
||||
BLI_path_abs(str, BKE_main_blendfile_path(bmain));
|
||||
|
||||
/* first search an identical filepath */
|
||||
for (vfont = bmain->fonts.first; vfont; vfont = vfont->id.next) {
|
||||
BLI_strncpy(strtest, vfont->filepath, sizeof(vfont->filepath));
|
||||
STRNCPY(strtest, vfont->filepath);
|
||||
BLI_path_abs(strtest, ID_BLEND_PATH(bmain, &vfont->id));
|
||||
|
||||
if (BLI_path_cmp(strtest, str) == 0) {
|
||||
|
|
|
@ -321,7 +321,7 @@ VFontData *BKE_vfontdata_from_freetypefont(PackedFile *pf)
|
|||
|
||||
/* Get the name. */
|
||||
if (face->family_name) {
|
||||
BLI_snprintf(vfd->name, sizeof(vfd->name), "%s %s", face->family_name, face->style_name);
|
||||
SNPRINTF(vfd->name, "%s %s", face->family_name, face->style_name);
|
||||
BLI_str_utf8_invalid_strip(vfd->name, strlen(vfd->name));
|
||||
}
|
||||
|
||||
|
|
|
@ -515,7 +515,7 @@ static void volume_init_data(ID *id)
|
|||
|
||||
BKE_volume_init_grids(volume);
|
||||
|
||||
BLI_strncpy(volume->velocity_grid, "velocity", sizeof(volume->velocity_grid));
|
||||
STRNCPY(volume->velocity_grid, "velocity");
|
||||
}
|
||||
|
||||
static void volume_copy_data(Main * /*bmain*/, ID *id_dst, const ID *id_src, const int /*flag*/)
|
||||
|
@ -793,7 +793,7 @@ bool BKE_volume_set_velocity_grid_by_name(Volume *volume, const char *base_name)
|
|||
const StringRefNull ref_base_name = base_name;
|
||||
|
||||
if (BKE_volume_grid_find_for_read(volume, base_name)) {
|
||||
BLI_strncpy(volume->velocity_grid, base_name, sizeof(volume->velocity_grid));
|
||||
STRNCPY(volume->velocity_grid, base_name);
|
||||
volume->runtime.velocity_x_grid[0] = '\0';
|
||||
volume->runtime.velocity_y_grid[0] = '\0';
|
||||
volume->runtime.velocity_z_grid[0] = '\0';
|
||||
|
@ -818,16 +818,10 @@ bool BKE_volume_set_velocity_grid_by_name(Volume *volume, const char *base_name)
|
|||
}
|
||||
|
||||
/* Save the base name as well. */
|
||||
BLI_strncpy(volume->velocity_grid, base_name, sizeof(volume->velocity_grid));
|
||||
BLI_strncpy(volume->runtime.velocity_x_grid,
|
||||
(ref_base_name + postfix[0]).c_str(),
|
||||
sizeof(volume->runtime.velocity_x_grid));
|
||||
BLI_strncpy(volume->runtime.velocity_y_grid,
|
||||
(ref_base_name + postfix[1]).c_str(),
|
||||
sizeof(volume->runtime.velocity_y_grid));
|
||||
BLI_strncpy(volume->runtime.velocity_z_grid,
|
||||
(ref_base_name + postfix[2]).c_str(),
|
||||
sizeof(volume->runtime.velocity_z_grid));
|
||||
STRNCPY(volume->velocity_grid, base_name);
|
||||
STRNCPY(volume->runtime.velocity_x_grid, (ref_base_name + postfix[0]).c_str());
|
||||
STRNCPY(volume->runtime.velocity_y_grid, (ref_base_name + postfix[1]).c_str());
|
||||
STRNCPY(volume->runtime.velocity_z_grid, (ref_base_name + postfix[2]).c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -224,7 +224,7 @@ static void workspace_layout_name_set(WorkSpace *workspace,
|
|||
WorkSpaceLayout *layout,
|
||||
const char *new_name)
|
||||
{
|
||||
BLI_strncpy(layout->name, new_name, sizeof(layout->name));
|
||||
STRNCPY(layout->name, new_name);
|
||||
BLI_uniquename(&workspace->layouts,
|
||||
layout,
|
||||
"Layout",
|
||||
|
|
|
@ -535,7 +535,7 @@ static const AVCodec *get_av1_encoder(
|
|||
}
|
||||
/* Set gop_size as rav1e's "--keyint". */
|
||||
char buffer[64];
|
||||
BLI_snprintf(buffer, sizeof(buffer), "keyint=%d", context->ffmpeg_gop_size);
|
||||
SNPRINTF(buffer, "keyint=%d", context->ffmpeg_gop_size);
|
||||
av_dict_set(opts, "rav1e-params", buffer, 0);
|
||||
}
|
||||
else if (STREQ(codec->name, "libsvtav1")) {
|
||||
|
@ -1073,7 +1073,7 @@ static void ffmpeg_dict_set_int(AVDictionary **dict, const char *key, int value)
|
|||
{
|
||||
char buffer[32];
|
||||
|
||||
BLI_snprintf(buffer, sizeof(buffer), "%d", value);
|
||||
SNPRINTF(buffer, "%d", value);
|
||||
|
||||
av_dict_set(dict, key, buffer, 0);
|
||||
}
|
||||
|
@ -1391,7 +1391,7 @@ static void ffmpeg_filepath_get(FFMpegContext *context,
|
|||
|
||||
if ((rd->ffcodecdata.flags & FFMPEG_AUTOSPLIT_OUTPUT) != 0) {
|
||||
if (context) {
|
||||
BLI_snprintf(autosplit, sizeof(autosplit), "_%03d", context->ffmpeg_autosplit_count);
|
||||
SNPRINTF(autosplit, "_%03d", context->ffmpeg_autosplit_count);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue