1
1

Merge branch 'master' into sculpt_curve_collisions

This commit is contained in:
2022-08-01 15:29:52 +01:00
303 changed files with 6470 additions and 4512 deletions

View File

@@ -478,7 +478,7 @@ OCIO_FORCE_BUILD=false
OCIO_FORCE_REBUILD=false
OCIO_SKIP=false
IMATH_VERSION="3.1.4"
IMATH_VERSION="3.1.5"
IMATH_VERSION_SHORT="3.1"
IMATH_VERSION_MIN="3.0"
IMATH_VERSION_MEX="4.0"
@@ -487,7 +487,7 @@ IMATH_FORCE_REBUILD=false
IMATH_SKIP=false
_with_built_imath=false
OPENEXR_VERSION="3.1.4"
OPENEXR_VERSION="3.1.5"
OPENEXR_VERSION_SHORT="3.1"
OPENEXR_VERSION_MIN="3.0"
OPENEXR_VERSION_MEX="4.0"
@@ -627,6 +627,9 @@ WEBP_DEV=""
VPX_USE=false
VPX_VERSION_MIN=0.9.7
VPX_DEV=""
AOM_USE=false
AOM_VERSION_MIN=3.3.0
AOM_DEV=""
OPUS_USE=false
OPUS_VERSION_MIN=1.1.1
OPUS_DEV=""
@@ -1209,7 +1212,7 @@ You may also want to build them yourself (optional ones are [between brackets]):
** [NumPy $PYTHON_NUMPY_VERSION] (use pip).
* Boost $BOOST_VERSION (from $BOOST_SOURCE, modules: $BOOST_BUILD_MODULES).
* TBB $TBB_VERSION (from $TBB_SOURCE).
* [FFMpeg $FFMPEG_VERSION (needs libvorbis, libogg, libtheora, libx264, libmp3lame, libxvidcore, libvpx, libwebp, ...)] (from $FFMPEG_SOURCE).
* [FFMpeg $FFMPEG_VERSION (needs libvorbis, libogg, libtheora, libx264, libmp3lame, libxvidcore, libvpx, libaom, libwebp, ...)] (from $FFMPEG_SOURCE).
* [OpenColorIO $OCIO_VERSION] (from $OCIO_SOURCE).
* Imath $IMATH_VERSION (from $IMATH_SOURCE).
* OpenEXR $OPENEXR_VERSION (from $OPENEXR_SOURCE).
@@ -3000,7 +3003,7 @@ compile_ALEMBIC() {
fi
# To be changed each time we make edits that would modify the compiled result!
alembic_magic=2
alembic_magic=3
_init_alembic
# Force having own builds for the dependencies.
@@ -3048,7 +3051,7 @@ compile_ALEMBIC() {
fi
if [ "$_with_built_openexr" = true ]; then
cmake_d="$cmake_d -D USE_ARNOLD=OFF"
cmake_d="$cmake_d -D USE_BINARIES=OFF"
cmake_d="$cmake_d -D USE_BINARIES=ON" # Tests use some Alembic binaries...
cmake_d="$cmake_d -D USE_EXAMPLES=OFF"
cmake_d="$cmake_d -D USE_HDF5=OFF"
cmake_d="$cmake_d -D USE_MAYA=OFF"
@@ -3634,7 +3637,7 @@ compile_FFmpeg() {
fi
# To be changed each time we make edits that would modify the compiled result!
ffmpeg_magic=5
ffmpeg_magic=6
_init_ffmpeg
# Force having own builds for the dependencies.
@@ -3687,6 +3690,10 @@ compile_FFmpeg() {
extra="$extra --enable-libvpx"
fi
if [ "$AOM_USE" = true ]; then
extra="$extra --enable-libaom"
fi
if [ "$WEBP_USE" = true ]; then
extra="$extra --enable-libwebp"
fi
@@ -4140,30 +4147,34 @@ install_DEB() {
WEBP_USE=true
fi
if [ "$WITH_ALL" = true ]; then
XVID_DEV="libxvidcore-dev"
check_package_DEB $XVID_DEV
if [ $? -eq 0 ]; then
XVID_USE=true
fi
XVID_DEV="libxvidcore-dev"
check_package_DEB $XVID_DEV
if [ $? -eq 0 ]; then
XVID_USE=true
fi
MP3LAME_DEV="libmp3lame-dev"
check_package_DEB $MP3LAME_DEV
if [ $? -eq 0 ]; then
MP3LAME_USE=true
fi
MP3LAME_DEV="libmp3lame-dev"
check_package_DEB $MP3LAME_DEV
if [ $? -eq 0 ]; then
MP3LAME_USE=true
fi
VPX_DEV="libvpx-dev"
check_package_version_ge_DEB $VPX_DEV $VPX_VERSION_MIN
if [ $? -eq 0 ]; then
VPX_USE=true
fi
VPX_DEV="libvpx-dev"
check_package_version_ge_DEB $VPX_DEV $VPX_VERSION_MIN
if [ $? -eq 0 ]; then
VPX_USE=true
fi
OPUS_DEV="libopus-dev"
check_package_version_ge_DEB $OPUS_DEV $OPUS_VERSION_MIN
if [ $? -eq 0 ]; then
OPUS_USE=true
fi
AOM_DEV="libaom-dev"
check_package_version_ge_DEB $AOM_DEV $AOM_VERSION_MIN
if [ $? -eq 0 ]; then
AOM_USE=true
fi
OPUS_DEV="libopus-dev"
check_package_version_ge_DEB $OPUS_DEV $OPUS_VERSION_MIN
if [ $? -eq 0 ]; then
OPUS_USE=true
fi
# Check cmake version and disable features for older distros.
@@ -4546,6 +4557,9 @@ install_DEB() {
if [ "$VPX_USE" = true ]; then
_packages="$_packages $VPX_DEV"
fi
if [ "$AOM_USE" = true ]; then
_packages="$_packages $AOM_DEV"
fi
if [ "$OPUS_USE" = true ]; then
_packages="$_packages $OPUS_DEV"
fi
@@ -4846,21 +4860,27 @@ install_RPM() {
WEBP_USE=true
fi
if [ "$WITH_ALL" = true ]; then
VPX_DEV="libvpx-devel"
check_package_version_ge_RPM $VPX_DEV $VPX_VERSION_MIN
if [ $? -eq 0 ]; then
VPX_USE=true
fi
VPX_DEV="libvpx-devel"
check_package_version_ge_RPM $VPX_DEV $VPX_VERSION_MIN
if [ $? -eq 0 ]; then
VPX_USE=true
fi
AOM_DEV="libaom-devel"
check_package_version_ge_RPM $AOM_DEV $AOM_VERSION_MIN
if [ $? -eq 0 ]; then
AOM_USE=true
fi
OPUS_DEV="libopus-devel"
check_package_version_ge_RPM $OPUS_DEV $OPUS_VERSION_MIN
if [ $? -eq 0 ]; then
OPUS_USE=true
fi
if [ "$WITH_ALL" = true ]; then
PRINT ""
install_packages_RPM libspnav-devel
OPUS_DEV="libopus-devel"
check_package_version_ge_RPM $OPUS_DEV $OPUS_VERSION_MIN
if [ $? -eq 0 ]; then
OPUS_USE=true
fi
fi
PRINT ""
@@ -5245,6 +5265,9 @@ install_RPM() {
if [ "$VPX_USE" = true ]; then
_packages="$_packages $VPX_DEV"
fi
if [ "$AOM_USE" = true ]; then
_packages="$_packages $AOM_DEV"
fi
if [ "$OPUS_USE" = true ]; then
_packages="$_packages $OPUS_DEV"
fi
@@ -5434,30 +5457,34 @@ install_ARCH() {
WEBP_USE=true
fi
if [ "$WITH_ALL" = true ]; then
XVID_DEV="xvidcore"
check_package_ARCH $XVID_DEV
if [ $? -eq 0 ]; then
XVID_USE=true
fi
XVID_DEV="xvidcore"
check_package_ARCH $XVID_DEV
if [ $? -eq 0 ]; then
XVID_USE=true
fi
MP3LAME_DEV="lame"
check_package_ARCH $MP3LAME_DEV
if [ $? -eq 0 ]; then
MP3LAME_USE=true
fi
MP3LAME_DEV="lame"
check_package_ARCH $MP3LAME_DEV
if [ $? -eq 0 ]; then
MP3LAME_USE=true
fi
VPX_DEV="libvpx"
check_package_version_ge_ARCH $VPX_DEV $VPX_VERSION_MIN
if [ $? -eq 0 ]; then
VPX_USE=true
fi
VPX_DEV="libvpx"
check_package_version_ge_ARCH $VPX_DEV $VPX_VERSION_MIN
if [ $? -eq 0 ]; then
VPX_USE=true
fi
OPUS_DEV="opus"
check_package_version_ge_ARCH $OPUS_DEV $OPUS_VERSION_MIN
if [ $? -eq 0 ]; then
OPUS_USE=true
fi
AOM_DEV="libaom"
check_package_version_ge_ARCH $AOM_DEV $AOM_VERSION_MIN
if [ $? -eq 0 ]; then
AOM_USE=true
fi
OPUS_DEV="opus"
check_package_version_ge_ARCH $OPUS_DEV $OPUS_VERSION_MIN
if [ $? -eq 0 ]; then
OPUS_USE=true
fi
@@ -5835,6 +5862,9 @@ install_ARCH() {
if [ "$VPX_USE" = true ]; then
_packages="$_packages $VPX_DEV"
fi
if [ "$AOM_USE" = true ]; then
_packages="$_packages $AOM_DEV"
fi
if [ "$OPUS_USE" = true ]; then
_packages="$_packages $OPUS_DEV"
fi

View File

@@ -470,8 +470,9 @@ string(APPEND CMAKE_CXX_FLAGS " -ftemplate-depth=1024")
# Avoid conflicts with Luxrender, and other plug-ins that may use the same
# libraries as Blender with a different version or build options.
set(PLATFORM_SYMBOLS_MAP ${CMAKE_SOURCE_DIR}/source/creator/symbols_apple.map)
string(APPEND PLATFORM_LINKFLAGS
" -Wl,-unexported_symbols_list,'${CMAKE_SOURCE_DIR}/source/creator/osx_locals.map'"
" -Wl,-unexported_symbols_list,'${PLATFORM_SYMBOLS_MAP}'"
)
string(APPEND CMAKE_CXX_FLAGS " -stdlib=libc++")

View File

@@ -888,8 +888,9 @@ unset(_IS_LINKER_DEFAULT)
# Avoid conflicts with Mesa llvmpipe, Luxrender, and other plug-ins that may
# use the same libraries as Blender with a different version or build options.
set(PLATFORM_SYMBOLS_MAP ${CMAKE_SOURCE_DIR}/source/creator/symbols_unix.map)
set(PLATFORM_LINKFLAGS
"${PLATFORM_LINKFLAGS} -Wl,--version-script='${CMAKE_SOURCE_DIR}/source/creator/blender.map'"
"${PLATFORM_LINKFLAGS} -Wl,--version-script='${PLATFORM_SYMBOLS_MAP}'"
)
# Don't use position independent executable for portable install since file

View File

@@ -7,6 +7,7 @@
#include "MEM_guardedalloc.h"
#include "RNA_access.h"
#include "RNA_blender_cpp.h"
#include "RNA_path.h"
#include "RNA_types.h"
#include "blender/id_map.h"

View File

@@ -355,8 +355,6 @@ set(SRC_UTIL_HEADERS
../util/types_uint4.h
../util/types_uint4_impl.h
../util/types_ushort4.h
../util/types_vector3.h
../util/types_vector3_impl.h
)
set(LIB

View File

@@ -33,38 +33,4 @@ CCL_NAMESPACE_BEGIN
#define kernel_assert(cond) assert(cond)
/* Macros to handle different memory storage on different devices */
#ifdef __KERNEL_SSE2__
typedef vector3<sseb> sse3b;
typedef vector3<ssef> sse3f;
typedef vector3<ssei> sse3i;
ccl_device_inline void print_sse3b(const char *label, sse3b &a)
{
print_sseb(label, a.x);
print_sseb(label, a.y);
print_sseb(label, a.z);
}
ccl_device_inline void print_sse3f(const char *label, sse3f &a)
{
print_ssef(label, a.x);
print_ssef(label, a.y);
print_ssef(label, a.z);
}
ccl_device_inline void print_sse3i(const char *label, sse3i &a)
{
print_ssei(label, a.x);
print_ssei(label, a.y);
print_ssei(label, a.z);
}
# if defined(__KERNEL_AVX__) || defined(__KERNEL_AVX2__)
typedef vector3<avxf> avx3f;
# endif
#endif
CCL_NAMESPACE_END

View File

@@ -149,25 +149,13 @@ void oneapi_kernel_##name(KernelGlobalsGPU *ccl_restrict kg, \
/* clang-format on */
/* Types */
/* It's not possible to use sycl types like sycl::float3, sycl::int3, etc
* because these types have different interfaces from blender version */
* because these types have different interfaces from blender version. */
using uchar = unsigned char;
using sycl::half;
struct float3 {
float x, y, z;
};
ccl_always_inline float3 make_float3(float x, float y, float z)
{
return {x, y, z};
}
ccl_always_inline float3 make_float3(float x)
{
return {x, x, x};
}
/* math functions */
#define fabsf(x) sycl::fabs((x))
#define copysignf(x, y) sycl::copysign((x), (y))

View File

@@ -129,8 +129,6 @@ set(SRC_HEADERS
types_uint4.h
types_uint4_impl.h
types_ushort4.h
types_vector3.h
types_vector3_impl.h
unique_ptr.h
vector.h
version.h

View File

@@ -953,7 +953,11 @@ ccl_device_inline uint prev_power_of_two(uint x)
ccl_device_inline uint32_t reverse_integer_bits(uint32_t x)
{
/* Use a native instruction if it exists. */
#if defined(__aarch64__) || defined(_M_ARM64)
#if defined(__KERNEL_CUDA__)
return __brev(x);
#elif defined(__KERNEL_METAL__)
return reverse_bits(x);
#elif defined(__aarch64__) || defined(_M_ARM64)
/* Assume the rbit is always available on 64bit ARM architecture. */
__asm__("rbit %w0, %w1" : "=r"(x) : "r"(x));
return x;
@@ -962,10 +966,6 @@ ccl_device_inline uint32_t reverse_integer_bits(uint32_t x)
* This 32-bit Thumb instruction is available in ARMv6T2 and above. */
__asm__("rbit %0, %1" : "=r"(x) : "r"(x));
return x;
#elif defined(__KERNEL_CUDA__)
return __brev(x);
#elif defined(__KERNEL_METAL__)
return reverse_bits(x);
#elif __has_builtin(__builtin_bitreverse32)
return __builtin_bitreverse32(x);
#else

View File

@@ -12,6 +12,7 @@
#if !defined(__KERNEL_GPU__)
# include <stdint.h>
# include <stdio.h>
#endif
#include "util/defines.h"
@@ -70,6 +71,12 @@ ccl_device_inline bool is_power_of_two(size_t x)
CCL_NAMESPACE_END
/* Most GPU APIs matching native vector types, so we only need to implement them for
* CPU and oneAPI. */
#if defined(__KERNEL_GPU__) && !defined(__KERNEL_ONEAPI__)
# define __KERNEL_NATIVE_VECTOR_TYPES__
#endif
/* Vectorized types declaration. */
#include "util/types_uchar2.h"
#include "util/types_uchar3.h"
@@ -90,8 +97,6 @@ CCL_NAMESPACE_END
#include "util/types_float4.h"
#include "util/types_float8.h"
#include "util/types_vector3.h"
/* Vectorized types implementation. */
#include "util/types_uchar2_impl.h"
#include "util/types_uchar3_impl.h"
@@ -110,8 +115,6 @@ CCL_NAMESPACE_END
#include "util/types_float4_impl.h"
#include "util/types_float8_impl.h"
#include "util/types_vector3_impl.h"
/* SSE types. */
#ifndef __KERNEL_GPU__
# include "util/sseb.h"

View File

@@ -1,8 +1,7 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2011-2022 Blender Foundation */
#ifndef __UTIL_TYPES_FLOAT2_H__
#define __UTIL_TYPES_FLOAT2_H__
#pragma once
#ifndef __UTIL_TYPES_H__
# error "Do not include this file directly, include util/types.h instead."
@@ -10,18 +9,18 @@
CCL_NAMESPACE_BEGIN
#if !defined(__KERNEL_GPU__) || defined(__KERNEL_ONEAPI__)
#ifndef __KERNEL_NATIVE_VECTOR_TYPES__
struct float2 {
float x, y;
# ifndef __KERNEL_GPU__
__forceinline float operator[](int i) const;
__forceinline float &operator[](int i);
# endif
};
ccl_device_inline float2 make_float2(float x, float y);
ccl_device_inline void print_float2(const char *label, const float2 &a);
#endif /* !defined(__KERNEL_GPU__) || defined(__KERNEL_ONEAPI__) */
#endif /* __KERNEL_NATIVE_VECTOR_TYPES__ */
CCL_NAMESPACE_END
#endif /* __UTIL_TYPES_FLOAT2_H__ */

View File

@@ -1,20 +1,16 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2011-2022 Blender Foundation */
#ifndef __UTIL_TYPES_FLOAT2_IMPL_H__
#define __UTIL_TYPES_FLOAT2_IMPL_H__
#pragma once
#ifndef __UTIL_TYPES_H__
# error "Do not include this file directly, include util/types.h instead."
#endif
#ifndef __KERNEL_GPU__
# include <cstdio>
#endif
CCL_NAMESPACE_BEGIN
#if !defined(__KERNEL_GPU__) || defined(__KERNEL_ONEAPI__)
#ifndef __KERNEL_NATIVE_VECTOR_TYPES__
# ifndef __KERNEL_GPU__
__forceinline float float2::operator[](int i) const
{
util_assert(i >= 0);
@@ -28,6 +24,7 @@ __forceinline float &float2::operator[](int i)
util_assert(i < 2);
return *(&x + i);
}
# endif
ccl_device_inline float2 make_float2(float x, float y)
{
@@ -39,8 +36,6 @@ ccl_device_inline void print_float2(const char *label, const float2 &a)
{
printf("%s: %.8f %.8f\n", label, (double)a.x, (double)a.y);
}
#endif /* !defined(__KERNEL_GPU__) || defined(__KERNEL_ONEAPI__) */
#endif /* __KERNEL_NATIVE_VECTOR_TYPES__ */
CCL_NAMESPACE_END
#endif /* __UTIL_TYPES_FLOAT2_IMPL_H__ */

View File

@@ -1,8 +1,7 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2011-2022 Blender Foundation */
#ifndef __UTIL_TYPES_FLOAT3_H__
#define __UTIL_TYPES_FLOAT3_H__
#pragma once
#ifndef __UTIL_TYPES_H__
# error "Do not include this file directly, include util/types.h instead."
@@ -10,17 +9,28 @@
CCL_NAMESPACE_BEGIN
#if !defined(__KERNEL_GPU__)
#ifndef __KERNEL_NATIVE_VECTOR_TYPES__
struct ccl_try_align(16) float3
{
# ifdef __KERNEL_SSE__
# ifdef __KERNEL_GPU__
/* Compact structure for GPU. */
float x, y, z;
# else
/* SIMD aligned structure for CPU. */
# ifdef __KERNEL_SSE__
union {
__m128 m128;
struct {
float x, y, z, w;
};
};
# else
float x, y, z, w;
# endif
# endif
# ifdef __KERNEL_SSE__
/* Convenient constructors and operators for SIMD, otherwise default is enough. */
__forceinline float3();
__forceinline float3(const float3 &a);
__forceinline explicit float3(const __m128 &a);
@@ -29,18 +39,18 @@ struct ccl_try_align(16) float3
__forceinline operator __m128 &();
__forceinline float3 &operator=(const float3 &a);
# else /* __KERNEL_SSE__ */
float x, y, z, w;
# endif /* __KERNEL_SSE__ */
# endif
# ifndef __KERNEL_GPU__
__forceinline float operator[](int i) const;
__forceinline float &operator[](int i);
# endif
};
ccl_device_inline float3 make_float3(float f);
ccl_device_inline float3 make_float3(float x, float y, float z);
ccl_device_inline void print_float3(const char *label, const float3 &a);
#endif /* !defined(__KERNEL_GPU__) */
#endif /* __KERNEL_NATIVE_VECTOR_TYPES__ */
/* Smaller float3 for storage. For math operations this must be converted to float3, so that on the
* CPU SIMD instructions can be used. */
@@ -78,5 +88,3 @@ struct packed_float3 {
static_assert(sizeof(packed_float3) == 12, "packed_float3 expected to be exactly 12 bytes");
CCL_NAMESPACE_END
#endif /* __UTIL_TYPES_FLOAT3_H__ */

View File

@@ -1,20 +1,15 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2011-2022 Blender Foundation */
#ifndef __UTIL_TYPES_FLOAT3_IMPL_H__
#define __UTIL_TYPES_FLOAT3_IMPL_H__
#pragma once
#ifndef __UTIL_TYPES_H__
# error "Do not include this file directly, include util/types.h instead."
#endif
#ifndef __KERNEL_GPU__
# include <cstdio>
#endif
CCL_NAMESPACE_BEGIN
#if !defined(__KERNEL_GPU__)
#ifndef __KERNEL_NATIVE_VECTOR_TYPES__
# ifdef __KERNEL_SSE__
__forceinline float3::float3()
{
@@ -45,6 +40,7 @@ __forceinline float3 &float3::operator=(const float3 &a)
}
# endif /* __KERNEL_SSE__ */
# ifndef __KERNEL_GPU__
__forceinline float float3::operator[](int i) const
{
util_assert(i >= 0);
@@ -58,23 +54,32 @@ __forceinline float &float3::operator[](int i)
util_assert(i < 3);
return *(&x + i);
}
# endif
ccl_device_inline float3 make_float3(float f)
{
# ifdef __KERNEL_SSE__
float3 a(_mm_set1_ps(f));
# ifdef __KERNEL_GPU__
float3 a = {f, f, f};
# else
# ifdef __KERNEL_SSE__
float3 a(_mm_set1_ps(f));
# else
float3 a = {f, f, f, f};
# endif
# endif
return a;
}
ccl_device_inline float3 make_float3(float x, float y, float z)
{
# ifdef __KERNEL_SSE__
float3 a(_mm_set_ps(0.0f, z, y, x));
# ifdef __KERNEL_GPU__
float3 a = {x, y, z};
# else
# ifdef __KERNEL_SSE__
float3 a(_mm_set_ps(0.0f, z, y, x));
# else
float3 a = {x, y, z, 0.0f};
# endif
# endif
return a;
}
@@ -83,8 +88,6 @@ ccl_device_inline void print_float3(const char *label, const float3 &a)
{
printf("%s: %.8f %.8f %.8f\n", label, (double)a.x, (double)a.y, (double)a.z);
}
#endif /* !defined(__KERNEL_GPU__) */
#endif /* __KERNEL_NATIVE_VECTOR_TYPES__ */
CCL_NAMESPACE_END
#endif /* __UTIL_TYPES_FLOAT3_IMPL_H__ */

View File

@@ -1,8 +1,7 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2011-2022 Blender Foundation */
#ifndef __UTIL_TYPES_FLOAT4_H__
#define __UTIL_TYPES_FLOAT4_H__
#pragma once
#ifndef __UTIL_TYPES_H__
# error "Do not include this file directly, include util/types.h instead."
@@ -10,7 +9,7 @@
CCL_NAMESPACE_BEGIN
#if !defined(__KERNEL_GPU__) || defined(__KERNEL_ONEAPI__)
#ifndef __KERNEL_NATIVE_VECTOR_TYPES__
struct int4;
struct ccl_try_align(16) float4
@@ -35,16 +34,16 @@ struct ccl_try_align(16) float4
float x, y, z, w;
# endif /* __KERNEL_SSE__ */
# ifndef __KERNEL_GPU__
__forceinline float operator[](int i) const;
__forceinline float &operator[](int i);
# endif
};
ccl_device_inline float4 make_float4(float f);
ccl_device_inline float4 make_float4(float x, float y, float z, float w);
ccl_device_inline float4 make_float4(const int4 &i);
ccl_device_inline void print_float4(const char *label, const float4 &a);
#endif /* !defined(__KERNEL_GPU__) || defined(__KERNEL_ONEAPI__) */
#endif /* __KERNEL_NATIVE_VECTOR_TYPES__ */
CCL_NAMESPACE_END
#endif /* __UTIL_TYPES_FLOAT4_H__ */

View File

@@ -1,20 +1,15 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2011-2022 Blender Foundation */
#ifndef __UTIL_TYPES_FLOAT4_IMPL_H__
#define __UTIL_TYPES_FLOAT4_IMPL_H__
#pragma once
#ifndef __UTIL_TYPES_H__
# error "Do not include this file directly, include util/types.h instead."
#endif
#ifndef __KERNEL_GPU__
# include <cstdio>
#endif
CCL_NAMESPACE_BEGIN
#if !defined(__KERNEL_GPU__) || defined(__KERNEL_ONEAPI__)
#ifndef __KERNEL_NATIVE_VECTOR_TYPES__
# ifdef __KERNEL_SSE__
__forceinline float4::float4()
{
@@ -41,6 +36,7 @@ __forceinline float4 &float4::operator=(const float4 &a)
}
# endif /* __KERNEL_SSE__ */
# ifndef __KERNEL_GPU__
__forceinline float float4::operator[](int i) const
{
util_assert(i >= 0);
@@ -54,6 +50,7 @@ __forceinline float &float4::operator[](int i)
util_assert(i < 4);
return *(&x + i);
}
# endif
ccl_device_inline float4 make_float4(float f)
{
@@ -89,8 +86,6 @@ ccl_device_inline void print_float4(const char *label, const float4 &a)
{
printf("%s: %.8f %.8f %.8f %.8f\n", label, (double)a.x, (double)a.y, (double)a.z, (double)a.w);
}
#endif /* !defined(__KERNEL_GPU__) || defined(__KERNEL_ONEAPI__) */
#endif /* __KERNEL_NATIVE_VECTOR_TYPES__ */
CCL_NAMESPACE_END
#endif /* __UTIL_TYPES_FLOAT4_IMPL_H__ */

View File

@@ -2,8 +2,7 @@
* Original code Copyright 2017, Intel Corporation
* Modifications Copyright 2018-2022 Blender Foundation. */
#ifndef __UTIL_TYPES_FLOAT8_H__
#define __UTIL_TYPES_FLOAT8_H__
#pragma once
#ifndef __UTIL_TYPES_H__
# error "Do not include this file directly, include util/types.h instead."
@@ -12,7 +11,7 @@
CCL_NAMESPACE_BEGIN
/* float8 is a reserved type in Metal that has not been implemented. For
* that reason this is named float8_t. */
* that reason this is named float8_t and not using native vector types. */
#ifdef __KERNEL_GPU__
struct float8_t
@@ -52,5 +51,3 @@ ccl_device_inline float8_t
make_float8_t(float a, float b, float c, float d, float e, float f, float g, float h);
CCL_NAMESPACE_END
#endif /* __UTIL_TYPES_FLOAT8_H__ */

View File

@@ -2,17 +2,12 @@
* Original code Copyright 2017, Intel Corporation
* Modifications Copyright 2018-2022 Blender Foundation. */
#ifndef __UTIL_TYPES_FLOAT8_IMPL_H__
#define __UTIL_TYPES_FLOAT8_IMPL_H__
#pragma once
#ifndef __UTIL_TYPES_H__
# error "Do not include this file directly, include util/types.h instead."
#endif
#ifndef __KERNEL_GPU__
# include <cstdio>
#endif
CCL_NAMESPACE_BEGIN
#ifdef __KERNEL_AVX2__
@@ -83,5 +78,3 @@ make_float8_t(float a, float b, float c, float d, float e, float f, float g, flo
}
CCL_NAMESPACE_END
#endif /* __UTIL_TYPES_FLOAT8_IMPL_H__ */

View File

@@ -1,8 +1,7 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2011-2022 Blender Foundation */
#ifndef __UTIL_TYPES_INT2_H__
#define __UTIL_TYPES_INT2_H__
#pragma once
#ifndef __UTIL_TYPES_H__
# error "Do not include this file directly, include util/types.h instead."
@@ -10,17 +9,17 @@
CCL_NAMESPACE_BEGIN
#if !defined(__KERNEL_GPU__) || defined(__KERNEL_ONEAPI__)
#ifndef __KERNEL_NATIVE_VECTOR_TYPES__
struct int2 {
int x, y;
# ifndef __KERNEL_GPU__
__forceinline int operator[](int i) const;
__forceinline int &operator[](int i);
# endif
};
ccl_device_inline int2 make_int2(int x, int y);
#endif /* !defined(__KERNEL_GPU__) || defined(__KERNEL_ONEAPI__) */
#endif /* __KERNEL_NATIVE_VECTOR_TYPES__ */
CCL_NAMESPACE_END
#endif /* __UTIL_TYPES_INT2_H__ */

View File

@@ -1,8 +1,7 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2011-2022 Blender Foundation */
#ifndef __UTIL_TYPES_INT2_IMPL_H__
#define __UTIL_TYPES_INT2_IMPL_H__
#pragma once
#ifndef __UTIL_TYPES_H__
# error "Do not include this file directly, include util/types.h instead."
@@ -10,7 +9,8 @@
CCL_NAMESPACE_BEGIN
#if !defined(__KERNEL_GPU__) || defined(__KERNEL_ONEAPI__)
#ifndef __KERNEL_NATIVE_VECTOR_TYPES__
# ifndef __KERNEL_GPU__
int int2::operator[](int i) const
{
util_assert(i >= 0);
@@ -24,14 +24,13 @@ int &int2::operator[](int i)
util_assert(i < 2);
return *(&x + i);
}
# endif
ccl_device_inline int2 make_int2(int x, int y)
{
int2 a = {x, y};
return a;
}
#endif /* !defined(__KERNEL_GPU__) || defined(__KERNEL_ONEAPI__) */
#endif /* __KERNEL_NATIVE_VECTOR_TYPES__ */
CCL_NAMESPACE_END
#endif /* __UTIL_TYPES_INT2_IMPL_H__ */

View File

@@ -1,8 +1,7 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2011-2022 Blender Foundation */
#ifndef __UTIL_TYPES_INT3_H__
#define __UTIL_TYPES_INT3_H__
#pragma once
#ifndef __UTIL_TYPES_H__
# error "Do not include this file directly, include util/types.h instead."
@@ -10,10 +9,15 @@
CCL_NAMESPACE_BEGIN
#if !defined(__KERNEL_GPU__) || defined(__KERNEL_ONEAPI__)
#ifndef __KERNEL_NATIVE_VECTOR_TYPES__
struct ccl_try_align(16) int3
{
# ifdef __KERNEL_SSE__
# ifdef __KERNEL_GPU__
/* Compact structure on the GPU. */
int x, y, z;
# else
/* SIMD aligned structure for CPU. */
# ifdef __KERNEL_SSE__
union {
__m128i m128;
struct {
@@ -29,19 +33,20 @@ struct ccl_try_align(16) int3
__forceinline operator __m128i &();
__forceinline int3 &operator=(const int3 &a);
# else /* __KERNEL_SSE__ */
# else /* __KERNEL_SSE__ */
int x, y, z, w;
# endif /* __KERNEL_SSE__ */
# endif /* __KERNEL_SSE__ */
# endif
# ifndef __KERNEL_GPU__
__forceinline int operator[](int i) const;
__forceinline int &operator[](int i);
# endif
};
ccl_device_inline int3 make_int3(int i);
ccl_device_inline int3 make_int3(int x, int y, int z);
ccl_device_inline void print_int3(const char *label, const int3 &a);
#endif /* !defined(__KERNEL_GPU__) || defined(__KERNEL_ONEAPI__) */
#endif /* __KERNEL_NATIVE_VECTOR_TYPES__ */
CCL_NAMESPACE_END
#endif /* __UTIL_TYPES_INT3_H__ */

View File

@@ -1,20 +1,15 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2011-2022 Blender Foundation */
#ifndef __UTIL_TYPES_INT3_IMPL_H__
#define __UTIL_TYPES_INT3_IMPL_H__
#pragma once
#ifndef __UTIL_TYPES_H__
# error "Do not include this file directly, include util/types.h instead."
#endif
#ifndef __KERNEL_GPU__
# include <cstdio>
#endif
CCL_NAMESPACE_BEGIN
#if !defined(__KERNEL_GPU__) || defined(__KERNEL_ONEAPI__)
#ifndef __KERNEL_NATIVE_VECTOR_TYPES__
# ifdef __KERNEL_SSE__
__forceinline int3::int3()
{
@@ -45,6 +40,7 @@ __forceinline int3 &int3::operator=(const int3 &a)
}
# endif /* __KERNEL_SSE__ */
# ifndef __KERNEL_GPU__
__forceinline int int3::operator[](int i) const
{
util_assert(i >= 0);
@@ -58,25 +54,33 @@ __forceinline int &int3::operator[](int i)
util_assert(i < 3);
return *(&x + i);
}
# endif
ccl_device_inline int3 make_int3(int i)
{
# ifdef __KERNEL_SSE__
int3 a(_mm_set1_epi32(i));
# ifdef __KERNEL_GPU__
int3 a = {i, i, i};
# else
# ifdef __KERNEL_SSE__
int3 a(_mm_set1_epi32(i));
# else
int3 a = {i, i, i, i};
# endif
# endif
return a;
}
ccl_device_inline int3 make_int3(int x, int y, int z)
{
# ifdef __KERNEL_SSE__
int3 a(_mm_set_epi32(0, z, y, x));
# ifdef __KERNEL_GPU__
int3 a = {x, y, z};
# else
# ifdef __KERNEL_SSE__
int3 a(_mm_set_epi32(0, z, y, x));
# else
int3 a = {x, y, z, 0};
# endif
# endif
return a;
}
@@ -84,8 +88,6 @@ ccl_device_inline void print_int3(const char *label, const int3 &a)
{
printf("%s: %d %d %d\n", label, a.x, a.y, a.z);
}
#endif /* !defined(__KERNEL_GPU__) || defined(__KERNEL_ONEAPI__) */
#endif /* __KERNEL_NATIVE_VECTOR_TYPES__ */
CCL_NAMESPACE_END
#endif /* __UTIL_TYPES_INT3_IMPL_H__ */

View File

@@ -1,8 +1,7 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2011-2022 Blender Foundation */
#ifndef __UTIL_TYPES_INT4_H__
#define __UTIL_TYPES_INT4_H__
#pragma once
#ifndef __UTIL_TYPES_H__
# error "Do not include this file directly, include util/types.h instead."
@@ -10,7 +9,7 @@
CCL_NAMESPACE_BEGIN
#if !defined(__KERNEL_GPU__) || defined(__KERNEL_ONEAPI__)
#ifndef __KERNEL_NATIVE_VECTOR_TYPES__
struct float3;
struct float4;
@@ -37,8 +36,10 @@ struct ccl_try_align(16) int4
int x, y, z, w;
# endif /* __KERNEL_SSE__ */
# ifndef __KERNEL_GPU__
__forceinline int operator[](int i) const;
__forceinline int &operator[](int i);
# endif
};
ccl_device_inline int4 make_int4(int i);
@@ -46,8 +47,6 @@ ccl_device_inline int4 make_int4(int x, int y, int z, int w);
ccl_device_inline int4 make_int4(const float3 &f);
ccl_device_inline int4 make_int4(const float4 &f);
ccl_device_inline void print_int4(const char *label, const int4 &a);
#endif /* !defined(__KERNEL_GPU__) || defined(__KERNEL_ONEAPI__) */
#endif /* __KERNEL_NATIVE_VECTOR_TYPES__ */
CCL_NAMESPACE_END
#endif /* __UTIL_TYPES_INT4_H__ */

View File

@@ -1,20 +1,15 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2011-2022 Blender Foundation */
#ifndef __UTIL_TYPES_INT4_IMPL_H__
#define __UTIL_TYPES_INT4_IMPL_H__
#pragma once
#ifndef __UTIL_TYPES_H__
# error "Do not include this file directly, include util/types.h instead."
#endif
#ifndef __KERNEL_GPU__
# include <cstdio>
#endif
CCL_NAMESPACE_BEGIN
#if !defined(__KERNEL_GPU__) || defined(__KERNEL_ONEAPI__)
#ifndef __KERNEL_NATIVE_VECTOR_TYPES__
# ifdef __KERNEL_SSE__
__forceinline int4::int4()
{
@@ -45,6 +40,7 @@ __forceinline int4 &int4::operator=(const int4 &a)
}
# endif /* __KERNEL_SSE__ */
# ifndef __KERNEL_GPU__
__forceinline int int4::operator[](int i) const
{
util_assert(i >= 0);
@@ -58,6 +54,7 @@ __forceinline int &int4::operator[](int i)
util_assert(i < 4);
return *(&x + i);
}
# endif
ccl_device_inline int4 make_int4(int i)
{
@@ -105,8 +102,6 @@ ccl_device_inline void print_int4(const char *label, const int4 &a)
{
printf("%s: %d %d %d %d\n", label, a.x, a.y, a.z, a.w);
}
#endif /* !defined(__KERNEL_GPU__) || defined(__KERNEL_ONEAPI__) */
#endif /* __KERNEL_NATIVE_VECTOR_TYPES__ */
CCL_NAMESPACE_END
#endif /* __UTIL_TYPES_INT4_IMPL_H__ */

View File

@@ -1,8 +1,7 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2011-2022 Blender Foundation */
#ifndef __UTIL_TYPES_UCHAR2_H__
#define __UTIL_TYPES_UCHAR2_H__
#pragma once
#ifndef __UTIL_TYPES_H__
# error "Do not include this file directly, include util/types.h instead."
@@ -10,17 +9,17 @@
CCL_NAMESPACE_BEGIN
#if !defined(__KERNEL_GPU__) || defined(__KERNEL_ONEAPI__)
#ifndef __KERNEL_NATIVE_VECTOR_TYPES__
struct uchar2 {
uchar x, y;
# ifndef __KERNEL_GPU__
__forceinline uchar operator[](int i) const;
__forceinline uchar &operator[](int i);
# endif
};
ccl_device_inline uchar2 make_uchar2(uchar x, uchar y);
#endif /* !defined(__KERNEL_GPU__) || defined(__KERNEL_ONEAPI__) */
#endif /* __KERNEL_NATIVE_VECTOR_TYPES__ */
CCL_NAMESPACE_END
#endif /* __UTIL_TYPES_UCHAR2_H__ */

View File

@@ -10,7 +10,8 @@
CCL_NAMESPACE_BEGIN
#if !defined(__KERNEL_GPU__) || defined(__KERNEL_ONEAPI__)
#ifndef __KERNEL_NATIVE_VECTOR_TYPES__
# ifndef __KERNEL_GPU__
uchar uchar2::operator[](int i) const
{
util_assert(i >= 0);
@@ -24,13 +25,14 @@ uchar &uchar2::operator[](int i)
util_assert(i < 2);
return *(&x + i);
}
# endif
ccl_device_inline uchar2 make_uchar2(uchar x, uchar y)
{
uchar2 a = {x, y};
return a;
}
#endif /* !defined(__KERNEL_GPU__) || defined(__KERNEL_ONEAPI__) */
#endif /* __KERNEL_NATIVE_VECTOR_TYPES__ */
CCL_NAMESPACE_END

View File

@@ -10,16 +10,18 @@
CCL_NAMESPACE_BEGIN
#if !defined(__KERNEL_GPU__) || defined(__KERNEL_ONEAPI__)
#ifndef __KERNEL_NATIVE_VECTOR_TYPES__
struct uchar3 {
uchar x, y, z;
# ifndef __KERNEL_GPU__
__forceinline uchar operator[](int i) const;
__forceinline uchar &operator[](int i);
# endif
};
ccl_device_inline uchar3 make_uchar3(uchar x, uchar y, uchar z);
#endif /* !defined(__KERNEL_GPU__) || defined(__KERNEL_ONEAPI__) */
#endif /* __KERNEL_NATIVE_VECTOR_TYPES__ */
CCL_NAMESPACE_END

View File

@@ -10,7 +10,8 @@
CCL_NAMESPACE_BEGIN
#if !defined(__KERNEL_GPU__) || defined(__KERNEL_ONEAPI__)
#ifndef __KERNEL_NATIVE_VECTOR_TYPES__
# ifndef __KERNEL_GPU__
uchar uchar3::operator[](int i) const
{
util_assert(i >= 0);
@@ -24,13 +25,14 @@ uchar &uchar3::operator[](int i)
util_assert(i < 3);
return *(&x + i);
}
# endif
ccl_device_inline uchar3 make_uchar3(uchar x, uchar y, uchar z)
{
uchar3 a = {x, y, z};
return a;
}
#endif /* !defined(__KERNEL_GPU__) || defined(__KERNEL_ONEAPI__) */
#endif /* __KERNEL_NATIVE_VECTOR_TYPES__ */
CCL_NAMESPACE_END

View File

@@ -1,8 +1,7 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2011-2022 Blender Foundation */
#ifndef __UTIL_TYPES_UCHAR4_H__
#define __UTIL_TYPES_UCHAR4_H__
#pragma once
#ifndef __UTIL_TYPES_H__
# error "Do not include this file directly, include util/types.h instead."
@@ -10,17 +9,17 @@
CCL_NAMESPACE_BEGIN
#if !defined(__KERNEL_GPU__) || defined(__KERNEL_ONEAPI__)
#ifndef __KERNEL_NATIVE_VECTOR_TYPES__
struct uchar4 {
uchar x, y, z, w;
# ifndef __KERNEL_GPU__
__forceinline uchar operator[](int i) const;
__forceinline uchar &operator[](int i);
# endif
};
ccl_device_inline uchar4 make_uchar4(uchar x, uchar y, uchar z, uchar w);
#endif /* !defined(__KERNEL_GPU__) || defined(__KERNEL_ONEAPI__) */
#endif /* __KERNEL_NATIVE_VECTOR_TYPES__ */
CCL_NAMESPACE_END
#endif /* __UTIL_TYPES_UCHAR4_H__ */

View File

@@ -10,7 +10,8 @@
CCL_NAMESPACE_BEGIN
#if !defined(__KERNEL_GPU__) || defined(__KERNEL_ONEAPI__)
#ifndef __KERNEL_NATIVE_VECTOR_TYPES__
# ifndef __KERNEL_GPU__
uchar uchar4::operator[](int i) const
{
util_assert(i >= 0);
@@ -24,13 +25,14 @@ uchar &uchar4::operator[](int i)
util_assert(i < 4);
return *(&x + i);
}
# endif
ccl_device_inline uchar4 make_uchar4(uchar x, uchar y, uchar z, uchar w)
{
uchar4 a = {x, y, z, w};
return a;
}
#endif /* !defined(__KERNEL_GPU__) || defined(__KERNEL_ONEAPI__) */
#endif /* __KERNEL_NATIVE_VECTOR_TYPES__ */
CCL_NAMESPACE_END

View File

@@ -1,8 +1,7 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2011-2022 Blender Foundation */
#ifndef __UTIL_TYPES_UINT2_H__
#define __UTIL_TYPES_UINT2_H__
#pragma once
#ifndef __UTIL_TYPES_H__
# error "Do not include this file directly, include util/types.h instead."
@@ -10,17 +9,17 @@
CCL_NAMESPACE_BEGIN
#if !defined(__KERNEL_GPU__) || defined(__KERNEL_ONEAPI__)
#ifndef __KERNEL_NATIVE_VECTOR_TYPES__
struct uint2 {
uint x, y;
# ifndef __KERNEL_GPU__
__forceinline uint operator[](uint i) const;
__forceinline uint &operator[](uint i);
# endif
};
ccl_device_inline uint2 make_uint2(uint x, uint y);
#endif /* !defined(__KERNEL_GPU__) || defined(__KERNEL_ONEAPI__) */
#endif /* __KERNEL_NATIVE_VECTOR_TYPES__ */
CCL_NAMESPACE_END
#endif /* __UTIL_TYPES_UINT2_H__ */

View File

@@ -1,8 +1,7 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2011-2022 Blender Foundation */
#ifndef __UTIL_TYPES_UINT2_IMPL_H__
#define __UTIL_TYPES_UINT2_IMPL_H__
#pragma once
#ifndef __UTIL_TYPES_H__
# error "Do not include this file directly, include util/types.h instead."
@@ -10,7 +9,8 @@
CCL_NAMESPACE_BEGIN
#if !defined(__KERNEL_GPU__) || defined(__KERNEL_ONEAPI__)
#ifndef __KERNEL_NATIVE_VECTOR_TYPES__
# ifndef __KERNEL_GPU__
__forceinline uint uint2::operator[](uint i) const
{
util_assert(i < 2);
@@ -22,14 +22,13 @@ __forceinline uint &uint2::operator[](uint i)
util_assert(i < 2);
return *(&x + i);
}
# endif
ccl_device_inline uint2 make_uint2(uint x, uint y)
{
uint2 a = {x, y};
return a;
}
#endif /* !defined(__KERNEL_GPU__) || defined(__KERNEL_ONEAPI__) */
#endif /* __KERNEL_NATIVE_VECTOR_TYPES__ */
CCL_NAMESPACE_END
#endif /* __UTIL_TYPES_UINT2_IMPL_H__ */

View File

@@ -1,8 +1,7 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2011-2022 Blender Foundation */
#ifndef __UTIL_TYPES_UINT3_H__
#define __UTIL_TYPES_UINT3_H__
#pragma once
#ifndef __UTIL_TYPES_H__
# error "Do not include this file directly, include util/types.h instead."
@@ -10,17 +9,17 @@
CCL_NAMESPACE_BEGIN
#if !defined(__KERNEL_GPU__) || defined(__KERNEL_ONEAPI__)
#ifndef __KERNEL_NATIVE_VECTOR_TYPES__
struct uint3 {
uint x, y, z;
# ifndef __KERNEL_GPU__
__forceinline uint operator[](uint i) const;
__forceinline uint &operator[](uint i);
# endif
};
ccl_device_inline uint3 make_uint3(uint x, uint y, uint z);
#endif /* !defined(__KERNEL_GPU__) || defined(__KERNEL_ONEAPI__) */
#endif /* __KERNEL_NATIVE_VECTOR_TYPES__ */
CCL_NAMESPACE_END
#endif /* __UTIL_TYPES_UINT3_H__ */

View File

@@ -1,8 +1,7 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2011-2022 Blender Foundation */
#ifndef __UTIL_TYPES_UINT3_IMPL_H__
#define __UTIL_TYPES_UINT3_IMPL_H__
#pragma once
#ifndef __UTIL_TYPES_H__
# error "Do not include this file directly, include util/types.h instead."
@@ -10,7 +9,8 @@
CCL_NAMESPACE_BEGIN
#if !defined(__KERNEL_GPU__) || defined(__KERNEL_ONEAPI__)
#ifndef __KERNEL_NATIVE_VECTOR_TYPES__
# ifndef __KERNEL_GPU__
__forceinline uint uint3::operator[](uint i) const
{
util_assert(i < 3);
@@ -22,14 +22,13 @@ __forceinline uint &uint3::operator[](uint i)
util_assert(i < 3);
return *(&x + i);
}
# endif
ccl_device_inline uint3 make_uint3(uint x, uint y, uint z)
{
uint3 a = {x, y, z};
return a;
}
#endif /* !defined(__KERNEL_GPU__) || defined(__KERNEL_ONEAPI__) */
#endif /* __KERNEL_NATIVE_VECTOR_TYPES__ */
CCL_NAMESPACE_END
#endif /* __UTIL_TYPES_UINT3_IMPL_H__ */

View File

@@ -1,8 +1,7 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2011-2022 Blender Foundation */
#ifndef __UTIL_TYPES_UINT4_H__
#define __UTIL_TYPES_UINT4_H__
#pragma once
#ifndef __UTIL_TYPES_H__
# error "Do not include this file directly, include util/types.h instead."
@@ -10,17 +9,17 @@
CCL_NAMESPACE_BEGIN
#if !defined(__KERNEL_GPU__) || defined(__KERNEL_ONEAPI__)
#ifndef __KERNEL_NATIVE_VECTOR_TYPES__
struct uint4 {
uint x, y, z, w;
# ifndef __KERNEL_GPU__
__forceinline uint operator[](uint i) const;
__forceinline uint &operator[](uint i);
# endif
};
ccl_device_inline uint4 make_uint4(uint x, uint y, uint z, uint w);
#endif /* !defined(__KERNEL_GPU__) || defined(__KERNEL_ONEAPI__) */
#endif /* __KERNEL_NATIVE_VECTOR_TYPES__ */
CCL_NAMESPACE_END
#endif /* __UTIL_TYPES_UINT4_H__ */

View File

@@ -1,8 +1,7 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2011-2022 Blender Foundation */
#ifndef __UTIL_TYPES_UINT4_IMPL_H__
#define __UTIL_TYPES_UINT4_IMPL_H__
#pragma once
#ifndef __UTIL_TYPES_H__
# error "Do not include this file directly, include util/types.h instead."
@@ -10,7 +9,8 @@
CCL_NAMESPACE_BEGIN
#if !defined(__KERNEL_GPU__) || defined(__KERNEL_ONEAPI__)
#ifndef __KERNEL_NATIVE_VECTOR_TYPES__
# ifndef __KERNEL_GPU__
__forceinline uint uint4::operator[](uint i) const
{
util_assert(i < 3);
@@ -22,14 +22,13 @@ __forceinline uint &uint4::operator[](uint i)
util_assert(i < 3);
return *(&x + i);
}
# endif
ccl_device_inline uint4 make_uint4(uint x, uint y, uint z, uint w)
{
uint4 a = {x, y, z, w};
return a;
}
#endif /* !defined(__KERNEL_GPU__) || defined(__KERNEL_ONEAPI__) */
#endif /* __KERNEL_NATIVE_VECTOR_TYPES__ */
CCL_NAMESPACE_END
#endif /* __UTIL_TYPES_UINT4_IMPL_H__ */

View File

@@ -10,7 +10,7 @@
CCL_NAMESPACE_BEGIN
#if !defined(__KERNEL_GPU__) || defined(__KERNEL_ONEAPI__)
#ifndef __KERNEL_NATIVE_VECTOR_TYPES__
struct ushort4 {
uint16_t x, y, z, w;

View File

@@ -1,26 +0,0 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2011-2022 Blender Foundation */
#ifndef __UTIL_TYPES_VECTOR3_H__
#define __UTIL_TYPES_VECTOR3_H__
#ifndef __UTIL_TYPES_H__
# error "Do not include this file directly, include util/types.h instead."
#endif
CCL_NAMESPACE_BEGIN
#ifndef __KERNEL_GPU__
template<typename T> class vector3 {
public:
T x, y, z;
__forceinline vector3();
__forceinline vector3(const T &a);
__forceinline vector3(const T &x, const T &y, const T &z);
};
#endif /* __KERNEL_GPU__ */
CCL_NAMESPACE_END
#endif /* __UTIL_TYPES_VECTOR3_H__ */

View File

@@ -1,30 +0,0 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2011-2022 Blender Foundation */
#ifndef __UTIL_TYPES_VECTOR3_IMPL_H__
#define __UTIL_TYPES_VECTOR3_IMPL_H__
#ifndef __UTIL_TYPES_H__
# error "Do not include this file directly, include util/types.h instead."
#endif
CCL_NAMESPACE_BEGIN
#ifndef __KERNEL_GPU__
template<typename T> ccl_always_inline vector3<T>::vector3()
{
}
template<typename T> ccl_always_inline vector3<T>::vector3(const T &a) : x(a), y(a), z(a)
{
}
template<typename T>
ccl_always_inline vector3<T>::vector3(const T &x, const T &y, const T &z) : x(x), y(y), z(z)
{
}
#endif /* __KERNEL_GPU__ */
CCL_NAMESPACE_END
#endif /* __UTIL_TYPES_VECTOR3_IMPL_H__ */

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -149,37 +149,6 @@ class NODE_OT_add_node(NodeAddOperator, Operator):
bl_options = {'REGISTER', 'UNDO'}
# Add a node and link it to an existing socket
class NODE_OT_add_and_link_node(NodeAddOperator, Operator):
'''Add a node to the active tree and link to an existing socket'''
bl_idname = "node.add_and_link_node"
bl_label = "Add and Link Node"
bl_options = {'REGISTER', 'UNDO'}
link_socket_index: IntProperty(
name="Link Socket Index",
description="Index of the socket to link",
)
def execute(self, context):
space = context.space_data
ntree = space.edit_tree
node = self.create_node(context)
if not node:
return {'CANCELLED'}
to_socket = getattr(context, "link_to_socket", None)
if to_socket:
ntree.links.new(node.outputs[self.link_socket_index], to_socket)
from_socket = getattr(context, "link_from_socket", None)
if from_socket:
ntree.links.new(from_socket, node.inputs[self.link_socket_index])
return {'FINISHED'}
class NODE_OT_add_search(NodeAddOperator, Operator):
'''Add a node to the active tree'''
bl_idname = "node.add_search"
@@ -306,7 +275,6 @@ class NODE_OT_tree_path_parent(Operator):
classes = (
NodeSetting,
NODE_OT_add_and_link_node,
NODE_OT_add_node,
NODE_OT_add_search,
NODE_OT_collapse_hide_unused_toggle,

View File

@@ -162,6 +162,35 @@ class RENDER_PT_eevee_motion_blur(RenderButtonsPanel, Panel):
col.prop(props, "motion_blur_steps", text="Steps")
class RENDER_PT_eevee_next_motion_blur(RenderButtonsPanel, Panel):
bl_label = "Motion Blur"
bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {'BLENDER_EEVEE_NEXT'}
@classmethod
def poll(cls, context):
return (context.engine in cls.COMPAT_ENGINES)
def draw_header(self, context):
scene = context.scene
props = scene.eevee
self.layout.prop(props, "use_motion_blur", text="")
def draw(self, context):
layout = self.layout
layout.use_property_split = True
scene = context.scene
props = scene.eevee
layout.active = props.use_motion_blur
col = layout.column()
col.prop(props, "motion_blur_position", text="Position")
col.prop(props, "motion_blur_shutter")
col.separator()
col.prop(props, "motion_blur_depth_scale")
col.prop(props, "motion_blur_steps", text="Steps")
class RENDER_PT_eevee_depth_of_field(RenderButtonsPanel, Panel):
bl_label = "Depth of Field"
bl_options = {'DEFAULT_CLOSED'}
@@ -756,6 +785,7 @@ classes = (
RENDER_PT_eevee_film,
RENDER_PT_eevee_next_sampling,
RENDER_PT_eevee_next_motion_blur,
RENDER_PT_eevee_next_film,
RENDER_PT_gpencil,

View File

@@ -79,6 +79,7 @@ class VIEWLAYER_PT_eevee_next_layer_passes_data(ViewLayerButtonsPanel, Panel):
layout.use_property_split = True
layout.use_property_decorate = False
scene = context.scene
view_layer = context.view_layer
col = layout.column()
@@ -87,7 +88,9 @@ class VIEWLAYER_PT_eevee_next_layer_passes_data(ViewLayerButtonsPanel, Panel):
col.prop(view_layer, "use_pass_mist")
col.prop(view_layer, "use_pass_normal")
col.prop(view_layer, "use_pass_position")
col.prop(view_layer, "use_pass_vector")
sub = col.column()
sub.active = not scene.eevee.use_motion_blur
sub.prop(view_layer, "use_pass_vector")
class VIEWLAYER_PT_eevee_layer_passes_light(ViewLayerButtonsPanel, Panel):

View File

@@ -18,10 +18,10 @@ extern "C" {
#define BLF_DATAFILES_FONTS_DIR "fonts"
/* File name of the default variable-width font. */
#define BLF_DEFAULT_PROPORTIONAL_FONT "droidsans.ttf"
#define BLF_DEFAULT_PROPORTIONAL_FONT "DejaVuSans.woff2"
/* File name of the default fixed-pitch font. */
#define BLF_DEFAULT_MONOSPACED_FONT "bmonofont-i18n.ttf"
#define BLF_DEFAULT_MONOSPACED_FONT "DejaVuSansMono.woff2"
/* enable this only if needed (unused circa 2016) */
#define BLF_BLUR_ENABLE 0
@@ -351,6 +351,8 @@ enum {
BLF_DEFAULT = 1 << 14,
/** Must only be used as last font in the stack. */
BLF_LAST_RESORT = 1 << 15,
/** Failure to load this font. Don't try again. */
BLF_BAD_FONT = 1 << 16,
};
#define BLF_DRAW_STR_DUMMY_MAX 1024

View File

@@ -18,8 +18,9 @@
#include FT_FREETYPE_H
#include FT_GLYPH_H
#include FT_TRUETYPE_TABLES_H /* For TT_OS2 */
#include FT_MULTIPLE_MASTERS_H /* Variable font support. */
#include FT_TRUETYPE_IDS_H /* Codepoint coverage constants. */
#include FT_TRUETYPE_TABLES_H /* For TT_OS2 */
#include "MEM_guardedalloc.h"
@@ -28,6 +29,7 @@
#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_math_color_blend.h"
#include "BLI_path_util.h"
#include "BLI_rect.h"
#include "BLI_string.h"
#include "BLI_string_utf8.h"
@@ -836,7 +838,7 @@ static void blf_font_boundbox_foreach_glyph_ex(FontBLF *font,
size_t i = 0, i_curr;
rcti gbox_px;
if (str_len == 0) {
if (str_len == 0 || str[0] == 0) {
/* early output. */
return;
}
@@ -1157,7 +1159,7 @@ int blf_font_ascender(FontBLF *font)
char *blf_display_name(FontBLF *font)
{
if (!font->face->family_name) {
if (!blf_ensure_face(font) || !font->face->family_name) {
return NULL;
}
return BLI_sprintfN("%s %s", font->face->family_name, font->face->style_name);
@@ -1244,14 +1246,28 @@ static void blf_font_fill(FontBLF *font)
font->glyph_cache_mutex = &blf_glyph_cache_mutex;
}
FontBLF *blf_font_new(const char *name, const char *filepath)
/**
* Create an FT_Face for this font if not already existing.
*/
bool blf_ensure_face(FontBLF *font)
{
FontBLF *font;
FT_Error err;
char *mfile;
if (font->face) {
return true;
}
if (font->flags & BLF_BAD_FONT) {
return false;
}
FT_Error err;
if (font->filepath) {
err = FT_New_Face(ft_lib, font->filepath, 0, &font->face);
}
if (font->mem) {
err = FT_New_Memory_Face(ft_lib, font->mem, (FT_Long)font->mem_size, 0, &font->face);
}
font = (FontBLF *)MEM_callocN(sizeof(FontBLF), "blf_font_new");
err = FT_New_Face(ft_lib, filepath, 0, &font->face);
if (err) {
if (ELEM(err, FT_Err_Unknown_File_Format, FT_Err_Unimplemented_Feature)) {
printf("Format of this font file is not supported\n");
@@ -1259,8 +1275,8 @@ FontBLF *blf_font_new(const char *name, const char *filepath)
else {
printf("Error encountered while opening font file\n");
}
MEM_freeN(font);
return NULL;
font->flags |= BLF_BAD_FONT;
return false;
}
err = FT_Select_Charmap(font->face, FT_ENCODING_UNICODE);
@@ -1272,28 +1288,28 @@ FontBLF *blf_font_new(const char *name, const char *filepath)
}
if (err) {
printf("Can't set a character map!\n");
FT_Done_Face(font->face);
MEM_freeN(font);
return NULL;
font->flags |= BLF_BAD_FONT;
return false;
}
mfile = blf_dir_metrics_search(filepath);
if (mfile) {
err = FT_Attach_File(font->face, mfile);
if (err) {
fprintf(stderr, "FT_Attach_File failed to load '%s' with error %d\n", filepath, (int)err);
if (font->filepath) {
char *mfile = blf_dir_metrics_search(font->filepath);
if (mfile) {
err = FT_Attach_File(font->face, mfile);
if (err) {
fprintf(stderr,
"FT_Attach_File failed to load '%s' with error %d\n",
font->filepath,
(int)err);
}
MEM_freeN(mfile);
}
MEM_freeN(mfile);
}
if (FT_HAS_MULTIPLE_MASTERS(font->face)) {
FT_Get_MM_Var(font->face, &(font->variations));
}
font->name = BLI_strdup(name);
font->filepath = BLI_strdup(filepath);
blf_font_fill(font);
/* Save TrueType table with bits to quickly test most unicode block coverage. */
TT_OS2 *os2_table = (TT_OS2 *)FT_Get_Sfnt_Table(font->face, FT_SFNT_OS2);
if (os2_table) {
@@ -1303,17 +1319,11 @@ FontBLF *blf_font_new(const char *name, const char *filepath)
font->UnicodeRanges[3] = (uint)os2_table->ulUnicodeRange4;
}
/* Detect "Last resort" fonts. They have everything. Usually except last 5 bits. */
if (font->UnicodeRanges[0] == 0xffffffffU && font->UnicodeRanges[1] == 0xffffffffU &&
font->UnicodeRanges[2] == 0xffffffffU && font->UnicodeRanges[3] >= 0x7FFFFFFU) {
font->flags |= BLF_LAST_RESORT;
}
if (FT_IS_FIXED_WIDTH(font->face)) {
font->flags |= BLF_MONOSPACED;
}
if (FT_HAS_KERNING(font->face)) {
if (FT_HAS_KERNING(font->face) && !font->kerning_cache) {
/* Create kerning cache table and fill with value indicating "unset". */
font->kerning_cache = MEM_mallocN(sizeof(KerningCacheBLF), __func__);
for (uint i = 0; i < KERNING_CACHE_TABLE_SIZE; i++) {
@@ -1323,49 +1333,114 @@ FontBLF *blf_font_new(const char *name, const char *filepath)
}
}
return true;
}
typedef struct eFaceDetails {
char name[50];
unsigned int coverage1;
unsigned int coverage2;
unsigned int coverage3;
unsigned int coverage4;
} eFaceDetails;
/* Details about the fallback fonts we ship, so that we can load only when needed. */
static const eFaceDetails static_face_details[] = {
{"lastresort.woff2", UINT32_MAX, UINT32_MAX, UINT32_MAX, UINT32_MAX},
{"Noto Sans CJK Regular.woff2", 0x30000083L, 0x2BDF3C10L, 0x16L, 0},
{"NotoEmoji-VariableFont_wght.woff2", 0x80000003L, 0x241E4ACL, 0x14000000L, 0x4000000L},
{"NotoSansArabic-VariableFont_wdth,wght.woff2", TT_UCR_ARABIC, 0, 0, 0},
{"NotoSansArmenian-VariableFont_wdth,wght.woff2",
TT_UCR_ARMENIAN,
TT_UCR_ALPHABETIC_PRESENTATION_FORMS,
0,
0},
{"NotoSansBengali-VariableFont_wdth,wght.woff2", TT_UCR_BENGALI, 0, 0, 0},
{"NotoSansDevanagari-Regular.woff2", TT_UCR_DEVANAGARI, 0, 0, 0},
{"NotoSansEthiopic-Regular.woff2", 0, 0, TT_UCR_ETHIOPIC, 0},
{"NotoSansGeorgian-VariableFont_wdth,wght.woff2", TT_UCR_GEORGIAN, 0, 0, 0},
{"NotoSansGujarati-Regular.woff2", TT_UCR_GUJARATI, 0, 0, 0},
{"NotoSansGurmukhi-VariableFont_wdth,wght.woff2", TT_UCR_GURMUKHI, 0, 0, 0},
{"NotoSansHebrew-VariableFont_wdth,wght.woff2", TT_UCR_HEBREW, 0, 0, 0},
{"NotoSansJavanese-Regular.woff2", 0x80000003L, 0x2000L, 0, 0},
{"NotoSansKannada-VariableFont_wdth,wght.woff2", TT_UCR_KANNADA, 0, 0, 0},
{"NotoSansMalayalam-VariableFont_wdth,wght.woff2", TT_UCR_MALAYALAM, 0, 0, 0},
{"NotoSansMath-Regular.woff2", 0, TT_UCR_MATHEMATICAL_OPERATORS, 0, 0},
{"NotoSansMyanmar-Regular.woff2", 0, 0, TT_UCR_MYANMAR, 0},
{"NotoSansSymbols-VariableFont_wght.woff2", 0x3L, 0x200E4B4L, 0, 0},
{"NotoSansSymbols2-Regular.woff2", 0x80000003L, 0x200E3E4L, 0x40020L, 0x580A048L},
{"NotoSansTamil-VariableFont_wdth,wght.woff2", TT_UCR_TAMIL, 0, 0, 0},
{"NotoSansTelugu-VariableFont_wdth,wght.woff2", TT_UCR_TELUGU, 0, 0, 0},
{"NotoSansThai-VariableFont_wdth,wght.woff2", TT_UCR_THAI, 0, 0, 0},
};
/* Create a new font from filename OR from passed memory pointer. */
static FontBLF *blf_font_new_ex(const char *name,
const char *filepath,
const unsigned char *mem,
const size_t mem_size)
{
FontBLF *font = (FontBLF *)MEM_callocN(sizeof(FontBLF), "blf_font_new");
font->name = BLI_strdup(name);
font->filepath = filepath ? BLI_strdup(filepath) : NULL;
if (mem) {
font->mem = (void *)mem;
font->mem_size = mem_size;
}
blf_font_fill(font);
/* If we have static details about this font we don't need to load the Face. */
const eFaceDetails *static_details = NULL;
char filename[256];
for (int i = 0; i < (int)ARRAY_SIZE(static_face_details); i++) {
BLI_split_file_part(font->filepath, filename, sizeof(filename));
if (STREQ(static_face_details[i].name, filename)) {
static_details = &static_face_details[i];
font->UnicodeRanges[0] = static_details->coverage1;
font->UnicodeRanges[1] = static_details->coverage2;
font->UnicodeRanges[2] = static_details->coverage3;
font->UnicodeRanges[3] = static_details->coverage4;
break;
}
}
if (!static_details) {
if (!blf_ensure_face(font)) {
blf_font_free(font);
return NULL;
}
}
/* Detect "Last resort" fonts. They have everything. Usually except last 5 bits. */
if (font->UnicodeRanges[0] == 0xffffffffU && font->UnicodeRanges[1] == 0xffffffffU &&
font->UnicodeRanges[2] == 0xffffffffU && font->UnicodeRanges[3] >= 0x7FFFFFFU) {
font->flags |= BLF_LAST_RESORT;
}
return font;
}
void blf_font_attach_from_mem(FontBLF *font, const unsigned char *mem, int mem_size)
FontBLF *blf_font_new(const char *name, const char *filename)
{
return blf_font_new_ex(name, filename, NULL, 0);
}
FontBLF *blf_font_new_from_mem(const char *name, const unsigned char *mem, const size_t mem_size)
{
return blf_font_new_ex(name, NULL, mem, mem_size);
}
void blf_font_attach_from_mem(FontBLF *font, const unsigned char *mem, const size_t mem_size)
{
FT_Open_Args open;
open.flags = FT_OPEN_MEMORY;
open.memory_base = (const FT_Byte *)mem;
open.memory_size = mem_size;
open.memory_size = (FT_Long)mem_size;
FT_Attach_Stream(font->face, &open);
}
FontBLF *blf_font_new_from_mem(const char *name, const unsigned char *mem, int mem_size)
{
FontBLF *font;
FT_Error err;
font = (FontBLF *)MEM_callocN(sizeof(FontBLF), "blf_font_new_from_mem");
err = FT_New_Memory_Face(ft_lib, mem, mem_size, 0, &font->face);
if (err) {
MEM_freeN(font);
return NULL;
}
err = FT_Select_Charmap(font->face, ft_encoding_unicode);
if (err) {
printf("Can't set the unicode character map!\n");
FT_Done_Face(font->face);
MEM_freeN(font);
return NULL;
}
if (FT_HAS_MULTIPLE_MASTERS(font->face)) {
FT_Get_MM_Var(font->face, &(font->variations));
}
font->name = BLI_strdup(name);
font->filepath = NULL;
blf_font_fill(font);
return font;
}
void blf_font_free(FontBLF *font)
{
blf_glyph_cache_clear(font);
@@ -1378,7 +1453,9 @@ void blf_font_free(FontBLF *font)
FT_Done_MM_Var(ft_lib, font->variations);
}
FT_Done_Face(font->face);
if (font->face) {
FT_Done_Face(font->face);
}
if (font->filepath) {
MEM_freeN(font->filepath);
}
@@ -1396,6 +1473,10 @@ void blf_font_free(FontBLF *font)
bool blf_font_size(FontBLF *font, float size, unsigned int dpi)
{
if (!blf_ensure_face(font)) {
return false;
}
/* FreeType uses fixed-point integers in 64ths. */
FT_F26Dot6 ft_size = lroundf(size * 64.0f);
/* Adjust our new size to be on even 64ths. */

View File

@@ -66,8 +66,6 @@ void BLF_load_font_stack()
}
else {
BLF_enable(font_id, BLF_DEFAULT);
/* TODO: FontBLF will later load FT_Face on demand. When this is in
* place we can drop this face now since we have all needed data. */
}
}
}

View File

@@ -584,16 +584,22 @@ static FT_UInt blf_glyph_index_from_charcode(FontBLF **font, const uint charcode
continue;
}
if (coverage_bit < 0 || blf_font_has_coverage_bit(f, coverage_bit)) {
glyph_index = FT_Get_Char_Index(f->face, charcode);
if (glyph_index) {
*font = f;
return glyph_index;
if (blf_ensure_face(f)) {
glyph_index = FT_Get_Char_Index(f->face, charcode);
if (glyph_index) {
*font = f;
return glyph_index;
}
}
}
}
#ifdef DEBUG
printf("Unicode character U+%04X not found in loaded fonts. \n", charcode);
#endif
/* Not found in the stack, return from Last Resort if there is one. */
if (last_resort) {
if (last_resort && blf_ensure_face(last_resort)) {
glyph_index = FT_Get_Char_Index(last_resort->face, charcode);
if (glyph_index) {
*font = last_resort;

View File

@@ -39,12 +39,14 @@ void blf_font_exit(void);
bool blf_font_id_is_valid(int fontid);
bool blf_ensure_face(struct FontBLF *font);
void blf_draw_buffer__start(struct FontBLF *font);
void blf_draw_buffer__end(void);
struct FontBLF *blf_font_new(const char *name, const char *filepath);
struct FontBLF *blf_font_new_from_mem(const char *name, const unsigned char *mem, int mem_size);
void blf_font_attach_from_mem(struct FontBLF *font, const unsigned char *mem, int mem_size);
struct FontBLF *blf_font_new_from_mem(const char *name, const unsigned char *mem, size_t mem_size);
void blf_font_attach_from_mem(struct FontBLF *font, const unsigned char *mem, size_t mem_size);
/**
* Change font's output size. Returns true if successful in changing the size.

View File

@@ -240,9 +240,13 @@ typedef struct FontBLF {
/* # of times this font was loaded */
unsigned int reference_count;
/** File-path or NULL. */
/* Full path to font file or NULL if from memory. */
char *filepath;
/* Pointer to in-memory font, or NULL if from file. */
void *mem;
size_t mem_size;
/* Copied from the SFNT OS/2 table. Bit flags for unicode blocks and ranges
* considered "functional". Cached here because face might not always exist.
* See: https://docs.microsoft.com/en-us/typography/opentype/spec/os2#ur */

View File

@@ -7,6 +7,7 @@
*/
#include "BLI_compiler_attrs.h"
#include "BLI_sys_types.h"
#ifdef __cplusplus
extern "C" {
@@ -19,6 +20,7 @@ struct BlendWriter;
struct ID;
struct IDProperty;
struct IDPropertyUIData;
struct Library;
typedef union IDPropertyTemplate {
int i;
@@ -318,7 +320,7 @@ void IDP_BlendReadData_impl(struct BlendDataReader *reader,
struct IDProperty **prop,
const char *caller_func_id);
#define IDP_BlendDataRead(reader, prop) IDP_BlendReadData_impl(reader, prop, __func__)
void IDP_BlendReadLib(struct BlendLibReader *reader, struct IDProperty *prop);
void IDP_BlendReadLib(struct BlendLibReader *reader, struct Library *lib, struct IDProperty *prop);
void IDP_BlendReadExpand(struct BlendExpander *expander, struct IDProperty *prop);
typedef enum eIDPropertyUIDataType {

View File

@@ -45,6 +45,9 @@ std::unique_ptr<IDProperty, IDPropertyDeleter> create(StringRefNull prop_name, d
std::unique_ptr<IDProperty, IDPropertyDeleter> create(StringRefNull prop_name,
const StringRefNull value);
/** \brief Allocate a new IDProperty of type IDP_ID, set its name and value. */
std::unique_ptr<IDProperty, IDPropertyDeleter> create(StringRefNull prop_name, ID *id);
/**
* \brief Allocate a new IDProperty of type IDP_ARRAY and subtype IDP_INT.
*

View File

@@ -374,6 +374,9 @@ typedef struct bNodeTreeType {
int type; /* type identifier */
char idname[64]; /* identifier name */
/* The ID name of group nodes for this type. */
char group_idname[64];
char ui_name[64];
char ui_description[256];
int ui_icon;

View File

@@ -13,6 +13,7 @@
#include "DNA_object_enums.h"
#include "BKE_attribute.h"
#include "BKE_pbvh.h"
#ifdef __cplusplus
extern "C" {
@@ -397,7 +398,7 @@ typedef struct SculptVertexInfo {
typedef struct SculptBoundaryEditInfo {
/* Vertex index from where the topology propagation reached this vertex. */
int original_vertex;
int original_vertex_i;
/* How many steps were needed to reach this vertex from the boundary. */
int num_propagation_steps;
@@ -408,13 +409,14 @@ typedef struct SculptBoundaryEditInfo {
/* Edge for drawing the boundary preview in the cursor. */
typedef struct SculptBoundaryPreviewEdge {
int v1;
int v2;
PBVHVertRef v1;
PBVHVertRef v2;
} SculptBoundaryPreviewEdge;
typedef struct SculptBoundary {
/* Vertex indices of the active boundary. */
int *vertices;
PBVHVertRef *vertices;
int *vertices_i;
int vertices_capacity;
int num_vertices;
@@ -432,12 +434,13 @@ typedef struct SculptBoundary {
bool forms_loop;
/* Initial vertex in the boundary which is closest to the current sculpt active vertex. */
int initial_vertex;
PBVHVertRef initial_vertex;
int initial_vertex_i;
/* Vertex that at max_propagation_steps from the boundary and closest to the original active
* vertex that was used to initialize the boundary. This is used as a reference to check how much
* the deformation will go into the mesh and to calculate the strength of the brushes. */
int pivot_vertex;
PBVHVertRef pivot_vertex;
/* Stores the initial positions of the pivot and boundary initial vertex as they may be deformed
* during the brush action. This allows to use them as a reference positions and vectors for some
@@ -565,7 +568,7 @@ typedef struct SculptSession {
struct ExpandCache *expand_cache;
/* Cursor data and active vertex for tools */
int active_vertex_index;
PBVHVertRef active_vertex;
int active_face_index;
int active_grid_index;
@@ -591,8 +594,8 @@ typedef struct SculptSession {
struct Scene *scene;
/* Dynamic mesh preview */
int *preview_vert_index_list;
int preview_vert_index_count;
PBVHVertRef *preview_vert_list;
int preview_vert_count;
/* Pose Brush Preview */
float pose_origin[3];

View File

@@ -8,8 +8,11 @@
*/
#include "BLI_bitmap.h"
#include "BLI_compiler_compat.h"
#include "BLI_ghash.h"
#include "bmesh.h"
/* For embedding CCGKey in iterator. */
#include "BKE_attribute.h"
#include "BKE_ccg.h"
@@ -43,6 +46,41 @@ struct MeshElemMap;
typedef struct PBVH PBVH;
typedef struct PBVHNode PBVHNode;
typedef enum {
PBVH_FACES,
PBVH_GRIDS,
PBVH_BMESH,
} PBVHType;
/* Public members of PBVH, used for inlined functions. */
struct PBVHPublic {
PBVHType type;
BMesh *bm;
};
/*
* These structs represent logical verts/edges/faces.
* for PBVH_GRIDS and PBVH_FACES they store integer
* offsets, PBVH_BMESH stores pointers.
*
* The idea is to enforce stronger type checking by encapsulating
* intptr_t's in structs.
*/
typedef struct PBVHVertRef {
intptr_t i;
} PBVHVertRef;
typedef struct PBVHEdgeRef {
intptr_t i;
} PBVHEdgeRef;
typedef struct PBVHFaceRef {
intptr_t i;
} PBVHFaceRef;
#define PBVH_REF_NONE -1LL
typedef struct {
float (*co)[3];
} PBVHProxyNode;
@@ -87,9 +125,97 @@ typedef struct PBVHFrustumPlanes {
int num_planes;
} PBVHFrustumPlanes;
BLI_INLINE PBVHType BKE_pbvh_type(const PBVH *pbvh)
{
return ((const struct PBVHPublic *)pbvh)->type;
}
BLI_INLINE BMesh *BKE_pbvh_get_bmesh(PBVH *pbvh)
{
return ((struct PBVHPublic *)pbvh)->bm;
}
void BKE_pbvh_set_frustum_planes(PBVH *pbvh, PBVHFrustumPlanes *planes);
void BKE_pbvh_get_frustum_planes(PBVH *pbvh, PBVHFrustumPlanes *planes);
BLI_INLINE PBVHVertRef BKE_pbvh_make_vref(intptr_t i)
{
PBVHVertRef ret = {i};
return ret;
}
BLI_INLINE PBVHEdgeRef BKE_pbvh_make_eref(intptr_t i)
{
PBVHEdgeRef ret = {i};
return ret;
}
BLI_INLINE PBVHFaceRef BKE_pbvh_make_fref(intptr_t i)
{
PBVHFaceRef ret = {i};
return ret;
}
BLI_INLINE int BKE_pbvh_vertex_to_index(PBVH *pbvh, PBVHVertRef v)
{
return (BKE_pbvh_type(pbvh) == PBVH_BMESH && v.i != PBVH_REF_NONE ?
BM_elem_index_get((BMVert *)(v.i)) :
(v.i));
}
BLI_INLINE PBVHVertRef BKE_pbvh_index_to_vertex(PBVH *pbvh, int index)
{
switch (BKE_pbvh_type(pbvh)) {
case PBVH_FACES:
case PBVH_GRIDS:
return BKE_pbvh_make_vref(index);
case PBVH_BMESH:
return BKE_pbvh_make_vref((intptr_t)BKE_pbvh_get_bmesh(pbvh)->vtable[index]);
}
return BKE_pbvh_make_vref(PBVH_REF_NONE);
}
BLI_INLINE int BKE_pbvh_edge_to_index(PBVH *pbvh, PBVHEdgeRef e)
{
return (BKE_pbvh_type(pbvh) == PBVH_BMESH && e.i != PBVH_REF_NONE ?
BM_elem_index_get((BMEdge *)(e.i)) :
(e.i));
}
BLI_INLINE PBVHEdgeRef BKE_pbvh_index_to_edge(PBVH *pbvh, int index)
{
switch (BKE_pbvh_type(pbvh)) {
case PBVH_FACES:
case PBVH_GRIDS:
return BKE_pbvh_make_eref(index);
case PBVH_BMESH:
return BKE_pbvh_make_eref((intptr_t)BKE_pbvh_get_bmesh(pbvh)->etable[index]);
}
return BKE_pbvh_make_eref(PBVH_REF_NONE);
}
BLI_INLINE int BKE_pbvh_face_to_index(PBVH *pbvh, PBVHFaceRef f)
{
return (BKE_pbvh_type(pbvh) == PBVH_BMESH && f.i != PBVH_REF_NONE ?
BM_elem_index_get((BMFace *)(f.i)) :
(f.i));
}
BLI_INLINE PBVHFaceRef BKE_pbvh_index_to_face(PBVH *pbvh, int index)
{
switch (BKE_pbvh_type(pbvh)) {
case PBVH_FACES:
case PBVH_GRIDS:
return BKE_pbvh_make_fref(index);
case PBVH_BMESH:
return BKE_pbvh_make_fref((intptr_t)BKE_pbvh_get_bmesh(pbvh)->ftable[index]);
}
return BKE_pbvh_make_fref(PBVH_REF_NONE);
}
/* Callbacks */
/**
@@ -181,7 +307,7 @@ bool BKE_pbvh_node_raycast(PBVH *pbvh,
const float ray_normal[3],
struct IsectRayPrecalc *isect_precalc,
float *depth,
int *active_vertex_index,
PBVHVertRef *active_vertex,
int *active_face_grid_index,
float *face_normal);
@@ -230,13 +356,7 @@ void BKE_pbvh_draw_debug_cb(
void *user_data);
/* PBVH Access */
typedef enum {
PBVH_FACES,
PBVH_GRIDS,
PBVH_BMESH,
} PBVHType;
PBVHType BKE_pbvh_type(const PBVH *pbvh);
bool BKE_pbvh_has_faces(const PBVH *pbvh);
/**
@@ -272,7 +392,6 @@ int BKE_pbvh_get_grid_num_faces(const PBVH *pbvh);
/**
* Only valid for type == #PBVH_BMESH.
*/
struct BMesh *BKE_pbvh_get_bmesh(PBVH *pbvh);
void BKE_pbvh_bmesh_detail_size_set(PBVH *pbvh, float detail_size);
typedef enum {
@@ -308,7 +427,7 @@ void BKE_pbvh_node_fully_unmasked_set(PBVHNode *node, int fully_masked);
bool BKE_pbvh_node_fully_unmasked_get(PBVHNode *node);
void BKE_pbvh_mark_rebuild_pixels(PBVH *pbvh);
void BKE_pbvh_vert_mark_update(PBVH *pbvh, int index);
void BKE_pbvh_vert_mark_update(PBVH *pbvh, PBVHVertRef vertex);
void BKE_pbvh_node_get_grids(PBVH *pbvh,
PBVHNode *node,
@@ -399,6 +518,7 @@ typedef struct PBVHVertexIter {
int gy;
int i;
int index;
PBVHVertRef vertex;
bool respect_hide;
/* grid */
@@ -443,7 +563,7 @@ void pbvh_vertex_iter_init(PBVH *pbvh, PBVHNode *node, PBVHVertexIter *vi, int m
if (vi.grids) { \
vi.width = vi.gridsize; \
vi.height = vi.gridsize; \
vi.index = vi.grid_indices[vi.g] * vi.key.grid_area - 1; \
vi.index = vi.vertex.i = vi.grid_indices[vi.g] * vi.key.grid_area - 1; \
vi.grid = vi.grids[vi.grid_indices[vi.g]]; \
if (mode == PBVH_ITER_UNIQUE) { \
vi.gh = vi.grid_hidden[vi.grid_indices[vi.g]]; \
@@ -462,6 +582,7 @@ void pbvh_vertex_iter_init(PBVH *pbvh, PBVHNode *node, PBVHVertexIter *vi, int m
vi.mask = vi.key.has_mask ? CCG_elem_mask(&vi.key, vi.grid) : NULL; \
vi.grid = CCG_elem_next(&vi.key, vi.grid); \
vi.index++; \
vi.vertex.i++; \
vi.visible = true; \
if (vi.gh) { \
if (BLI_BITMAP_TEST(vi.gh, vi.gy * vi.gridsize + vi.gx)) { \
@@ -482,7 +603,7 @@ void pbvh_vertex_iter_init(PBVH *pbvh, PBVHNode *node, PBVHVertexIter *vi, int m
} \
vi.co = vi.mvert->co; \
vi.no = vi.vert_normals[vi.vert_indices[vi.gx]]; \
vi.index = vi.vert_indices[vi.i]; \
vi.index = vi.vertex.i = vi.vert_indices[vi.i]; \
if (vi.vmask) { \
vi.mask = &vi.vmask[vi.index]; \
} \
@@ -502,6 +623,7 @@ void pbvh_vertex_iter_init(PBVH *pbvh, PBVHNode *node, PBVHVertexIter *vi, int m
} \
vi.co = vi.bm_vert->co; \
vi.fno = vi.bm_vert->no; \
vi.vertex = BKE_pbvh_make_vref((intptr_t)vi.bm_vert); \
vi.index = BM_elem_index_get(vi.bm_vert); \
vi.mask = (float *)BM_ELEM_CD_GET_VOID_P(vi.bm_vert, vi.cd_vert_mask_offset); \
}
@@ -581,8 +703,8 @@ void BKE_pbvh_node_num_loops(PBVH *pbvh, PBVHNode *node, int *r_totloop);
void BKE_pbvh_update_active_vcol(PBVH *pbvh, const struct Mesh *mesh);
void BKE_pbvh_pmap_set(PBVH *pbvh, const struct MeshElemMap *pmap);
void BKE_pbvh_vertex_color_set(PBVH *pbvh, int vertex, const float color[4]);
void BKE_pbvh_vertex_color_get(const PBVH *pbvh, int vertex, float r_color[4]);
void BKE_pbvh_vertex_color_set(PBVH *pbvh, PBVHVertRef vertex, const float color[4]);
void BKE_pbvh_vertex_color_get(const PBVH *pbvh, PBVHVertRef vertex, float r_color[4]);
void BKE_pbvh_ensure_node_loops(PBVH *pbvh);
bool BKE_pbvh_draw_cache_invalid(const PBVH *pbvh);

View File

@@ -291,7 +291,7 @@ enum {
/* Draw an item in the uiList */
typedef void (*uiListDrawItemFunc)(struct uiList *ui_list,
struct bContext *C,
const struct bContext *C,
struct uiLayout *layout,
struct PointerRNA *dataptr,
struct PointerRNA *itemptr,
@@ -303,12 +303,12 @@ typedef void (*uiListDrawItemFunc)(struct uiList *ui_list,
/* Draw the filtering part of an uiList */
typedef void (*uiListDrawFilterFunc)(struct uiList *ui_list,
struct bContext *C,
const struct bContext *C,
struct uiLayout *layout);
/* Filter items of an uiList */
typedef void (*uiListFilterItemsFunc)(struct uiList *ui_list,
struct bContext *C,
const struct bContext *C,
struct PointerRNA *,
const char *propname);

View File

@@ -53,6 +53,7 @@
#include "BIK_api.h"
#include "RNA_access.h"
#include "RNA_path.h"
#include "RNA_prototypes.h"
#include "BLO_read_write.h"
@@ -1950,7 +1951,7 @@ void BKE_pose_blend_read_lib(BlendLibReader *reader, Object *ob, bPose *pose)
pchan->bone = BKE_armature_find_bone_name(arm, pchan->name);
IDP_BlendReadLib(reader, pchan->prop);
IDP_BlendReadLib(reader, ob->id.lib, pchan->prop);
BLO_read_id_address(reader, ob->id.lib, &pchan->custom);
if (UNLIKELY(pchan->bone == NULL)) {

View File

@@ -43,6 +43,7 @@
#include "BLO_read_write.h"
#include "RNA_access.h"
#include "RNA_path.h"
#include "CLG_log.h"

View File

@@ -53,6 +53,7 @@
#include "DEG_depsgraph_query.h"
#include "RNA_access.h"
#include "RNA_path.h"
#include "RNA_prototypes.h"
#include "BLO_read_write.h"

View File

@@ -261,12 +261,12 @@ static void armature_blend_read_data(BlendDataReader *reader, ID *id)
BKE_armature_bone_hash_make(arm);
}
static void lib_link_bones(BlendLibReader *reader, Bone *bone)
static void lib_link_bones(BlendLibReader *reader, Library *lib, Bone *bone)
{
IDP_BlendReadLib(reader, bone->prop);
IDP_BlendReadLib(reader, lib, bone->prop);
LISTBASE_FOREACH (Bone *, curbone, &bone->childbase) {
lib_link_bones(reader, curbone);
lib_link_bones(reader, lib, curbone);
}
}
@@ -274,7 +274,7 @@ static void armature_blend_read_lib(BlendLibReader *reader, ID *id)
{
bArmature *arm = (bArmature *)id;
LISTBASE_FOREACH (Bone *, curbone, &arm->bonebase) {
lib_link_bones(reader, curbone);
lib_link_bones(reader, id->lib, curbone);
}
}

View File

@@ -73,7 +73,7 @@ static void set_crazy_vertex_quat(float r_quat[4],
static bool modifiers_disable_subsurf_temporary(struct Scene *scene, Object *ob)
{
bool disabled = false;
int cageIndex = BKE_modifiers_get_cage_index(scene, ob, nullptr, 1);
int cageIndex = BKE_modifiers_get_cage_index(scene, ob, nullptr, true);
ModifierData *md = static_cast<ModifierData *>(ob->modifiers.first);
for (int i = 0; md && i <= cageIndex; i++, md = md->next) {
@@ -241,7 +241,7 @@ int BKE_crazyspace_get_first_deform_matrices_editbmesh(struct Depsgraph *depsgra
Mesh *me_input = static_cast<Mesh *>(ob->data);
Mesh *me = nullptr;
int i, a, modifiers_left_num = 0, verts_num = 0;
int cageIndex = BKE_modifiers_get_cage_index(scene, ob, nullptr, 1);
int cageIndex = BKE_modifiers_get_cage_index(scene, ob, nullptr, true);
float(*defmats)[3][3] = nullptr, (*deformedVerts)[3] = nullptr;
VirtualModifierData virtualModifierData;
ModifierEvalContext mectx = {depsgraph, ob, ModifierApplyFlag(0)};
@@ -362,7 +362,7 @@ int BKE_sculpt_get_first_deform_matrices(struct Depsgraph *depsgraph,
VirtualModifierData virtualModifierData;
Object object_eval;
crazyspace_init_object_for_eval(depsgraph, object, &object_eval);
MultiresModifierData *mmd = get_multires_modifier(scene, &object_eval, 0);
MultiresModifierData *mmd = get_multires_modifier(scene, &object_eval, false);
const bool is_sculpt_mode = (object->mode & OB_MODE_SCULPT) != 0;
const bool has_multires = mmd != nullptr && mmd->sculptlvl > 0;
const ModifierEvalContext mectx = {depsgraph, &object_eval, ModifierApplyFlag(0)};

View File

@@ -37,6 +37,7 @@
#include "BLO_read_write.h"
#include "RNA_access.h"
#include "RNA_path.h"
#include "CLG_log.h"

View File

@@ -30,6 +30,7 @@
#include "BKE_object.h"
#include "RNA_access.h"
#include "RNA_path.h"
#include "atomic_ops.h"

View File

@@ -1428,7 +1428,7 @@ void IDP_BlendReadData_impl(BlendDataReader *reader, IDProperty **prop, const ch
}
}
void IDP_BlendReadLib(BlendLibReader *reader, IDProperty *prop)
void IDP_BlendReadLib(BlendLibReader *reader, Library *lib, IDProperty *prop)
{
if (!prop) {
return;
@@ -1437,7 +1437,7 @@ void IDP_BlendReadLib(BlendLibReader *reader, IDProperty *prop)
switch (prop->type) {
case IDP_ID: /* PointerProperty */
{
void *newaddr = BLO_read_get_new_id_address(reader, NULL, IDP_Id(prop));
void *newaddr = BLO_read_get_new_id_address(reader, lib, IDP_Id(prop));
if (IDP_Id(prop) && !newaddr && G.debug) {
printf("Error while loading \"%s\". Data not found in file!\n", prop->name);
}
@@ -1448,14 +1448,14 @@ void IDP_BlendReadLib(BlendLibReader *reader, IDProperty *prop)
{
IDProperty *idp_array = IDP_IDPArray(prop);
for (int i = 0; i < prop->len; i++) {
IDP_BlendReadLib(reader, &(idp_array[i]));
IDP_BlendReadLib(reader, lib, &(idp_array[i]));
}
break;
}
case IDP_GROUP: /* PointerProperty */
{
LISTBASE_FOREACH (IDProperty *, loop, &prop->data.group) {
IDP_BlendReadLib(reader, loop);
IDP_BlendReadLib(reader, lib, loop);
}
break;
}

View File

@@ -44,6 +44,14 @@ std::unique_ptr<IDProperty, IDPropertyDeleter> create(const StringRefNull prop_n
return std::unique_ptr<IDProperty, IDPropertyDeleter>(property);
}
std::unique_ptr<IDProperty, IDPropertyDeleter> create(const StringRefNull prop_name, ID *value)
{
IDPropertyTemplate prop_template{0};
prop_template.id = value;
IDProperty *property = IDP_New(IDP_ID, &prop_template, prop_name.c_str());
return std::unique_ptr<IDProperty, IDPropertyDeleter>(property);
}
static std::unique_ptr<IDProperty, IDPropertyDeleter> array_create(const StringRefNull prop_name,
eIDPropertyType subtype,
size_t array_len)

View File

@@ -3410,9 +3410,8 @@ void BKE_image_ensure_tile_token(char *filename)
/* General 4-digit "udim" pattern. As this format is susceptible to ambiguity
* with other digit sequences, we can leverage the supported range of roughly
* 1000 through 2000 to provide better detection.
*/
std::regex pattern(R"((^|.*?\D)([12]\d{3})(\D.*))");
* 1000 through 2000 to provide better detection. */
std::regex pattern(R"((.*[._-])([12]\d{3})([._-].*))");
if (std::regex_search(path, match, pattern)) {
BLI_strncpy(filename, match.format("$1<UDIM>$3").c_str(), FILE_MAX);
return;

View File

@@ -32,8 +32,12 @@ TEST(udim, image_ensure_tile_token)
verify("test_1002_ao.png", "test_<UDIM>_ao.png");
verify("test.1002.ver0023.png", "test.<UDIM>.ver0023.png");
verify("test.ver0023.1002.png", "test.ver0023.<UDIM>.png");
verify("1002test.png", "<UDIM>test.png");
verify("test1002.png", "test<UDIM>.png");
verify("test.1002.1.png", "test.<UDIM>.1.png");
verify("test.1.1002.png", "test.1.<UDIM>.png");
verify("test-2022-01-01.1002.png", "test-2022-01-01.<UDIM>.png");
verify("1111_11.1002.png", "1111_11.<UDIM>.png");
verify("2111_01.1002.png", "2111_01.<UDIM>.png");
verify("2022_1002_100200.1002.png", "2022_1002_100200.<UDIM>.png");
/* UVTILE pattern detection. */
verify("uv-test.u2_v10.png", "uv-test.<UVTILE>.png");
@@ -44,8 +48,15 @@ TEST(udim, image_ensure_tile_token)
verify("u2_v10uv-test.png", "<UVTILE>uv-test.png");
verify("u2_v10u_v-test.png", "<UVTILE>u_v-test.png");
/* Incorrect patterns. */
for (const char *incorrect : {"test.123.png",
/* Patterns which should not be detected as UDIMs. */
for (const char *incorrect : {"1002.png",
"1002test.png",
"test1002.png",
"test(1002).png",
"(1002)test.png",
"test-1080p.png",
"test-1920x1080.png",
"test.123.png",
"test.12345.png",
"test.uv.png",
"test.u1v.png",

View File

@@ -46,6 +46,7 @@
#include "BKE_scene.h"
#include "RNA_access.h"
#include "RNA_path.h"
#include "RNA_prototypes.h"
#include "BLO_read_write.h"

View File

@@ -2384,7 +2384,7 @@ void BKE_view_layer_blend_read_lib(BlendLibReader *reader, Library *lib, ViewLay
BLO_read_id_address(reader, lib, &view_layer->mat_override);
IDP_BlendReadLib(reader, view_layer->id_properties);
IDP_BlendReadLib(reader, lib, view_layer->id_properties);
}
/** \} */

View File

@@ -52,6 +52,7 @@
#include "PIL_time.h"
#include "RNA_access.h"
#include "RNA_path.h"
#include "RNA_prototypes.h"
#include "RNA_types.h"

View File

@@ -835,7 +835,7 @@ static void ntree_blend_read_data(BlendDataReader *reader, ID *id)
static void lib_link_node_socket(BlendLibReader *reader, Library *lib, bNodeSocket *sock)
{
IDP_BlendReadLib(reader, sock->prop);
IDP_BlendReadLib(reader, lib, sock->prop);
/* This can happen for all socket types when a file is saved in an older version of Blender than
* it was originally created in (T86298). Some socket types still require a default value. The
@@ -901,7 +901,7 @@ void ntreeBlendReadLib(struct BlendLibReader *reader, struct bNodeTree *ntree)
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
/* Link ID Properties -- and copy this comment EXACTLY for easy finding
* of library blocks that implement this. */
IDP_BlendReadLib(reader, node->prop);
IDP_BlendReadLib(reader, lib, node->prop);
BLO_read_id_address(reader, lib, &node->id);

View File

@@ -1433,10 +1433,10 @@ static void sculptsession_free_pbvh(Object *object)
MEM_SAFE_FREE(ss->persistent_base);
MEM_SAFE_FREE(ss->preview_vert_index_list);
ss->preview_vert_index_count = 0;
MEM_SAFE_FREE(ss->preview_vert_list);
ss->preview_vert_count = 0;
MEM_SAFE_FREE(ss->preview_vert_index_list);
MEM_SAFE_FREE(ss->preview_vert_list);
MEM_SAFE_FREE(ss->vertex_info.connected_component);
MEM_SAFE_FREE(ss->vertex_info.boundary);

View File

@@ -555,7 +555,7 @@ void BKE_pbvh_build_mesh(PBVH *pbvh,
BB cb;
pbvh->mesh = mesh;
pbvh->type = PBVH_FACES;
pbvh->header.type = PBVH_FACES;
pbvh->mpoly = mpoly;
pbvh->mloop = mloop;
pbvh->looptri = looptri;
@@ -615,7 +615,7 @@ void BKE_pbvh_build_grids(PBVH *pbvh,
{
const int gridsize = key->grid_size;
pbvh->type = PBVH_GRIDS;
pbvh->header.type = PBVH_GRIDS;
pbvh->grids = grids;
pbvh->gridfaces = gridfaces;
pbvh->grid_flag_mats = flagmats;
@@ -1305,17 +1305,17 @@ static void pbvh_update_draw_buffer_cb(void *__restrict userdata,
CustomData *vdata, *ldata;
if (!pbvh->bm) {
if (!pbvh->header.bm) {
vdata = pbvh->vdata;
ldata = pbvh->ldata;
}
else {
vdata = &pbvh->bm->vdata;
ldata = &pbvh->bm->ldata;
vdata = &pbvh->header.bm->vdata;
ldata = &pbvh->header.bm->ldata;
}
if (node->flag & PBVH_RebuildDrawBuffers) {
switch (pbvh->type) {
switch (pbvh->header.type) {
case PBVH_GRIDS: {
bool smooth = node->totprim > 0 ?
pbvh->grid_flag_mats[node->prim_indices[0]].flag & ME_SMOOTH :
@@ -1344,7 +1344,7 @@ static void pbvh_update_draw_buffer_cb(void *__restrict userdata,
if (node->flag & PBVH_UpdateDrawBuffers) {
const int update_flags = pbvh_get_buffers_update_flags(pbvh);
switch (pbvh->type) {
switch (pbvh->header.type) {
case PBVH_GRIDS:
GPU_pbvh_grid_buffers_update(pbvh->vbo_id,
node->draw_buffers,
@@ -1376,7 +1376,7 @@ static void pbvh_update_draw_buffer_cb(void *__restrict userdata,
case PBVH_BMESH:
GPU_pbvh_bmesh_buffers_update(pbvh->vbo_id,
node->draw_buffers,
pbvh->bm,
pbvh->header.bm,
node->bm_faces,
node->bm_unique_verts,
node->bm_other_verts,
@@ -1405,15 +1405,15 @@ static void pbvh_check_draw_layout(PBVH *pbvh)
pbvh->vbo_id = GPU_pbvh_make_format();
}
switch (pbvh->type) {
switch (pbvh->header.type) {
case PBVH_BMESH:
if (!pbvh->bm) {
if (!pbvh->header.bm) {
/* BMesh hasn't been created yet */
return;
}
vdata = &pbvh->bm->vdata;
ldata = &pbvh->bm->ldata;
vdata = &pbvh->header.bm->vdata;
ldata = &pbvh->header.bm->ldata;
break;
case PBVH_FACES:
vdata = pbvh->vdata;
@@ -1431,7 +1431,7 @@ static void pbvh_check_draw_layout(PBVH *pbvh)
* (there's no guarantee there isn't another EEVEE viewport which would
* free the draw buffers and corrupt the draw cache).
*/
if (GPU_pbvh_attribute_names_update(pbvh->type, pbvh->vbo_id, vdata, ldata, false)) {
if (GPU_pbvh_attribute_names_update(pbvh->header.type, pbvh->vbo_id, vdata, ldata, false)) {
/* attribute layout changed; force rebuild */
for (int i = 0; i < pbvh->totnode; i++) {
PBVHNode *node = pbvh->nodes + i;
@@ -1451,14 +1451,14 @@ static void pbvh_update_draw_buffers(PBVH *pbvh, PBVHNode **nodes, int totnode,
pbvh->vbo_id = GPU_pbvh_make_format();
}
switch (pbvh->type) {
switch (pbvh->header.type) {
case PBVH_BMESH:
if (!pbvh->bm) {
if (!pbvh->header.bm) {
/* BMesh hasn't been created yet */
return;
}
vdata = &pbvh->bm->vdata;
vdata = &pbvh->header.bm->vdata;
break;
case PBVH_FACES:
vdata = pbvh->vdata;
@@ -1469,7 +1469,7 @@ static void pbvh_update_draw_buffers(PBVH *pbvh, PBVHNode **nodes, int totnode,
}
UNUSED_VARS(vdata);
if ((update_flag & PBVH_RebuildDrawBuffers) || ELEM(pbvh->type, PBVH_GRIDS, PBVH_BMESH)) {
if ((update_flag & PBVH_RebuildDrawBuffers) || ELEM(pbvh->header.type, PBVH_GRIDS, PBVH_BMESH)) {
/* Free buffers uses OpenGL, so not in parallel. */
for (int n = 0; n < totnode; n++) {
PBVHNode *node = nodes[n];
@@ -1477,11 +1477,11 @@ static void pbvh_update_draw_buffers(PBVH *pbvh, PBVHNode **nodes, int totnode,
pbvh_free_draw_buffers(pbvh, node);
}
else if ((node->flag & PBVH_UpdateDrawBuffers) && node->draw_buffers) {
if (pbvh->type == PBVH_GRIDS) {
if (pbvh->header.type == PBVH_GRIDS) {
GPU_pbvh_grid_buffers_update_free(
node->draw_buffers, pbvh->grid_flag_mats, node->prim_indices);
}
else if (pbvh->type == PBVH_BMESH) {
else if (pbvh->header.type == PBVH_BMESH) {
GPU_pbvh_bmesh_buffers_update_free(node->draw_buffers);
}
}
@@ -1795,15 +1795,10 @@ void BKE_pbvh_get_grid_updates(PBVH *pbvh, bool clear, void ***r_gridfaces, int
/***************************** PBVH Access ***********************************/
PBVHType BKE_pbvh_type(const PBVH *pbvh)
{
return pbvh->type;
}
bool BKE_pbvh_has_faces(const PBVH *pbvh)
{
if (pbvh->type == PBVH_BMESH) {
return (pbvh->bm->totface != 0);
if (pbvh->header.type == PBVH_BMESH) {
return (pbvh->header.bm->totface != 0);
}
return (pbvh->totprim != 0);
@@ -1824,46 +1819,40 @@ void BKE_pbvh_bounding_box(const PBVH *pbvh, float min[3], float max[3])
BLI_bitmap **BKE_pbvh_grid_hidden(const PBVH *pbvh)
{
BLI_assert(pbvh->type == PBVH_GRIDS);
BLI_assert(pbvh->header.type == PBVH_GRIDS);
return pbvh->grid_hidden;
}
const CCGKey *BKE_pbvh_get_grid_key(const PBVH *pbvh)
{
BLI_assert(pbvh->type == PBVH_GRIDS);
BLI_assert(pbvh->header.type == PBVH_GRIDS);
return &pbvh->gridkey;
}
struct CCGElem **BKE_pbvh_get_grids(const PBVH *pbvh)
{
BLI_assert(pbvh->type == PBVH_GRIDS);
BLI_assert(pbvh->header.type == PBVH_GRIDS);
return pbvh->grids;
}
BLI_bitmap **BKE_pbvh_get_grid_visibility(const PBVH *pbvh)
{
BLI_assert(pbvh->type == PBVH_GRIDS);
BLI_assert(pbvh->header.type == PBVH_GRIDS);
return pbvh->grid_hidden;
}
int BKE_pbvh_get_grid_num_vertices(const PBVH *pbvh)
{
BLI_assert(pbvh->type == PBVH_GRIDS);
BLI_assert(pbvh->header.type == PBVH_GRIDS);
return pbvh->totgrid * pbvh->gridkey.grid_area;
}
int BKE_pbvh_get_grid_num_faces(const PBVH *pbvh)
{
BLI_assert(pbvh->type == PBVH_GRIDS);
BLI_assert(pbvh->header.type == PBVH_GRIDS);
return pbvh->totgrid * (pbvh->gridkey.grid_size - 1) * (pbvh->gridkey.grid_size - 1);
}
BMesh *BKE_pbvh_get_bmesh(PBVH *pbvh)
{
BLI_assert(pbvh->type == PBVH_BMESH);
return pbvh->bm;
}
/***************************** Node Access ***********************************/
void BKE_pbvh_node_mark_update(PBVHNode *node)
@@ -1964,10 +1953,10 @@ bool BKE_pbvh_node_fully_unmasked_get(PBVHNode *node)
return (node->flag & PBVH_Leaf) && (node->flag & PBVH_FullyUnmasked);
}
void BKE_pbvh_vert_mark_update(PBVH *pbvh, int index)
void BKE_pbvh_vert_mark_update(PBVH *pbvh, PBVHVertRef index)
{
BLI_assert(pbvh->type == PBVH_FACES);
pbvh->vert_bitmap[index] = true;
BLI_assert(pbvh->header.type == PBVH_FACES);
pbvh->vert_bitmap[index.i] = true;
}
void BKE_pbvh_node_get_loops(PBVH *pbvh,
@@ -2004,7 +1993,7 @@ void BKE_pbvh_node_num_verts(PBVH *pbvh, PBVHNode *node, int *r_uniquevert, int
{
int tot;
switch (pbvh->type) {
switch (pbvh->header.type) {
case PBVH_GRIDS:
tot = node->totprim * pbvh->gridkey.grid_area;
if (r_totvert) {
@@ -2042,7 +2031,7 @@ void BKE_pbvh_node_get_grids(PBVH *pbvh,
int *r_gridsize,
CCGElem ***r_griddata)
{
switch (pbvh->type) {
switch (pbvh->header.type) {
case PBVH_GRIDS:
if (r_grid_indices) {
*r_grid_indices = node->prim_indices;
@@ -2125,7 +2114,7 @@ void BKE_pbvh_node_get_bm_orco_data(PBVHNode *node,
bool BKE_pbvh_node_vert_update_check_any(PBVH *pbvh, PBVHNode *node)
{
BLI_assert(pbvh->type == PBVH_FACES);
BLI_assert(pbvh->header.type == PBVH_FACES);
const int *verts = node->vert_indices;
const int totvert = node->uniq_verts + node->face_verts;
@@ -2299,7 +2288,7 @@ static bool pbvh_faces_node_raycast(PBVH *pbvh,
const float ray_normal[3],
struct IsectRayPrecalc *isect_precalc,
float *depth,
int *r_active_vertex_index,
PBVHVertRef *r_active_vertex,
int *r_active_face_index,
float *r_face_normal)
{
@@ -2339,7 +2328,7 @@ static bool pbvh_faces_node_raycast(PBVH *pbvh,
normal_tri_v3(r_face_normal, co[0], co[1], co[2]);
}
if (r_active_vertex_index) {
if (r_active_vertex) {
float location[3] = {0.0f};
madd_v3_v3v3fl(location, ray_start, ray_normal, *depth);
for (int j = 0; j < 3; j++) {
@@ -2349,7 +2338,7 @@ static bool pbvh_faces_node_raycast(PBVH *pbvh,
if (j == 0 ||
len_squared_v3v3(location, co[j]) < len_squared_v3v3(location, nearest_vertex_co)) {
copy_v3_v3(nearest_vertex_co, co[j]);
*r_active_vertex_index = mloop[lt->tri[j]].v;
r_active_vertex->i = mloop[lt->tri[j]].v;
*r_active_face_index = lt->poly;
}
}
@@ -2367,7 +2356,7 @@ static bool pbvh_grids_node_raycast(PBVH *pbvh,
const float ray_normal[3],
struct IsectRayPrecalc *isect_precalc,
float *depth,
int *r_active_vertex_index,
PBVHVertRef *r_active_vertex,
int *r_active_grid_index,
float *r_face_normal)
{
@@ -2419,7 +2408,7 @@ static bool pbvh_grids_node_raycast(PBVH *pbvh,
normal_quad_v3(r_face_normal, co[0], co[1], co[2], co[3]);
}
if (r_active_vertex_index) {
if (r_active_vertex) {
float location[3] = {0.0};
madd_v3_v3v3fl(location, ray_start, ray_normal, *depth);
@@ -2434,8 +2423,8 @@ static bool pbvh_grids_node_raycast(PBVH *pbvh,
len_squared_v3v3(location, nearest_vertex_co)) {
copy_v3_v3(nearest_vertex_co, co[j]);
*r_active_vertex_index = gridkey->grid_area * grid_index +
(y + y_it[j]) * gridkey->grid_size + (x + x_it[j]);
r_active_vertex->i = gridkey->grid_area * grid_index +
(y + y_it[j]) * gridkey->grid_size + (x + x_it[j]);
}
}
}
@@ -2462,7 +2451,7 @@ bool BKE_pbvh_node_raycast(PBVH *pbvh,
const float ray_normal[3],
struct IsectRayPrecalc *isect_precalc,
float *depth,
int *active_vertex_index,
PBVHVertRef *active_vertex,
int *active_face_grid_index,
float *face_normal)
{
@@ -2472,7 +2461,7 @@ bool BKE_pbvh_node_raycast(PBVH *pbvh,
return false;
}
switch (pbvh->type) {
switch (pbvh->header.type) {
case PBVH_FACES:
hit |= pbvh_faces_node_raycast(pbvh,
node,
@@ -2481,7 +2470,7 @@ bool BKE_pbvh_node_raycast(PBVH *pbvh,
ray_normal,
isect_precalc,
depth,
active_vertex_index,
active_vertex,
active_face_grid_index,
face_normal);
break;
@@ -2493,19 +2482,19 @@ bool BKE_pbvh_node_raycast(PBVH *pbvh,
ray_normal,
isect_precalc,
depth,
active_vertex_index,
active_vertex,
active_face_grid_index,
face_normal);
break;
case PBVH_BMESH:
BM_mesh_elem_index_ensure(pbvh->bm, BM_VERT);
BM_mesh_elem_index_ensure(pbvh->header.bm, BM_VERT);
hit = pbvh_bmesh_node_raycast(node,
ray_start,
ray_normal,
isect_precalc,
depth,
use_origco,
active_vertex_index,
active_vertex,
face_normal);
break;
}
@@ -2729,7 +2718,7 @@ bool BKE_pbvh_node_find_nearest_to_ray(PBVH *pbvh,
return false;
}
switch (pbvh->type) {
switch (pbvh->header.type) {
case PBVH_FACES:
hit |= pbvh_faces_node_nearest_to_ray(
pbvh, node, origco, ray_start, ray_normal, depth, dist_sq);
@@ -2820,13 +2809,13 @@ void BKE_pbvh_update_normals(PBVH *pbvh, struct SubdivCCG *subdiv_ccg)
pbvh, update_search_cb, POINTER_FROM_INT(PBVH_UpdateNormals), &nodes, &totnode);
if (totnode > 0) {
if (pbvh->type == PBVH_BMESH) {
if (pbvh->header.type == PBVH_BMESH) {
pbvh_bmesh_normals_update(nodes, totnode);
}
else if (pbvh->type == PBVH_FACES) {
else if (pbvh->header.type == PBVH_FACES) {
pbvh_faces_update_normals(pbvh, nodes, totnode);
}
else if (pbvh->type == PBVH_GRIDS) {
else if (pbvh->header.type == PBVH_GRIDS) {
struct CCGFace **faces;
int num_faces;
BKE_pbvh_get_grid_updates(pbvh, true, (void ***)&faces, &num_faces);
@@ -2991,7 +2980,7 @@ void BKE_pbvh_vert_coords_apply(PBVH *pbvh, const float (*vertCos)[3], const int
/* no need for float comparison here (memory is exactly equal or not) */
if (memcmp(mvert->co, vertCos[a], sizeof(float[3])) != 0) {
copy_v3_v3(mvert->co, vertCos[a]);
BKE_pbvh_vert_mark_update(pbvh, a);
BKE_pbvh_vert_mark_update(pbvh, BKE_pbvh_make_vref(a));
}
}
@@ -3108,6 +3097,7 @@ void pbvh_vertex_iter_init(PBVH *pbvh, PBVHNode *node, PBVHVertexIter *vi, int m
vi->no = NULL;
vi->fno = NULL;
vi->mvert = NULL;
vi->vertex.i = 0LL;
vi->respect_hide = pbvh->respect_hide;
if (pbvh->respect_hide == false) {
@@ -3134,10 +3124,10 @@ void pbvh_vertex_iter_init(PBVH *pbvh, PBVHNode *node, PBVHVertexIter *vi, int m
vi->vert_indices = vert_indices;
vi->mverts = verts;
if (pbvh->type == PBVH_BMESH) {
if (pbvh->header.type == PBVH_BMESH) {
BLI_gsetIterator_init(&vi->bm_unique_verts, node->bm_unique_verts);
BLI_gsetIterator_init(&vi->bm_other_verts, node->bm_other_verts);
vi->bm_vdata = &pbvh->bm->vdata;
vi->bm_vdata = &pbvh->header.bm->vdata;
vi->cd_vert_mask_offset = CustomData_get_offset(vi->bm_vdata, CD_PAINT_MASK);
}
@@ -3147,7 +3137,7 @@ void pbvh_vertex_iter_init(PBVH *pbvh, PBVHNode *node, PBVHVertexIter *vi, int m
}
vi->mask = NULL;
if (pbvh->type == PBVH_FACES) {
if (pbvh->header.type == PBVH_FACES) {
vi->vert_normals = pbvh->vert_normals;
vi->vmask = CustomData_get_layer(pbvh->vdata, CD_PAINT_MASK);
@@ -3156,13 +3146,14 @@ void pbvh_vertex_iter_init(PBVH *pbvh, PBVHNode *node, PBVHVertexIter *vi, int m
bool pbvh_has_mask(const PBVH *pbvh)
{
switch (pbvh->type) {
switch (pbvh->header.type) {
case PBVH_GRIDS:
return (pbvh->gridkey.has_mask != 0);
case PBVH_FACES:
return (pbvh->vdata && CustomData_get_layer(pbvh->vdata, CD_PAINT_MASK));
case PBVH_BMESH:
return (pbvh->bm && (CustomData_get_offset(&pbvh->bm->vdata, CD_PAINT_MASK) != -1));
return (pbvh->header.bm &&
(CustomData_get_offset(&pbvh->header.bm->vdata, CD_PAINT_MASK) != -1));
}
return false;
@@ -3170,7 +3161,7 @@ bool pbvh_has_mask(const PBVH *pbvh)
bool pbvh_has_face_sets(PBVH *pbvh)
{
switch (pbvh->type) {
switch (pbvh->header.type) {
case PBVH_GRIDS:
return (pbvh->pdata && CustomData_get_layer(pbvh->pdata, CD_SCULPT_FACE_SETS));
case PBVH_FACES:
@@ -3218,13 +3209,13 @@ void BKE_pbvh_parallel_range_settings(TaskParallelSettings *settings,
MVert *BKE_pbvh_get_verts(const PBVH *pbvh)
{
BLI_assert(pbvh->type == PBVH_FACES);
BLI_assert(pbvh->header.type == PBVH_FACES);
return pbvh->verts;
}
const float (*BKE_pbvh_get_vert_normals(const PBVH *pbvh))[3]
{
BLI_assert(pbvh->type == PBVH_FACES);
BLI_assert(pbvh->header.type == PBVH_FACES);
return pbvh->vert_normals;
}
@@ -3242,6 +3233,7 @@ void BKE_pbvh_respect_hide_set(PBVH *pbvh, bool respect_hide)
{
pbvh->respect_hide = respect_hide;
}
bool BKE_pbvh_is_drawing(const PBVH *pbvh)
{
return pbvh->is_drawing;

View File

@@ -86,10 +86,12 @@ template<> void from_float(const float src[4], MPropCol &dst)
}
template<typename T>
static void pbvh_vertex_color_get(const PBVH &pbvh, int vertex, float r_color[4])
static void pbvh_vertex_color_get(const PBVH &pbvh, PBVHVertRef vertex, float r_color[4])
{
int index = vertex.i;
if (pbvh.color_domain == ATTR_DOMAIN_CORNER) {
const MeshElemMap &melem = pbvh.pmap[vertex];
const MeshElemMap &melem = pbvh.pmap[index];
int count = 0;
zero_v4(r_color);
@@ -99,7 +101,7 @@ static void pbvh_vertex_color_get(const PBVH &pbvh, int vertex, float r_color[4]
Span<MLoop> loops{pbvh.mloop + mp.loopstart, mp.totloop};
for (const int i_loop : IndexRange(mp.totloop)) {
if (loops[i_loop].v == vertex) {
if (loops[i_loop].v == index) {
float temp[4];
to_float(colors[i_loop], temp);
@@ -114,15 +116,17 @@ static void pbvh_vertex_color_get(const PBVH &pbvh, int vertex, float r_color[4]
}
}
else {
to_float(static_cast<T *>(pbvh.color_layer->data)[vertex], r_color);
to_float(static_cast<T *>(pbvh.color_layer->data)[index], r_color);
}
}
template<typename T>
static void pbvh_vertex_color_set(PBVH &pbvh, int vertex, const float color[4])
static void pbvh_vertex_color_set(PBVH &pbvh, PBVHVertRef vertex, const float color[4])
{
int index = vertex.i;
if (pbvh.color_domain == ATTR_DOMAIN_CORNER) {
const MeshElemMap &melem = pbvh.pmap[vertex];
const MeshElemMap &melem = pbvh.pmap[index];
for (const int i_poly : Span(melem.indices, melem.count)) {
const MPoly &mp = pbvh.mpoly[i_poly];
@@ -130,21 +134,21 @@ static void pbvh_vertex_color_set(PBVH &pbvh, int vertex, const float color[4])
Span<MLoop> loops{pbvh.mloop + mp.loopstart, mp.totloop};
for (const int i_loop : IndexRange(mp.totloop)) {
if (loops[i_loop].v == vertex) {
if (loops[i_loop].v == index) {
from_float(color, colors[i_loop]);
}
}
}
}
else {
from_float(color, static_cast<T *>(pbvh.color_layer->data)[vertex]);
from_float(color, static_cast<T *>(pbvh.color_layer->data)[index]);
}
}
} // namespace blender::bke
extern "C" {
void BKE_pbvh_vertex_color_get(const PBVH *pbvh, int vertex, float r_color[4])
void BKE_pbvh_vertex_color_get(const PBVH *pbvh, PBVHVertRef vertex, float r_color[4])
{
blender::bke::to_static_color_type(eCustomDataType(pbvh->color_layer->type), [&](auto dummy) {
using T = decltype(dummy);
@@ -152,7 +156,7 @@ void BKE_pbvh_vertex_color_get(const PBVH *pbvh, int vertex, float r_color[4])
});
}
void BKE_pbvh_vertex_color_set(PBVH *pbvh, int vertex, const float color[4])
void BKE_pbvh_vertex_color_set(PBVH *pbvh, PBVHVertRef vertex, const float color[4])
{
blender::bke::to_static_color_type(eCustomDataType(pbvh->color_layer->type), [&](auto dummy) {
using T = decltype(dummy);
@@ -202,7 +206,7 @@ void BKE_pbvh_store_colors_vertex(PBVH *pbvh,
blender::bke::to_static_color_type(eCustomDataType(pbvh->color_layer->type), [&](auto dummy) {
using T = decltype(dummy);
for (const int i : IndexRange(indices_num)) {
blender::bke::pbvh_vertex_color_get<T>(*pbvh, indices[i], r_colors[i]);
blender::bke::pbvh_vertex_color_get<T>(*pbvh, BKE_pbvh_make_vref(indices[i]), r_colors[i]);
}
});
}

View File

@@ -400,7 +400,7 @@ static bool pbvh_bmesh_node_limit_ensure(PBVH *pbvh, int node_index)
BM_elem_index_set(f, i); /* set_dirty! */
}
/* Likely this is already dirty. */
pbvh->bm->elem_index_dirty |= BM_FACE;
pbvh->header.bm->elem_index_dirty |= BM_FACE;
pbvh_bmesh_node_split(pbvh, bbc_array, node_index);
@@ -484,8 +484,8 @@ static BMVert *pbvh_bmesh_vert_create(PBVH *pbvh,
BLI_assert((pbvh->totnode == 1 || node_index) && node_index <= pbvh->totnode);
/* avoid initializing customdata because its quite involved */
BMVert *v = BM_vert_create(pbvh->bm, co, NULL, BM_CREATE_SKIP_CD);
CustomData_bmesh_set_default(&pbvh->bm->vdata, &v->head.data);
BMVert *v = BM_vert_create(pbvh->header.bm, co, NULL, BM_CREATE_SKIP_CD);
CustomData_bmesh_set_default(&pbvh->header.bm->vdata, &v->head.data);
/* This value is logged below */
copy_v3_v3(v->no, no);
@@ -512,7 +512,7 @@ static BMFace *pbvh_bmesh_face_create(
/* ensure we never add existing face */
BLI_assert(!BM_face_exists(v_tri, 3));
BMFace *f = BM_face_create(pbvh->bm, v_tri, e_tri, 3, f_example, BM_CREATE_NOP);
BMFace *f = BM_face_create(pbvh->header.bm, v_tri, e_tri, 3, f_example, BM_CREATE_NOP);
f->head.hflag = f_example->head.hflag;
BLI_gset_insert(node->bm_faces, f);
@@ -1185,22 +1185,22 @@ static void pbvh_bmesh_split_edge(EdgeQueueContext *eq_ctx,
v_tri[0] = v1;
v_tri[1] = v_new;
v_tri[2] = v_opp;
bm_edges_from_tri(pbvh->bm, v_tri, e_tri);
bm_edges_from_tri(pbvh->header.bm, v_tri, e_tri);
f_new = pbvh_bmesh_face_create(pbvh, ni, v_tri, e_tri, f_adj);
long_edge_queue_face_add(eq_ctx, f_new);
v_tri[0] = v_new;
v_tri[1] = v2;
/* v_tri[2] = v_opp; */ /* unchanged */
e_tri[0] = BM_edge_create(pbvh->bm, v_tri[0], v_tri[1], NULL, BM_CREATE_NO_DOUBLE);
e_tri[0] = BM_edge_create(pbvh->header.bm, v_tri[0], v_tri[1], NULL, BM_CREATE_NO_DOUBLE);
e_tri[2] = e_tri[1]; /* switched */
e_tri[1] = BM_edge_create(pbvh->bm, v_tri[1], v_tri[2], NULL, BM_CREATE_NO_DOUBLE);
e_tri[1] = BM_edge_create(pbvh->header.bm, v_tri[1], v_tri[2], NULL, BM_CREATE_NO_DOUBLE);
f_new = pbvh_bmesh_face_create(pbvh, ni, v_tri, e_tri, f_adj);
long_edge_queue_face_add(eq_ctx, f_new);
/* Delete original */
pbvh_bmesh_face_remove(pbvh, f_adj);
BM_face_kill(pbvh->bm, f_adj);
BM_face_kill(pbvh->header.bm, f_adj);
/* Ensure new vertex is in the node */
if (!BLI_gset_haskey(pbvh->nodes[ni].bm_unique_verts, v_new)) {
@@ -1217,7 +1217,7 @@ static void pbvh_bmesh_split_edge(EdgeQueueContext *eq_ctx,
}
}
BM_edge_kill(pbvh->bm, e);
BM_edge_kill(pbvh->header.bm, e);
}
static bool pbvh_bmesh_subdivide_long_edges(EdgeQueueContext *eq_ctx,
@@ -1303,12 +1303,12 @@ static void pbvh_bmesh_collapse_edge(PBVH *pbvh,
BMFace *f_adj = l_adj->f;
pbvh_bmesh_face_remove(pbvh, f_adj);
BM_face_kill(pbvh->bm, f_adj);
BM_face_kill(pbvh->header.bm, f_adj);
}
/* Kill the edge */
BLI_assert(BM_edge_is_wire(e));
BM_edge_kill(pbvh->bm, e);
BM_edge_kill(pbvh->header.bm, e);
/* For all remaining faces of v_del, create a new face that is the
* same except it uses v_conn instead of v_del */
@@ -1355,7 +1355,7 @@ static void pbvh_bmesh_collapse_edge(PBVH *pbvh,
BMEdge *e_tri[3];
PBVHNode *n = pbvh_bmesh_node_from_face(pbvh, f);
int ni = n - pbvh->nodes;
bm_edges_from_tri(pbvh->bm, v_tri, e_tri);
bm_edges_from_tri(pbvh->header.bm, v_tri, e_tri);
pbvh_bmesh_face_create(pbvh, ni, v_tri, e_tri, f);
/* Ensure that v_conn is in the new face's node */
@@ -1388,13 +1388,13 @@ static void pbvh_bmesh_collapse_edge(PBVH *pbvh,
/* Remove the face */
pbvh_bmesh_face_remove(pbvh, f_del);
BM_face_kill(pbvh->bm, f_del);
BM_face_kill(pbvh->header.bm, f_del);
/* Check if any of the face's edges are now unused by any
* face, if so delete them */
for (int j = 0; j < 3; j++) {
if (BM_edge_is_wire(e_tri[j])) {
BM_edge_kill(pbvh->bm, e_tri[j]);
BM_edge_kill(pbvh->header.bm, e_tri[j]);
}
}
@@ -1410,7 +1410,7 @@ static void pbvh_bmesh_collapse_edge(PBVH *pbvh,
v_conn = NULL;
}
BLI_ghash_insert(deleted_verts, v_tri[j], NULL);
BM_vert_kill(pbvh->bm, v_tri[j]);
BM_vert_kill(pbvh->header.bm, v_tri[j]);
}
}
}
@@ -1437,7 +1437,7 @@ static void pbvh_bmesh_collapse_edge(PBVH *pbvh,
BM_log_vert_removed(pbvh->bm_log, v_del, eq_ctx->cd_vert_mask_offset);
/* v_conn == NULL is OK */
BLI_ghash_insert(deleted_verts, v_del, v_conn);
BM_vert_kill(pbvh->bm, v_del);
BM_vert_kill(pbvh->header.bm, v_del);
}
static bool pbvh_bmesh_collapse_short_edges(EdgeQueueContext *eq_ctx,
@@ -1501,7 +1501,7 @@ bool pbvh_bmesh_node_raycast(PBVHNode *node,
struct IsectRayPrecalc *isect_precalc,
float *depth,
bool use_original,
int *r_active_vertex_index,
PBVHVertRef *r_active_vertex,
float *r_face_normal)
{
bool hit = false;
@@ -1538,14 +1538,14 @@ bool pbvh_bmesh_node_raycast(PBVHNode *node,
normal_tri_v3(r_face_normal, v_tri[0]->co, v_tri[1]->co, v_tri[2]->co);
}
if (r_active_vertex_index) {
if (r_active_vertex) {
float location[3] = {0.0f};
madd_v3_v3v3fl(location, ray_start, ray_normal, *depth);
for (int j = 0; j < 3; j++) {
if (len_squared_v3v3(location, v_tri[j]->co) <
len_squared_v3v3(location, nearest_vertex_co)) {
copy_v3_v3(nearest_vertex_co, v_tri[j]->co);
*r_active_vertex_index = BM_elem_index_get(v_tri[j]);
r_active_vertex->i = (intptr_t)v_tri[j];
}
}
}
@@ -1872,11 +1872,11 @@ void BKE_pbvh_build_bmesh(PBVH *pbvh,
{
pbvh->cd_vert_node_offset = cd_vert_node_offset;
pbvh->cd_face_node_offset = cd_face_node_offset;
pbvh->bm = bm;
pbvh->header.bm = bm;
BKE_pbvh_bmesh_detail_size_set(pbvh, 0.75);
pbvh->type = PBVH_BMESH;
pbvh->header.type = PBVH_BMESH;
pbvh->bm_log = log;
/* TODO: choose leaf limit better */
@@ -1951,7 +1951,7 @@ bool BKE_pbvh_bmesh_update_topology(PBVH *pbvh,
/* 2 is enough for edge faces - manifold edge */
BLI_buffer_declare_static(BMLoop *, edge_loops, BLI_BUFFER_NOP, 2);
BLI_buffer_declare_static(BMFace *, deleted_faces, BLI_BUFFER_NOP, 32);
const int cd_vert_mask_offset = CustomData_get_offset(&pbvh->bm->vdata, CD_PAINT_MASK);
const int cd_vert_mask_offset = CustomData_get_offset(&pbvh->header.bm->vdata, CD_PAINT_MASK);
const int cd_vert_node_offset = pbvh->cd_vert_node_offset;
const int cd_face_node_offset = pbvh->cd_face_node_offset;
@@ -1967,7 +1967,7 @@ bool BKE_pbvh_bmesh_update_topology(PBVH *pbvh,
EdgeQueueContext eq_ctx = {
&q,
queue_pool,
pbvh->bm,
pbvh->header.bm,
cd_vert_mask_offset,
cd_vert_node_offset,
cd_face_node_offset,
@@ -1986,7 +1986,7 @@ bool BKE_pbvh_bmesh_update_topology(PBVH *pbvh,
EdgeQueueContext eq_ctx = {
&q,
queue_pool,
pbvh->bm,
pbvh->header.bm,
cd_vert_mask_offset,
cd_vert_node_offset,
cd_face_node_offset,
@@ -2126,13 +2126,13 @@ static void pbvh_bmesh_print(PBVH *pbvh)
BMIter iter;
BMFace *f;
BM_ITER_MESH (f, &iter, pbvh->bm, BM_FACES_OF_MESH) {
BM_ITER_MESH (f, &iter, pbvh->header.bm, BM_FACES_OF_MESH) {
fprintf(stderr, " %d -> %d\n", BM_elem_index_get(f), pbvh_bmesh_node_index_from_face(pbvh, f));
}
fprintf(stderr, "bm_vert_to_node:\n");
BMVert *v;
BM_ITER_MESH (v, &iter, pbvh->bm, BM_FACES_OF_MESH) {
BM_ITER_MESH (v, &iter, pbvh->header.bm, BM_FACES_OF_MESH) {
fprintf(stderr, " %d -> %d\n", BM_elem_index_get(v), pbvh_bmesh_node_index_from_vert(pbvh, v));
}
@@ -2171,21 +2171,21 @@ static void print_flag_factors(int flag)
static void pbvh_bmesh_verify(PBVH *pbvh)
{
/* build list of faces & verts to lookup */
GSet *faces_all = BLI_gset_ptr_new_ex(__func__, pbvh->bm->totface);
GSet *faces_all = BLI_gset_ptr_new_ex(__func__, pbvh->header.bm->totface);
BMIter iter;
{
BMFace *f;
BM_ITER_MESH (f, &iter, pbvh->bm, BM_FACES_OF_MESH) {
BM_ITER_MESH (f, &iter, pbvh->header.bm, BM_FACES_OF_MESH) {
BLI_assert(BM_ELEM_CD_GET_INT(f, pbvh->cd_face_node_offset) != DYNTOPO_NODE_NONE);
BLI_gset_insert(faces_all, f);
}
}
GSet *verts_all = BLI_gset_ptr_new_ex(__func__, pbvh->bm->totvert);
GSet *verts_all = BLI_gset_ptr_new_ex(__func__, pbvh->header.bm->totvert);
{
BMVert *v;
BM_ITER_MESH (v, &iter, pbvh->bm, BM_VERTS_OF_MESH) {
BM_ITER_MESH (v, &iter, pbvh->header.bm, BM_VERTS_OF_MESH) {
if (BM_ELEM_CD_GET_INT(v, pbvh->cd_vert_node_offset) != DYNTOPO_NODE_NONE) {
BLI_gset_insert(verts_all, v);
}
@@ -2207,7 +2207,7 @@ static void pbvh_bmesh_verify(PBVH *pbvh)
{
BMFace *f;
BM_ITER_MESH (f, &iter, pbvh->bm, BM_FACES_OF_MESH) {
BM_ITER_MESH (f, &iter, pbvh->header.bm, BM_FACES_OF_MESH) {
BMIter bm_iter;
BMVert *v;
PBVHNode *n = pbvh_bmesh_node_lookup(pbvh, f);
@@ -2240,7 +2240,7 @@ static void pbvh_bmesh_verify(PBVH *pbvh)
/* Check verts */
{
BMVert *v;
BM_ITER_MESH (v, &iter, pbvh->bm, BM_VERTS_OF_MESH) {
BM_ITER_MESH (v, &iter, pbvh->header.bm, BM_VERTS_OF_MESH) {
/* vertex isn't tracked */
if (BM_ELEM_CD_GET_INT(v, pbvh->cd_vert_node_offset) == DYNTOPO_NODE_NONE) {
continue;
@@ -2286,7 +2286,7 @@ static void pbvh_bmesh_verify(PBVH *pbvh)
# if 0
/* check that every vert belongs somewhere */
/* Slow */
BM_ITER_MESH (vi, &iter, pbvh->bm, BM_VERTS_OF_MESH) {
BM_ITER_MESH (vi, &iter, pbvh->header.bm, BM_VERTS_OF_MESH) {
bool has_unique = false;
for (int i = 0; i < pbvh->totnode; i++) {
PBVHNode *n = &pbvh->nodes[i];
@@ -2299,7 +2299,7 @@ static void pbvh_bmesh_verify(PBVH *pbvh)
}
/* If totvert differs from number of verts inside the hash. hash-totvert is checked above. */
BLI_assert(vert_count == pbvh->bm->totvert);
BLI_assert(vert_count == pbvh->header.bm->totvert);
# endif
/* Check that node elements are recorded in the top level */

Some files were not shown because too many files have changed in this diff Show More