Geometry Node: Edge Rings node #104623

Open
Iliya Katushenock wants to merge 17 commits from mod_moder/blender:edge_rings into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
84 changed files with 396139 additions and 549802 deletions
Showing only changes of commit 01a3a34623 - Show all commits

View File

@ -65,17 +65,6 @@ enum_filter_types = (
('BLACKMAN_HARRIS', "Blackman-Harris", "Blackman-Harris filter"),
)
enum_panorama_types = (
('EQUIRECTANGULAR', "Equirectangular", "Spherical camera for environment maps, also known as Lat Long panorama", 0),
('EQUIANGULAR_CUBEMAP_FACE', "Equiangular Cubemap Face", "Single face of an equiangular cubemap", 5),
('MIRRORBALL', "Mirror Ball", "Mirror ball mapping for environment maps", 3),
('FISHEYE_EQUIDISTANT', "Fisheye Equidistant", "Ideal for fulldomes, ignore the sensor dimensions", 1),
('FISHEYE_EQUISOLID', "Fisheye Equisolid",
"Similar to most fisheye modern lens, takes sensor dimensions into consideration", 2),
('FISHEYE_LENS_POLYNOMIAL', "Fisheye Lens Polynomial",
"Defines the lens projection as polynomial to allow real world camera lenses to be mimicked", 4),
)
enum_curve_shape = (
('RIBBONS', "Rounded Ribbons", "Render curves as flat ribbons with rounded normals, for fast rendering"),
('THICK', "3D Curves", "Render curves as circular 3D geometry, for accurate results when viewing closely"),
@ -1014,95 +1003,6 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
del bpy.types.Scene.cycles
class CyclesCameraSettings(bpy.types.PropertyGroup):
panorama_type: EnumProperty(
name="Panorama Type",
description="Distortion to use for the calculation",
items=enum_panorama_types,
default='FISHEYE_EQUISOLID',
)
fisheye_fov: FloatProperty(
name="Field of View",
description="Field of view for the fisheye lens",
min=0.1745, soft_max=2.0 * pi, max=10.0 * pi,
subtype='ANGLE',
default=pi,
)
fisheye_lens: FloatProperty(
name="Fisheye Lens",
description="Lens focal length (mm)",
min=0.01, soft_max=15.0, max=100.0,
default=10.5,
)
latitude_min: FloatProperty(
name="Min Latitude",
description="Minimum latitude (vertical angle) for the equirectangular lens",
min=-0.5 * pi, max=0.5 * pi,
subtype='ANGLE',
default=-0.5 * pi,
)
latitude_max: FloatProperty(
name="Max Latitude",
description="Maximum latitude (vertical angle) for the equirectangular lens",
min=-0.5 * pi, max=0.5 * pi,
subtype='ANGLE',
default=0.5 * pi,
)
longitude_min: FloatProperty(
name="Min Longitude",
description="Minimum longitude (horizontal angle) for the equirectangular lens",
min=-pi, max=pi,
subtype='ANGLE',
default=-pi,
)
longitude_max: FloatProperty(
name="Max Longitude",
description="Maximum longitude (horizontal angle) for the equirectangular lens",
min=-pi, max=pi,
subtype='ANGLE',
default=pi,
)
fisheye_polynomial_k0: FloatProperty(
name="Fisheye Polynomial K0",
description="Coefficient K0 of the lens polynomial",
default=camera.default_fisheye_polynomial[0], precision=6, step=0.1, subtype='ANGLE',
)
fisheye_polynomial_k1: FloatProperty(
name="Fisheye Polynomial K1",
description="Coefficient K1 of the lens polynomial",
default=camera.default_fisheye_polynomial[1], precision=6, step=0.1, subtype='ANGLE',
)
fisheye_polynomial_k2: FloatProperty(
name="Fisheye Polynomial K2",
description="Coefficient K2 of the lens polynomial",
default=camera.default_fisheye_polynomial[2], precision=6, step=0.1, subtype='ANGLE',
)
fisheye_polynomial_k3: FloatProperty(
name="Fisheye Polynomial K3",
description="Coefficient K3 of the lens polynomial",
default=camera.default_fisheye_polynomial[3], precision=6, step=0.1, subtype='ANGLE',
)
fisheye_polynomial_k4: FloatProperty(
name="Fisheye Polynomial K4",
description="Coefficient K4 of the lens polynomial",
default=camera.default_fisheye_polynomial[4], precision=6, step=0.1, subtype='ANGLE',
)
@classmethod
def register(cls):
bpy.types.Camera.cycles = PointerProperty(
name="Cycles Camera Settings",
description="Cycles camera settings",
type=cls,
)
@classmethod
def unregister(cls):
del bpy.types.Camera.cycles
class CyclesMaterialSettings(bpy.types.PropertyGroup):
emission_sampling: EnumProperty(
@ -1837,7 +1737,6 @@ class CyclesView3DShadingSettings(bpy.types.PropertyGroup):
def register():
bpy.utils.register_class(CyclesRenderSettings)
bpy.utils.register_class(CyclesCameraSettings)
bpy.utils.register_class(CyclesMaterialSettings)
bpy.utils.register_class(CyclesLightSettings)
bpy.utils.register_class(CyclesWorldSettings)
@ -1858,7 +1757,6 @@ def register():
def unregister():
bpy.utils.unregister_class(CyclesRenderSettings)
bpy.utils.unregister_class(CyclesCameraSettings)
bpy.utils.unregister_class(CyclesMaterialSettings)
bpy.utils.unregister_class(CyclesLightSettings)
bpy.utils.unregister_class(CyclesWorldSettings)

View File

@ -164,6 +164,26 @@ static float blender_camera_focal_distance(BL::RenderEngine &b_engine,
return fabsf(dot(view_dir, dof_dir));
}
static PanoramaType blender_panorama_type_to_cycles(const BL::Camera::panorama_type_enum type)
{
switch (type) {
case BL::Camera::panorama_type_EQUIRECTANGULAR:
return PANORAMA_EQUIRECTANGULAR;
case BL::Camera::panorama_type_EQUIANGULAR_CUBEMAP_FACE:
return PANORAMA_EQUIANGULAR_CUBEMAP_FACE;
case BL::Camera::panorama_type_MIRRORBALL:
return PANORAMA_MIRRORBALL;
case BL::Camera::panorama_type_FISHEYE_EQUIDISTANT:
return PANORAMA_FISHEYE_EQUIDISTANT;
case BL::Camera::panorama_type_FISHEYE_EQUISOLID:
return PANORAMA_FISHEYE_EQUISOLID;
case BL::Camera::panorama_type_FISHEYE_LENS_POLYNOMIAL:
return PANORAMA_FISHEYE_LENS_POLYNOMIAL;
}
/* Could happen if loading a newer file that has an unsupported type. */
return PANORAMA_FISHEYE_EQUISOLID;
}
static void blender_camera_from_object(BlenderCamera *bcam,
BL::RenderEngine &b_engine,
BL::Object &b_ob,
@ -173,7 +193,6 @@ static void blender_camera_from_object(BlenderCamera *bcam,
if (b_ob_data.is_a(&RNA_Camera)) {
BL::Camera b_camera(b_ob_data);
PointerRNA ccamera = RNA_pointer_get(&b_camera.ptr, "cycles");
bcam->nearclip = b_camera.clip_start();
bcam->farclip = b_camera.clip_end();
@ -194,21 +213,19 @@ static void blender_camera_from_object(BlenderCamera *bcam,
break;
}
bcam->panorama_type = (PanoramaType)get_enum(
ccamera, "panorama_type", PANORAMA_NUM_TYPES, PANORAMA_EQUIRECTANGULAR);
bcam->panorama_type = blender_panorama_type_to_cycles(b_camera.panorama_type());
bcam->fisheye_fov = b_camera.fisheye_fov();
bcam->fisheye_lens = b_camera.fisheye_lens();
bcam->latitude_min = b_camera.latitude_min();
bcam->latitude_max = b_camera.latitude_max();
bcam->longitude_min = b_camera.longitude_min();
bcam->longitude_max = b_camera.longitude_max();
bcam->fisheye_fov = RNA_float_get(&ccamera, "fisheye_fov");
bcam->fisheye_lens = RNA_float_get(&ccamera, "fisheye_lens");
bcam->latitude_min = RNA_float_get(&ccamera, "latitude_min");
bcam->latitude_max = RNA_float_get(&ccamera, "latitude_max");
bcam->longitude_min = RNA_float_get(&ccamera, "longitude_min");
bcam->longitude_max = RNA_float_get(&ccamera, "longitude_max");
bcam->fisheye_polynomial_k0 = RNA_float_get(&ccamera, "fisheye_polynomial_k0");
bcam->fisheye_polynomial_k1 = RNA_float_get(&ccamera, "fisheye_polynomial_k1");
bcam->fisheye_polynomial_k2 = RNA_float_get(&ccamera, "fisheye_polynomial_k2");
bcam->fisheye_polynomial_k3 = RNA_float_get(&ccamera, "fisheye_polynomial_k3");
bcam->fisheye_polynomial_k4 = RNA_float_get(&ccamera, "fisheye_polynomial_k4");
bcam->fisheye_polynomial_k0 = b_camera.fisheye_polynomial_k0();
bcam->fisheye_polynomial_k1 = b_camera.fisheye_polynomial_k1();
bcam->fisheye_polynomial_k2 = b_camera.fisheye_polynomial_k2();
bcam->fisheye_polynomial_k3 = b_camera.fisheye_polynomial_k3();
bcam->fisheye_polynomial_k4 = b_camera.fisheye_polynomial_k4();
bcam->interocular_distance = b_camera.stereo().interocular_distance();
if (b_camera.stereo().convergence_mode() == BL::CameraStereoData::convergence_mode_PARALLEL) {

View File

@ -64,7 +64,10 @@ GHOST_TSuccess GHOST_ISystem::createSystem(bool verbose, [[maybe_unused]] bool b
try {
m_system = new GHOST_SystemWayland(background);
}
catch (const std::runtime_error &) {
catch (const std::runtime_error &e) {
if (verbose) {
fprintf(stderr, "GHOST: %s\n", e.what());
}
delete m_system;
m_system = nullptr;
# ifdef WITH_GHOST_WAYLAND_DYNLOAD
@ -102,7 +105,10 @@ GHOST_TSuccess GHOST_ISystem::createSystem(bool verbose, [[maybe_unused]] bool b
try {
m_system = new GHOST_SystemWayland(background);
}
catch (const std::runtime_error &) {
catch (const std::runtime_error &const e) {
if (verbose) {
fprintf(stderr, "GHOST: %s\n", e.what());
}
delete m_system;
m_system = nullptr;
# ifdef WITH_GHOST_WAYLAND_DYNLOAD

View File

@ -1,12 +1,16 @@
# OpenColorIO configuration file for Blender
#
# Based on aces, nuke-default and spi configurations from OpenColorIO-Config
# ACEScg and ACES2065-1 spaces using OpenColorIO's BuiltinTransform
#
# Filmic Dynamic Range LUT configuration crafted by Troy James Sobotka with
# special thanks and feedback from Guillermo, Claudio Rocha, Bassam Kurdali,
# Eugenio Pignataro, Henri Hebeisen, Jason Clarke, Haarm-Peter Duiker, Thomas
# Mansencal, and Timothy Lottes.
#
# Based on original AgX by Troy Sobotka: https://github.com/sobotka/AgX https://github.com/sobotka/SB2383-Configuration-Generation
# Further Developed by Zijun Eary Zhou法纤净, Mark Faderbauer, and Sakari Kapanen
# Repository for this version: https://github.com/EaryChow/AgX
#
# See ocio-license.txt for details.
ocio_profile_version: 2
@ -44,8 +48,8 @@ roles:
cie_xyz_d65_interchange: Linear CIE-XYZ D65
# Specified by OCIO, not used in Blender
color_timing: Filmic Log
compositing_log: Filmic Log
color_timing: AgX Log
compositing_log: AgX Log
default: Linear Rec.709
matte_paint: Linear Rec.709
texture_paint: Linear Rec.709
@ -53,14 +57,29 @@ roles:
displays:
sRGB:
- !<View> {name: Standard, colorspace: sRGB}
- !<View> {name: AgX, colorspace: AgX Base sRGB}
- !<View> {name: Filmic, colorspace: Filmic sRGB}
- !<View> {name: Filmic Log, colorspace: Filmic Log}
- !<View> {name: False Color, colorspace: False Color}
- !<View> {name: False Color, colorspace: AgX False Color Rec.709}
- !<View> {name: Raw, colorspace: Non-Color}
active_displays: [sRGB]
active_views: [Standard, Filmic, Filmic Log, False Color, Raw]
inactive_colorspaces: [False Color]
Display P3:
- !<View> {name: Standard, colorspace: Display P3}
- !<View> {name: AgX, colorspace: AgX Base Display P3}
- !<View> {name: False Color, colorspace: AgX False Color P3}
- !<View> {name: Raw, colorspace: Non-Color}
Rec.1886:
- !<View> {name: Standard, colorspace: Rec.1886}
- !<View> {name: AgX, colorspace: AgX Base Rec.1886}
- !<View> {name: False Color, colorspace: AgX False Color Rec.709}
- !<View> {name: Raw, colorspace: Non-Color}
Rec.2020:
- !<View> {name: Standard, colorspace: Rec.2020}
- !<View> {name: AgX, colorspace: AgX Base Rec.2020}
- !<View> {name: False Color, colorspace: AgX False Color Rec.2020}
- !<View> {name: Raw, colorspace: Non-Color}
active_displays: [sRGB, Display P3, Rec.1886, Rec.2020]
active_views: [Standard, AgX, Filmic, Filmic Log, False Color, Raw]
inactive_colorspaces: [Luminance Compensation Rec.2020, Luminance Compensation sRGB, Luminance Compensation P3, AgX False Color Rec.709, AgX False Color P3, AgX False Color Rec.1886, AgX False Color Rec.2020]
colorspaces:
- !<ColorSpace>
@ -246,7 +265,7 @@ colorspaces:
children:
- !<ColorSpaceTransform> {src: Linear CIE-XYZ E, dst: Linear Rec.709}
- !<AllocationTransform> {allocation: lg2, vars: [-12.473931188, 12.526068812]}
- !<FileTransform> {src: filmic_desat65cube.spi3d, interpolation: best}
- !<FileTransform> {src: filmic_desat_33.cube, interpolation: tetrahedral}
- !<AllocationTransform> {allocation: uniform, vars: [0, 0.66]}
to_scene_reference: !<GroupTransform>
children:
@ -267,18 +286,205 @@ colorspaces:
- !<FileTransform> {src: filmic_to_0-70_1-03.spi1d, interpolation: linear}
- !<ColorSpace>
name: False Color
family: Filmic
name: Luminance Compensation Rec.2020
aliases: [Luminance Compensation BT.2020]
family: Utilities
equalitygroup:
bitdepth: 32f
description: |
Filmic false color view transform
Offset the negative values in BT.2020 and compensate for luminance, ensuring there is no negative values in Rec.2020
isdata: false
from_scene_reference: !<GroupTransform>
children:
- !<ColorSpaceTransform> {src: Linear CIE-XYZ E, dst: Linear FilmLight E-Gamut}
- !<AllocationTransform> {allocation: lg2, vars: [-12.47393, 12.5260688117]}
- !<FileTransform> {src: luminance_compensation_bt2020.cube, interpolation: tetrahedral}
- !<AllocationTransform> {allocation: lg2, vars: [-12.47393, 12.5260688117], direction: inverse}
- !<ColorSpaceTransform> {src: Linear FilmLight E-Gamut, dst: Linear Rec.2020}
- !<ColorSpace>
name: Luminance Compensation sRGB
family: Utilities
equalitygroup:
bitdepth: 32f
description: |
Offset the negative values in BT.709 and compensate for luminance, ensuring there is no negative values in Rec.709
isdata: false
from_scene_reference: !<GroupTransform>
children:
- !<ColorSpaceTransform> {src: Linear CIE-XYZ E, dst: Linear FilmLight E-Gamut}
- !<MatrixTransform> {matrix: [0.960599732262383, 0.0196075412762159, 0.019792726461401, 0, 0.0105997322623829, 0.969607541276216, 0.0197927264614012, 0, 0.0105997322623829, 0.0196075412762162, 0.969792726461401, 0, 0, 0, 0, 1]}
- !<FileTransform> {src: Guard_Rail_Shaper_EOTF.spi1d, interpolation: linear, direction: inverse}
- !<FileTransform> {src: luminance_compensation_srgb.cube, interpolation: tetrahedral}
- !<FileTransform> {src: Guard_Rail_Shaper_EOTF.spi1d, interpolation: linear}
- !<MatrixTransform> {matrix: [0.960599732262383, 0.0196075412762159, 0.019792726461401, 0, 0.0105997322623829, 0.969607541276216, 0.0197927264614012, 0, 0.0105997322623829, 0.0196075412762162, 0.969792726461401, 0, 0, 0, 0, 1], direction: inverse}
- !<ColorSpaceTransform> {src: Linear FilmLight E-Gamut, dst: Linear Rec.709}
- !<RangeTransform> {min_in_value: 0, min_out_value: 0}
- !<ColorSpace>
name: Luminance Compensation P3
family: Utilities
equalitygroup:
bitdepth: 32f
description: |
Offset the negative values in P3 and compensate for luminance, ensuring there is no negative values in P3
isdata: false
from_scene_reference: !<GroupTransform>
children:
- !<ColorSpaceTransform> {src: Linear CIE-XYZ E, dst: Linear FilmLight E-Gamut}
- !<MatrixTransform> {matrix: [0.960599732262383, 0.0196075412762159, 0.019792726461401, 0, 0.0105997322623829, 0.969607541276216, 0.0197927264614012, 0, 0.0105997322623829, 0.0196075412762162, 0.969792726461401, 0, 0, 0, 0, 1]}
- !<FileTransform> {src: Guard_Rail_Shaper_EOTF.spi1d, interpolation: linear, direction: inverse}
- !<FileTransform> {src: luminance_compensation_p3.cube, interpolation: tetrahedral}
- !<FileTransform> {src: Guard_Rail_Shaper_EOTF.spi1d, interpolation: linear}
- !<MatrixTransform> {matrix: [0.960599732262383, 0.0196075412762159, 0.019792726461401, 0, 0.0105997322623829, 0.969607541276216, 0.0197927264614012, 0, 0.0105997322623829, 0.0196075412762162, 0.969792726461401, 0, 0, 0, 0, 1], direction: inverse}
- !<ColorSpaceTransform> {src: Linear FilmLight E-Gamut, dst: Linear DCI-P3 D65}
- !<RangeTransform> {min_in_value: 0, min_out_value: 0}
- !<ColorSpace>
name: AgX Log
family: Log Encodings
equalitygroup:
bitdepth: 32f
description: |
Log Encoding with Chroma inset and rotation, and with 25 Stops of Dynamic Range
isdata: false
from_reference: !<GroupTransform>
children:
- !<ColorSpaceTransform> {src: Linear CIE-XYZ E, dst: Filmic Log}
- !<MatrixTransform> {matrix: [0.2126729, 0.7151521, 0.0721750, 0, 0.2126729, 0.7151521, 0.0721750, 0, 0.2126729, 0.7151521, 0.0721750, 0, 0, 0, 0, 1]}
- !<FileTransform> {src: filmic_false_color.spi3d, interpolation: best}
from_scene_reference: !<GroupTransform>
children:
- !<ColorSpaceTransform> {src: Linear CIE-XYZ E, dst: Luminance Compensation Rec.2020}
# rotate = [3.0, -1, -2.0], inset = [0.4, 0.22, 0.13]
- !<MatrixTransform> {matrix: [0.856627153315983, 0.0951212405381588, 0.0482516061458583, 0, 0.137318972929847, 0.761241990602591, 0.101439036467562, 0, 0.11189821299995, 0.0767994186031903, 0.811302368396859, 0, 0, 0, 0, 1]}
- !<AllocationTransform> {allocation: lg2, vars: [-12.47393, 12.5260688117]}
to_scene_reference: !<GroupTransform>
children:
- !<AllocationTransform> {allocation: lg2, vars: [-12.47393, 12.5260688117], direction: inverse}
- !<MatrixTransform> {matrix: [0.856627153315983, 0.0951212405381588, 0.0482516061458583, 0, 0.137318972929847, 0.761241990602591, 0.101439036467562, 0, 0.11189821299995, 0.0767994186031903, 0.811302368396859, 0, 0, 0, 0, 1], direction: inverse}
- !<ColorSpaceTransform> {src: Linear CIE-XYZ E, dst: Linear Rec.2020, direction: inverse}
- !<ColorSpace>
name: AgX Base Rec.2020
aliases: [AgX Base BT.2020]
family: AgX
equalitygroup:
bitdepth: 32f
description: |
AgX Base Image Encoding for BT.2020 Display
isdata: false
from_scene_reference: !<GroupTransform>
children:
- !<ColorSpaceTransform> {src: Linear CIE-XYZ E, dst: Linear FilmLight E-Gamut}
- !<AllocationTransform> {allocation: lg2, vars: [-12.47393, 12.5260688117]}
- !<FileTransform> {src: AgX_Base_Rec2020.cube, interpolation: tetrahedral}
to_scene_reference: !<GroupTransform>
children:
- !<FileTransform> {src: Inverse_AgX_Base_Rec2020.cube, interpolation: tetrahedral}
- !<AllocationTransform> {allocation: lg2, vars: [-12.47393, 4.026069], direction: inverse}
- !<ColorSpaceTransform> {src: Linear CIE-XYZ E, dst: Linear Rec.2020, direction: inverse}
- !<ColorSpace>
name: AgX Base sRGB
family: AgX
equalitygroup:
bitdepth: 32f
description: |
AgX Base Image Encoding for sRGB Display
isdata: false
from_scene_reference: !<GroupTransform>
children:
- !<ColorSpaceTransform> {src: Linear CIE-XYZ E, dst: Linear FilmLight E-Gamut}
- !<AllocationTransform> {allocation: lg2, vars: [-12.47393, 12.5260688117]}
- !<FileTransform> {src: AgX_Base_sRGB.cube, interpolation: tetrahedral}
- !<ExponentTransform> {value: 2.4}
- !<ColorSpaceTransform> {src: Linear Rec.709, dst: sRGB}
to_scene_reference: !<GroupTransform>
children:
- !<ColorSpaceTransform> {src: sRGB, dst: Rec.2020}
- !<ColorSpaceTransform> {src: AgX Base Rec.2020, dst: Linear CIE-XYZ E}
- !<ColorSpace>
name: AgX Base Display P3
family: AgX
equalitygroup:
bitdepth: 32f
description: |
AgX Base Image Encoding for Display P3 Display
isdata: false
from_scene_reference: !<GroupTransform>
children:
- !<ColorSpaceTransform> {src: Linear CIE-XYZ E, dst: Linear FilmLight E-Gamut}
- !<AllocationTransform> {allocation: lg2, vars: [-12.47393, 12.5260688117]}
- !<FileTransform> {src: AgX_Base_P3.cube, interpolation: tetrahedral}
- !<ExponentTransform> {value: 2.4}
- !<ColorSpaceTransform> {src: Linear DCI-P3 D65, dst: Display P3}
to_scene_reference: !<GroupTransform>
children:
- !<ColorSpaceTransform> {src: Display P3, dst: Rec.2020}
- !<ColorSpaceTransform> {src: AgX Base Rec.2020, dst: Linear CIE-XYZ E}
- !<ColorSpace>
name: AgX Base Rec.1886
aliases: [AgX Base BT.1886]
family: AgX
equalitygroup:
bitdepth: 32f
description: |
AgX Base Image Encoding for Rec.1886 Display
isdata: false
from_scene_reference: !<GroupTransform>
children:
- !<ColorSpaceTransform> {src: Linear CIE-XYZ E, dst: Linear FilmLight E-Gamut}
- !<AllocationTransform> {allocation: lg2, vars: [-12.47393, 12.5260688117]}
- !<FileTransform> {src: AgX_Base_sRGB.cube, interpolation: tetrahedral}
to_scene_reference: !<GroupTransform>
children:
- !<ColorSpaceTransform> {src: Rec.1886, dst: Rec.2020}
- !<ColorSpaceTransform> {src: AgX Base Rec.2020, dst: Linear CIE-XYZ E}
- !<ColorSpace>
name: AgX False Color Rec.709
aliases: [AgX False Color BT.709, False Colour, False Color]
family: AgX
equalitygroup:
bitdepth: 32f
description: |
A heat-map-like image formed from AgX Base for sRGB and Rec.1886 displays
isdata: false
from_scene_reference: !<GroupTransform>
children:
- !<ColorSpaceTransform> {src: Linear CIE-XYZ E, dst: AgX Base Rec.2020}
- !<ColorSpaceTransform> {src: Rec.2020, dst: Linear Rec.2020}
- !<MatrixTransform> {matrix: [0.2658180370250449, 0.59846986045365, 0.1357121025213052, 0, 0.2658180370250449, 0.59846986045365, 0.1357121025213052, 0, 0.2658180370250449, 0.59846986045365, 0.1357121025213052, 0, 0, 0, 0, 1]}
- !<ExponentTransform> {value: 2.5, direction: inverse}
- !<FileTransform> {src: AgX_False_Color.spi1d, interpolation: tetrahedral}
- !<ColorSpace>
name: AgX False Color P3
family: AgX
equalitygroup:
bitdepth: 32f
description: |
A heat-map-like image formed from AgX Base for Display P3 displays
isdata: false
from_scene_reference: !<GroupTransform>
children:
- !<ColorSpaceTransform> {src: Linear CIE-XYZ E, dst: AgX False Color Rec.709}
- !<ColorSpaceTransform> {src: sRGB, dst: Display P3}
- !<ColorSpace>
name: AgX False Color Rec.2020
aliases: [AgX False Color BT.2020]
family: AgX
equalitygroup:
bitdepth: 32f
description: |
A heat-map-like image formed from AgX Base for Rec.2020 displays
isdata: false
from_scene_reference: !<GroupTransform>
children:
- !<ColorSpaceTransform> {src: Linear CIE-XYZ E, dst: AgX False Color Rec.709}
- !<ColorSpaceTransform> {src: Rec.1886, dst: Rec.2020}
looks:
- !<Look>
name: Very High Contrast
@ -301,7 +507,7 @@ looks:
process_space: Filmic Log
transform: !<GroupTransform>
children:
- !<FileTransform> {src: filmic_to_0-85_1-011.spi1d, interpolation: best}
- !<FileTransform> {src: filmic_to_0-85_1-011.spi1d, interpolation: linear}
- !<FileTransform> {src: filmic_to_0-70_1-03.spi1d, interpolation: linear, direction: inverse}
- !<Look>
@ -333,3 +539,106 @@ looks:
children:
- !<FileTransform> {src: filmic_to_0-35_1-30.spi1d, interpolation: linear}
- !<FileTransform> {src: filmic_to_0-70_1-03.spi1d, interpolation: linear, direction: inverse}
- !<Look>
name: AgX - Punchy
process_space: AgX Log
description: A darkening punchy look
transform: !<GroupTransform>
children:
- !<GradingToneTransform>
shadows: {rgb: [0.2, 0.2, 0.2], master: 0.35, start: 0.4, pivot: 0.1}
- !<CDLTransform> {power: [1.0912, 1.0912, 1.0912]}
- !<Look>
name: AgX - Greyscale
process_space: AgX Log
description: A Black and White Look
transform: !<GroupTransform>
children:
- !<AllocationTransform> {allocation: lg2, vars: [-12.47393, 12.5260688117], direction: inverse}
- !<MatrixTransform> {matrix: [0.2658180370250449, 0.59846986045365, 0.1357121025213052, 0, 0.2658180370250449, 0.59846986045365, 0.1357121025213052, 0, 0.2658180370250449, 0.59846986045365, 0.1357121025213052, 0, 0, 0, 0, 1]}
- !<AllocationTransform> {allocation: lg2, vars: [-12.47393, 12.5260688117]}
- !<Look>
name: AgX - Very High Contrast
process_space: AgX Log
description: A Very High Contrast Look
transform: !<GroupTransform>
children:
- !<GradingPrimaryTransform>
style: log
contrast: {rgb: [1.57, 1.57, 1.57], master: 1}
saturation: 0.9
pivot: {contrast: -0.2}
- !<Look>
name: AgX - High Contrast
process_space: AgX Log
description: A High Contrast Look
transform: !<GroupTransform>
children:
- !<GradingPrimaryTransform>
style: log
contrast: {rgb: [1.4, 1.4, 1.4], master: 1}
saturation: 0.95
pivot: {contrast: -0.2}
- !<Look>
name: AgX - Medium High Contrast
process_space: AgX Log
description: A Medium High Contrast Look
transform: !<GroupTransform>
children:
- !<GradingPrimaryTransform>
style: log
contrast: {rgb: [1.2, 1.2, 1.2], master: 1}
saturation: 1
pivot: {contrast: -0.2}
- !<Look>
name: AgX - Base Contrast
process_space: AgX Log
description: A Base Contrast Look
transform: !<GroupTransform>
children:
- !<GradingPrimaryTransform>
style: log
contrast: {rgb: [1, 1, 1], master: 1}
pivot: {contrast: -0.2}
- !<Look>
name: AgX - Medium Low Contrast
process_space: AgX Log
description: A Medium Low Contrast Look
transform: !<GroupTransform>
children:
- !<GradingPrimaryTransform>
style: log
contrast: {rgb: [0.9, 0.9, 0.9], master: 1}
saturation: 1.05
pivot: {contrast: -0.2}
- !<Look>
name: AgX - Low Contrast
process_space: AgX Log
description: A Low Contrast Look
transform: !<GroupTransform>
children:
- !<GradingPrimaryTransform>
style: log
contrast: {rgb: [0.8, 0.8, 0.8], master: 1}
saturation: 1.1
pivot: {contrast: -0.2}
- !<Look>
name: AgX - Very Low Contrast
process_space: AgX Log
description: A Very Low Contrast Look
transform: !<GroupTransform>
children:
- !<GradingPrimaryTransform>
style: log
contrast: {rgb: [0.7, 0.7, 0.7], master: 1}
saturation: 1.15
pivot: {contrast: -0.2}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,3 @@
0.95318743 -0.02659057 0.02387315 0
-0.03824666 1.02884062 0.00940604 0
0.00260677 -0.00303325 1.08925647 0
0.95318743 -0.02659057 0.02387315 0
-0.03824666 1.02884062 0.00940604 0
0.00260677 -0.00303325 1.08925647 0

View File

@ -186,9 +186,9 @@ def draw(layout, context, context_member, property_type, *, use_edit=True):
props.data_path = context_member
props.property_name = key
elif is_datablock:
value_column.template_ID(rna_item, '["%s"]' % escape_identifier(key), text="")
value_column.template_ID(rna_item, rna_idprop_quote_path(key), text="")
else:
value_column.prop(rna_item, '["%s"]' % escape_identifier(key), text="")
value_column.prop(rna_item, rna_idprop_quote_path(key), text="")
operator_row = value_row.row()
operator_row.alignment = 'RIGHT'

View File

@ -419,6 +419,25 @@ def _template_items_select_actions(params, operator):
]
def _template_items_select_lasso(params, operator):
# Needed because of shortcut conflicts on CTRL-LMB on right click select with brush modes,
# all modifier keys are used together to unmask/deselect.
if params.select_mouse == 'RIGHTMOUSE':
return [
(operator, {"type": params.action_mouse, "value": 'CLICK_DRAG', "shift": True, "ctrl": True},
{"properties": [("mode", 'SUB')]}),
(operator, {"type": params.action_mouse, "value": 'CLICK_DRAG', "shift": True, "ctrl": True, "alt": True},
{"properties": [("mode", 'ADD')]}),
]
else:
return [
(operator, {"type": params.action_mouse, "value": 'CLICK_DRAG', "shift": True, "ctrl": True},
{"properties": [("mode", 'SUB')]}),
(operator, {"type": params.action_mouse, "value": 'CLICK_DRAG', "ctrl": True},
{"properties": [("mode", 'ADD')]}),
]
def _template_items_hide_reveal_actions(op_hide, op_reveal):
return [
(op_reveal, {"type": 'H', "value": 'PRESS', "alt": True}, None),
@ -3638,7 +3657,7 @@ def km_grease_pencil(params):
return keymap
def _grease_pencil_selection(params, *, use_select_mouse=True):
def _grease_pencil_selection(params, *, alt_select=False):
return [
# Select all
*_template_items_select_actions(params, "gpencil.select_all"),
@ -3650,31 +3669,19 @@ def _grease_pencil_selection(params, *, use_select_mouse=True):
op_tool_optional(
("gpencil.select_box", {"type": 'B', "value": 'PRESS'}, None),
(op_tool, "builtin.select_box"), params),
# Lasso select
("gpencil.select_lasso", {"type": params.action_mouse, "value": 'CLICK_DRAG', "ctrl": True},
{"properties": [("mode", 'ADD')]}),
("gpencil.select_lasso", {"type": params.action_mouse, "value": 'CLICK_DRAG', "shift": True, "ctrl": True},
{"properties": [("mode", 'SUB')]}),
# In the Node Editor, lasso select needs ALT modifier too
# (as somehow CTRL+LMB drag gets taken for "cut" quite early).
# There probably isn't too much harm adding this for other editors too
# as part of standard GP editing keymap. This hotkey combo doesn't seem
# to see much use under standard scenarios?
("gpencil.select_lasso",
{"type": params.action_mouse, "value": 'CLICK_DRAG', "ctrl": True, "alt": True},
{"properties": [("mode", 'ADD')]}),
("gpencil.select_lasso",
{"type": params.action_mouse, "value": 'CLICK_DRAG', "shift": True, "ctrl": True, "alt": True},
{"properties": [("mode", 'SUB')]}),
*_template_view3d_gpencil_select(
type=params.select_mouse,
value=params.select_mouse_value_fallback,
legacy=params.legacy,
use_select_mouse=use_select_mouse,
alt_select=alt_select
),
# Select linked
("gpencil.select_linked", {"type": 'L', "value": 'PRESS'}, None),
("gpencil.select_linked", {"type": 'L', "value": 'PRESS', "ctrl": True}, None),
# Whole stroke select: Same behavior and use case as select linked pick.
("gpencil.select", {"type": 'L', "value": 'PRESS'},
{"properties": [("extend", True), ("entire_strokes", True)]}),
("gpencil.select", {"type": 'L', "value": 'PRESS', "shift": True},
{"properties": [("deselect", True), ("extend", True), ("entire_strokes", True)]}),
# Select grouped
("gpencil.select_grouped", {"type": 'G', "value": 'PRESS', "shift": True}, None),
# Select more/less
@ -3708,6 +3715,10 @@ def km_grease_pencil_stroke_edit_mode(params):
("gpencil.interpolate_sequence", {"type": 'E', "value": 'PRESS', "shift": True, "ctrl": True}, None),
# Selection
*_grease_pencil_selection(params),
("gpencil.select_lasso", {"type": params.action_mouse, "value": 'CLICK_DRAG', "ctrl": True},
{"properties": [("mode", 'ADD')]}),
("gpencil.select_lasso", {"type": params.action_mouse, "value": 'CLICK_DRAG', "shift": True, "ctrl": True},
{"properties": [("mode", 'SUB')]}),
# Duplicate and move selected points
("gpencil.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None),
# Extrude and move selected points
@ -3990,7 +4001,8 @@ def km_grease_pencil_stroke_sculpt_mode(params):
items.extend([
# Selection
*_grease_pencil_selection(params, use_select_mouse=not params.use_fallback_tool_select_mouse),
*_grease_pencil_selection(params, alt_select=True),
*_template_items_select_lasso(params, "gpencil.select_lasso"),
# Selection mode
("wm.context_toggle", {"type": 'ONE', "value": 'PRESS'},
{"properties": [("data_path", 'scene.tool_settings.use_gpencil_select_mask_point')]}),
@ -4347,7 +4359,8 @@ def km_grease_pencil_stroke_vertex_mode(params):
items.extend([
# Selection
*_grease_pencil_selection(params, use_select_mouse=not params.use_fallback_tool_select_mouse),
*_grease_pencil_selection(params, alt_select=True),
*_template_items_select_lasso(params, "gpencil.select_lasso"),
# Selection mode
("wm.context_toggle", {"type": 'ONE', "value": 'PRESS'},
{"properties": [("data_path", 'scene.tool_settings.use_gpencil_vertex_select_mask_point')]}),
@ -4917,19 +4930,23 @@ def _template_view3d_paint_mask_select_loop(params):
]
def _template_view3d_gpencil_select(*, type, value, legacy, use_select_mouse=True):
return [
*([] if not use_select_mouse else [
("gpencil.select", {"type": type, "value": value},
{"properties": [("deselect_all", not legacy)]})]),
def _template_view3d_gpencil_select(*, type, value, legacy, alt_select=False):
items = [
("gpencil.select", {"type": type, "value": value},
{"properties": [("deselect_all", not legacy)]}),
("gpencil.select", {"type": type, "value": value, "shift": True},
{"properties": [("extend", True), ("toggle", True)]}),
# Whole stroke select
("gpencil.select", {"type": type, "value": value, "alt": True},
{"properties": [("entire_strokes", True)]}),
("gpencil.select", {"type": type, "value": value, "shift": True, "alt": True},
{"properties": [("extend", True), ("entire_strokes", True)]}),
]
if type == 'LEFTMOUSE' and alt_select:
items.extend([
# Selection shortcuts for when brushes are active on LMB-select.
("gpencil.select", {"type": type, "value": value, "alt": True},
{"properties": [("deselect_all", True)]}),
("gpencil.select", {"type": type, "value": value, "alt": True, "shift": True},
{"properties": [("extend", True), ("toggle", True)]}),
])
return items
def _template_node_select(*, type, value, select_passthrough):
@ -5212,6 +5229,7 @@ def km_paint_face_mask(params):
items.extend([
*_template_items_select_actions(params, "paint.face_select_all"),
*_template_items_select_lasso(params, "view3d.select_lasso"),
*_template_items_hide_reveal_actions("paint.face_select_hide", "paint.face_vert_reveal"),
("paint.face_select_linked", {"type": 'L', "value": 'PRESS', "ctrl": True}, None),
("paint.face_select_linked_pick", {"type": 'L', "value": 'PRESS'},
@ -5240,12 +5258,9 @@ def km_paint_vertex_mask(params):
items.extend([
*_template_items_select_actions(params, "paint.vert_select_all"),
*_template_items_select_lasso(params, "view3d.select_lasso"),
*_template_items_hide_reveal_actions("paint.vert_select_hide", "paint.face_vert_reveal"),
("view3d.select_box", {"type": 'B', "value": 'PRESS'}, None),
("view3d.select_lasso", {"type": params.action_mouse, "value": 'CLICK_DRAG', "ctrl": True},
{"properties": [("mode", 'ADD')]}),
("view3d.select_lasso", {"type": params.action_mouse, "value": 'CLICK_DRAG', "shift": True, "ctrl": True},
{"properties": [("mode", 'SUB')]}),
("view3d.select_circle", {"type": 'C', "value": 'PRESS'}, None),
("paint.vert_select_linked", {"type": 'L', "value": 'PRESS', "ctrl": True}, None),
("paint.vert_select_linked_pick", {"type": 'L', "value": 'PRESS'},
@ -5338,7 +5353,6 @@ def km_sculpt(params):
{"properties": [("mode", 'INVERT')]}),
("paint.mask_box_gesture", {"type": 'B', "value": 'PRESS'},
{"properties": [("mode", 'VALUE'), ("value", 0.0)]}),
("paint.mask_lasso_gesture", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, None),
# Dynamic topology
("sculpt.dyntopo_detail_size_edit", {"type": 'R', "value": 'PRESS'}, None),
("sculpt.detail_flood_fill", {"type": 'R', "value": 'PRESS', "ctrl": True}, None),
@ -5381,6 +5395,26 @@ def km_sculpt(params):
*_template_items_context_panel("VIEW3D_PT_sculpt_context_menu", params.context_menu_event),
])
# Lasso Masking.
# Needed because of shortcut conflicts on CTRL-LMB on right click select,
# all modifier keys are used together to unmask (equivalent of selecting).
if params.select_mouse == 'RIGHTMOUSE':
items.extend([
("paint.mask_lasso_gesture",
{"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True},
{"properties": [("value", 1.0)]}),
("paint.mask_lasso_gesture",
{"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True},
{"properties": [("value", 0.0)]}),
])
else:
items.extend([
("paint.mask_lasso_gesture", {"type": 'RIGHTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True},
{"properties": [("value", 1.0)]}),
("paint.mask_lasso_gesture", {"type": 'RIGHTMOUSE', "value": 'PRESS', "ctrl": True},
{"properties": [("value", 0.0)]}),
])
if params.legacy:
items.extend(_template_items_legacy_tools_from_numbers())

View File

@ -103,27 +103,26 @@ class DATA_PT_lens(CameraButtonsPanel, Panel):
elif cam.type == 'PANO':
engine = context.engine
if engine == 'CYCLES':
ccam = cam.cycles
col.prop(ccam, "panorama_type")
if ccam.panorama_type == 'FISHEYE_EQUIDISTANT':
col.prop(ccam, "fisheye_fov")
elif ccam.panorama_type == 'FISHEYE_EQUISOLID':
col.prop(ccam, "fisheye_lens", text="Lens")
col.prop(ccam, "fisheye_fov")
elif ccam.panorama_type == 'EQUIRECTANGULAR':
col.prop(cam, "panorama_type")
if cam.panorama_type == 'FISHEYE_EQUIDISTANT':
col.prop(cam, "fisheye_fov")
elif cam.panorama_type == 'FISHEYE_EQUISOLID':
col.prop(cam, "fisheye_lens", text="Lens")
col.prop(cam, "fisheye_fov")
elif cam.panorama_type == 'EQUIRECTANGULAR':
sub = col.column(align=True)
sub.prop(ccam, "latitude_min", text="Latitude Min")
sub.prop(ccam, "latitude_max", text="Max")
sub.prop(cam, "latitude_min", text="Latitude Min")
sub.prop(cam, "latitude_max", text="Max")
sub = col.column(align=True)
sub.prop(ccam, "longitude_min", text="Longitude Min")
sub.prop(ccam, "longitude_max", text="Max")
elif ccam.panorama_type == 'FISHEYE_LENS_POLYNOMIAL':
col.prop(ccam, "fisheye_fov")
col.prop(ccam, "fisheye_polynomial_k0", text="K0")
col.prop(ccam, "fisheye_polynomial_k1", text="K1")
col.prop(ccam, "fisheye_polynomial_k2", text="K2")
col.prop(ccam, "fisheye_polynomial_k3", text="K3")
col.prop(ccam, "fisheye_polynomial_k4", text="K4")
sub.prop(cam, "longitude_min", text="Longitude Min")
sub.prop(cam, "longitude_max", text="Max")
elif cam.panorama_type == 'FISHEYE_LENS_POLYNOMIAL':
col.prop(cam, "fisheye_fov")
col.prop(cam, "fisheye_polynomial_k0", text="K0")
col.prop(cam, "fisheye_polynomial_k1", text="K1")
col.prop(cam, "fisheye_polynomial_k2", text="K2")
col.prop(cam, "fisheye_polynomial_k3", text="K3")
col.prop(cam, "fisheye_polynomial_k4", text="K4")
elif engine in {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_EEVEE_NEXT', 'BLENDER_WORKBENCH', 'BLENDER_WORKBENCH_NEXT'}:
if cam.lens_unit == 'MILLIMETERS':

View File

@ -111,7 +111,8 @@ class RENDER_PT_color_management_display_settings(RenderButtonsPanel, Panel):
# Only display HDR toggle for non-Filmic display transforms.
col = layout.column(align=True)
sub = col.row()
sub.active = (view.view_transform != "Filmic" and view.view_transform != "Filmic Log")
sub.active = (not view.view_transform.startswith("Filmic") and
not view.view_transform.startswith("AgX"))
sub.prop(view, "use_hdr_view")

View File

@ -29,7 +29,7 @@ extern "C" {
/* Blender file format version. */
#define BLENDER_FILE_VERSION BLENDER_VERSION
#define BLENDER_FILE_SUBVERSION 16
#define BLENDER_FILE_SUBVERSION 17
/* Minimum Blender version that supports reading file written with the current
* version. Older Blender versions will test this and cancel loading the file, showing a warning to

View File

@ -7,18 +7,21 @@
* \ingroup bke
*/
#include "BLI_math_inline.h"
#include "BLI_math_vector_types.hh"
#include <float.h>
#ifdef __cplusplus
extern "C" {
#endif
struct BVHTree;
struct ClothVertex;
struct ClothModifierData;
struct CollisionModifierData;
struct Implicit_Data;
struct Depsgraph;
struct EdgeSet;
struct GHash;
struct LinkNode;
struct Mesh;
struct MVertTri;
struct Object;
struct Scene;
@ -32,27 +35,27 @@ struct Scene;
#define ALMOST_ZERO FLT_EPSILON
/* Bits to or into the #ClothVertex.flags. */
typedef enum eClothVertexFlag {
enum eClothVertexFlag {
CLOTH_VERT_FLAG_PINNED = (1 << 0),
CLOTH_VERT_FLAG_NOSELFCOLL = (1 << 1), /* vertex NOT used for self collisions */
CLOTH_VERT_FLAG_NOOBJCOLL = (1 << 2), /* vertex NOT used for object collisions */
} eClothVertexFlag;
};
typedef struct ClothHairData {
struct ClothHairData {
float loc[3];
float rot[3][3];
float rest_target[3]; /* rest target direction for each segment */
float radius;
float bending_stiffness;
} ClothHairData;
};
typedef struct ClothSolverResult {
struct ClothSolverResult {
int status;
int max_iterations, min_iterations;
float avg_iterations;
float max_error, min_error, avg_error;
} ClothSolverResult;
};
/**
* This structure describes a cloth object against which the
@ -63,31 +66,31 @@ typedef struct ClothSolverResult {
* At some point they need to disappear and we need to determine out
* own connectivity of the mesh based on the actual edges in the mesh.
*/
typedef struct Cloth {
struct ClothVertex *verts; /* The vertices that represent this cloth. */
struct LinkNode *springs; /* The springs connecting the mesh. */
struct Cloth {
ClothVertex *verts; /* The vertices that represent this cloth. */
LinkNode *springs; /* The springs connecting the mesh. */
unsigned int numsprings; /* The count of springs. */
unsigned int mvert_num; /* The number of verts == m * n. */
unsigned int primitive_num; /* Number of triangles for cloth and edges for hair. */
unsigned char old_solver_type; /* unused, only 1 solver here */
unsigned char pad2;
short pad3;
struct BVHTree *bvhtree; /* collision tree for this cloth object */
struct BVHTree *bvhselftree; /* collision tree for this cloth object (may be same as bvhtree) */
struct MVertTri *tri;
struct Implicit_Data *implicit; /* our implicit solver connects to this pointer */
struct EdgeSet *edgeset; /* used for selfcollisions */
BVHTree *bvhtree; /* collision tree for this cloth object */
BVHTree *bvhselftree; /* collision tree for this cloth object (may be same as bvhtree) */
MVertTri *tri;
Implicit_Data *implicit; /* our implicit solver connects to this pointer */
EdgeSet *edgeset; /* used for selfcollisions */
int last_frame;
float initial_mesh_volume; /* Initial volume of the mesh. Used for pressure */
float average_acceleration[3]; /* Moving average of overall acceleration. */
const struct vec2i *edges; /* Used for hair collisions. */
struct EdgeSet *sew_edge_graph; /* Sewing edges represented using a GHash */
} Cloth;
float initial_mesh_volume; /* Initial volume of the mesh. Used for pressure */
float average_acceleration[3]; /* Moving average of overall acceleration. */
const blender::int2 *edges; /* Used for hair collisions. */
EdgeSet *sew_edge_graph; /* Sewing edges represented using a GHash */
};
/**
* The definition of a cloth vertex.
*/
typedef struct ClothVertex {
struct ClothVertex {
int flags; /* General flags per vertex. */
float v[3]; /* The velocity of the point. */
float xconst[3]; /* constrained position */
@ -110,12 +113,12 @@ typedef struct ClothVertex {
float shrink_factor; /* how much to shrink this cloth */
float internal_stiff; /* internal spring stiffness scaling */
float pressure_factor; /* how much pressure should affect this vertex */
} ClothVertex;
};
/**
* The definition of a spring.
*/
typedef struct ClothSpring {
struct ClothSpring {
int ij; /* `Pij` from the paper, one end of the spring. */
int kl; /* `Pkl` from the paper, one end of the spring. */
int mn; /* For hair springs: third vertex index; For bending springs: edge index; */
@ -125,15 +128,15 @@ typedef struct ClothSpring {
int lb; /* Length of `*pb`. */
float restlen; /* The original length of the spring. */
float restang; /* The original angle of the bending springs. */
int type; /* Types defined in BKE_cloth.h ("springType"). */
int flags; /* Defined in BKE_cloth.h, e.g. deactivated due to tearing. */
int type; /* Types defined in BKE_cloth.hh ("springType"). */
int flags; /* Defined in BKE_cloth.hh, e.g. deactivated due to tearing. */
float lin_stiffness; /* Linear stiffness factor from the vertex groups. */
float ang_stiffness; /* Angular stiffness factor from the vertex groups. */
float editrestlen;
/* angular bending spring target and derivatives */
float target[3];
} ClothSpring;
};
/* Some macro enhancements for vector treatment. */
#define VECSUBADDSS(v1, v2, aS, v3, bS) \
@ -180,7 +183,7 @@ typedef struct ClothSpring {
((void)0)
/* Spring types as defined in the paper. */
typedef enum {
enum CLOTH_SPRING_TYPES {
CLOTH_SPRING_TYPE_STRUCTURAL = (1 << 1),
CLOTH_SPRING_TYPE_SHEAR = (1 << 2),
CLOTH_SPRING_TYPE_BENDING = (1 << 3),
@ -188,61 +191,54 @@ typedef enum {
CLOTH_SPRING_TYPE_SEWING = (1 << 5),
CLOTH_SPRING_TYPE_BENDING_HAIR = (1 << 6),
CLOTH_SPRING_TYPE_INTERNAL = (1 << 7),
} CLOTH_SPRING_TYPES;
};
/* SPRING FLAGS */
typedef enum {
enum CLOTH_SPRINGS_FLAGS {
CLOTH_SPRING_FLAG_DEACTIVATE = (1 << 1),
CLOTH_SPRING_FLAG_NEEDED = (1 << 2), /* Springs has values to be applied. */
} CLOTH_SPRINGS_FLAGS;
};
/* -------------------------------------------------------------------- */
/* collision.cc */
struct CollPair;
typedef struct ColliderContacts {
struct Object *ob;
struct CollisionModifierData *collmd;
struct ColliderContacts {
Object *ob;
CollisionModifierData *collmd;
struct CollPair *collisions;
CollPair *collisions;
int totcollisions;
} ColliderContacts;
};
/* needed for implicit.c */
int cloth_bvh_collision(struct Depsgraph *depsgraph,
struct Object *ob,
struct ClothModifierData *clmd,
float step,
float dt);
int cloth_bvh_collision(
Depsgraph *depsgraph, Object *ob, ClothModifierData *clmd, float step, float dt);
/* -------------------------------------------------------------------- */
/* cloth.cc */
/* Needed for modifier.cc */
/** Frees all. */
void cloth_free_modifier_extern(struct ClothModifierData *clmd);
void cloth_free_modifier_extern(ClothModifierData *clmd);
/** Frees all. */
void cloth_free_modifier(struct ClothModifierData *clmd);
void clothModifier_do(struct ClothModifierData *clmd,
struct Depsgraph *depsgraph,
struct Scene *scene,
struct Object *ob,
struct Mesh *me,
void cloth_free_modifier(ClothModifierData *clmd);
void clothModifier_do(ClothModifierData *clmd,
Depsgraph *depsgraph,
Scene *scene,
Object *ob,
Mesh *me,
float (*vertexCos)[3]);
int cloth_uses_vgroup(struct ClothModifierData *clmd);
int cloth_uses_vgroup(ClothModifierData *clmd);
/* Needed for collision.cc */
void bvhtree_update_from_cloth(struct ClothModifierData *clmd, bool moving, bool self);
void bvhtree_update_from_cloth(ClothModifierData *clmd, bool moving, bool self);
/* Needed for button_object.c */
void cloth_clear_cache(struct Object *ob, struct ClothModifierData *clmd, float framenr);
void cloth_clear_cache(Object *ob, ClothModifierData *clmd, float framenr);
void cloth_parallel_transport_hair_frame(float mat[3][3],
const float dir_old[3],
const float dir_new[3]);
#ifdef __cplusplus
}
#endif

View File

@ -351,7 +351,7 @@ set(SRC
BKE_camera.h
BKE_ccg.h
BKE_cdderivedmesh.h
BKE_cloth.h
BKE_cloth.hh
BKE_collection.h
BKE_collision.h
BKE_colorband.h

View File

@ -27,6 +27,7 @@
#include "BLI_math_geom.h"
#include "BLI_math_matrix.h"
#include "BLI_math_vector_types.hh"
#include "BLI_span.hh"
#include "BLI_task.h"
#include "BLI_task.hh"
#include "BLI_utildefines.h"
@ -71,6 +72,7 @@
using blender::float3;
using blender::IndexRange;
using blender::MutableSpan;
using blender::Span;
using blender::VArray;
using blender::bke::GeometryOwnershipType;
@ -400,47 +402,51 @@ static Mesh *create_orco_mesh(Object *ob, Mesh *me, BMEditMesh *em, int layer)
return mesh;
}
static MutableSpan<float3> orco_coord_layer_ensure(Mesh *mesh, const eCustomDataType layer)
{
void *data = CustomData_get_layer_for_write(&mesh->vert_data, layer, mesh->totvert);
if (!data) {
data = CustomData_add_layer(&mesh->vert_data, layer, CD_CONSTRUCT, mesh->totvert);
}
return MutableSpan(reinterpret_cast<float3 *>(data), mesh->totvert);
}
static void add_orco_mesh(
Object *ob, BMEditMesh *em, Mesh *mesh, Mesh *mesh_orco, const eCustomDataType layer)
{
float(*orco)[3], (*layerorco)[3];
int totvert, free;
totvert = mesh->totvert;
const int totvert = mesh->totvert;
MutableSpan<float3> layer_orco;
if (mesh_orco) {
free = 1;
layer_orco = orco_coord_layer_ensure(mesh, layer);
if (mesh_orco->totvert == totvert) {
orco = BKE_mesh_vert_coords_alloc(mesh_orco, nullptr);
layer_orco.copy_from(mesh_orco->vert_positions());
}
else {
orco = BKE_mesh_vert_coords_alloc(mesh, nullptr);
layer_orco.copy_from(mesh->vert_positions());
}
}
else {
/* TODO(sybren): totvert should potentially change here, as ob->data
* or em may have a different number of vertices than dm. */
orco = get_orco_coords(ob, em, layer, &free);
}
if (orco) {
if (layer == CD_ORCO) {
BKE_mesh_orco_verts_transform((Mesh *)ob->data, orco, totvert, 0);
int free = 0;
float(*orco)[3] = get_orco_coords(ob, em, layer, &free);
if (orco) {
layer_orco = orco_coord_layer_ensure(mesh, layer);
layer_orco.copy_from(Span<float3>(reinterpret_cast<float3 *>(orco), totvert));
}
layerorco = (float(*)[3])CustomData_get_layer_for_write(
&mesh->vert_data, layer, mesh->totvert);
if (!layerorco) {
layerorco = (float(*)[3])CustomData_add_layer(
&mesh->vert_data, eCustomDataType(layer), CD_SET_DEFAULT, mesh->totvert);
}
memcpy(layerorco, orco, sizeof(float[3]) * totvert);
if (free) {
MEM_freeN(orco);
}
}
if (!layer_orco.is_empty()) {
if (layer == CD_ORCO) {
BKE_mesh_orco_verts_transform(
(Mesh *)ob->data, reinterpret_cast<float(*)[3]>(layer_orco.data()), totvert, 0);
}
}
}
static bool mesh_has_modifier_final_normals(const Mesh *mesh_input,
@ -1129,7 +1135,7 @@ static void editbmesh_calc_modifier_final_normals_or_defer(
editbmesh_calc_modifier_final_normals(mesh_final, final_datamask);
}
static blender::MutableSpan<float3> mesh_wrapper_vert_coords_ensure_for_write(Mesh *mesh)
static MutableSpan<float3> mesh_wrapper_vert_coords_ensure_for_write(Mesh *mesh)
{
switch (mesh->runtime->wrapper_type) {
case ME_WRAPPER_TYPE_BMESH:

View File

@ -31,6 +31,7 @@
#include "BKE_action.h"
#include "BKE_anim_data.h"
#include "BKE_camera.h"
#include "BKE_idprop.h"
#include "BKE_idtype.h"
#include "BKE_layer.h"
#include "BKE_lib_id.h"
@ -103,10 +104,97 @@ static void camera_foreach_id(ID *id, LibraryForeachIDData *data)
}
}
struct CameraCyclesCompatibilityData {
IDProperty *idprop_prev = nullptr;
IDProperty *idprop_temp = nullptr;
};
static CameraCyclesCompatibilityData camera_write_cycles_compatibility_data_create(ID *id)
{
auto cycles_data_ensure = [](IDProperty *group) {
IDProperty *prop = IDP_GetPropertyTypeFromGroup(group, "cycles", IDP_GROUP);
if (prop) {
return prop;
}
IDPropertyTemplate val = {0};
prop = IDP_New(IDP_GROUP, &val, "cycles");
IDP_AddToGroup(group, prop);
return prop;
};
auto cycles_property_int_set = [](IDProperty *idprop, const char *name, int value) {
IDProperty *prop = IDP_GetPropertyTypeFromGroup(idprop, name, IDP_INT);
if (prop) {
IDP_Int(prop) = value;
}
else {
IDPropertyTemplate val = {0};
val.i = value;
IDP_AddToGroup(idprop, IDP_New(IDP_INT, &val, name));
}
};
auto cycles_property_float_set = [](IDProperty *idprop, const char *name, float value) {
IDProperty *prop = IDP_GetPropertyTypeFromGroup(idprop, name, IDP_FLOAT);
if (prop) {
IDP_Float(prop) = value;
}
else {
IDPropertyTemplate val = {0};
val.f = value;
IDP_AddToGroup(idprop, IDP_New(IDP_FLOAT, &val, name));
}
};
/* For forward compatibility, still write panoramic properties as ID properties for
* previous blender versions. */
IDProperty *idprop_prev = IDP_GetProperties(id, false);
/* Make a copy to avoid modifying the original. */
IDProperty *idprop_temp = idprop_prev ? IDP_CopyProperty(idprop_prev) :
IDP_GetProperties(id, true);
Camera *cam = (Camera *)id;
IDProperty *cycles_cam = cycles_data_ensure(idprop_temp);
cycles_property_int_set(cycles_cam, "panorama_type", cam->panorama_type);
cycles_property_float_set(cycles_cam, "fisheye_fov", cam->fisheye_fov);
cycles_property_float_set(cycles_cam, "fisheye_lens", cam->fisheye_lens);
cycles_property_float_set(cycles_cam, "latitude_min", cam->latitude_min);
cycles_property_float_set(cycles_cam, "latitude_max", cam->latitude_max);
cycles_property_float_set(cycles_cam, "longitude_min", cam->longitude_min);
cycles_property_float_set(cycles_cam, "longitude_max", cam->longitude_max);
cycles_property_float_set(cycles_cam, "fisheye_polynomial_k0", cam->fisheye_polynomial_k0);
cycles_property_float_set(cycles_cam, "fisheye_polynomial_k1", cam->fisheye_polynomial_k1);
cycles_property_float_set(cycles_cam, "fisheye_polynomial_k2", cam->fisheye_polynomial_k2);
cycles_property_float_set(cycles_cam, "fisheye_polynomial_k3", cam->fisheye_polynomial_k3);
cycles_property_float_set(cycles_cam, "fisheye_polynomial_k4", cam->fisheye_polynomial_k4);
id->properties = idprop_temp;
return {idprop_prev, idprop_temp};
}
static void camera_write_cycles_compatibility_data_clear(ID *id,
CameraCyclesCompatibilityData &data)
{
id->properties = data.idprop_prev;
data.idprop_prev = nullptr;
if (data.idprop_temp) {
IDP_FreeProperty(data.idprop_temp);
data.idprop_temp = nullptr;
}
}
static void camera_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
const bool is_undo = BLO_write_is_undo(writer);
Camera *cam = (Camera *)id;
CameraCyclesCompatibilityData cycles_data;
if (!is_undo) {
cycles_data = camera_write_cycles_compatibility_data_create(id);
}
/* write LibData */
BLO_write_id_struct(writer, Camera, id_address, &cam->id);
BKE_id_blend_write(writer, &cam->id);
@ -114,6 +202,10 @@ static void camera_blend_write(BlendWriter *writer, ID *id, const void *id_addre
LISTBASE_FOREACH (CameraBGImage *, bgpic, &cam->bg_images) {
BLO_write_struct(writer, CameraBGImage, bgpic);
}
if (!is_undo) {
camera_write_cycles_compatibility_data_clear(id, cycles_data);
}
}
static void camera_blend_read_data(BlendDataReader *reader, ID *id)

View File

@ -27,7 +27,7 @@
#include "DEG_depsgraph_query.h"
#include "BKE_bvhutils.h"
#include "BKE_cloth.h"
#include "BKE_cloth.hh"
#include "BKE_effect.h"
#include "BKE_global.h"
#include "BKE_lib_id.h"
@ -101,7 +101,7 @@ static BVHTree *bvhtree_build_from_cloth(ClothModifierData *clmd, float epsilon)
}
}
else {
const blender::int2 *edges = reinterpret_cast<const blender::int2 *>(cloth->edges);
const blender::int2 *edges = cloth->edges;
for (int i = 0; i < cloth->primitive_num; i++) {
float co[2][3];
@ -373,7 +373,7 @@ void clothModifier_do(ClothModifierData *clmd,
/* Since implicit sharing is introduced, mesh data can be moved to other places.
* Therefore some fields in simulation data need to be updated accordingly */
clmd->clothObject->edges = reinterpret_cast<const vec2i *>(mesh->edges().data());
clmd->clothObject->edges = mesh->edges().data();
/* try to read from cache */
bool can_simulate = (framenr == clmd->clothObject->last_frame + 1) &&
@ -883,7 +883,7 @@ static void cloth_from_mesh(ClothModifierData *clmd, const Object *ob, Mesh *mes
BKE_mesh_runtime_verttri_from_looptri(
clmd->clothObject->tri, corner_verts.data(), looptris.data(), looptris.size());
clmd->clothObject->edges = reinterpret_cast<const vec2i *>(mesh->edges().data());
clmd->clothObject->edges = mesh->edges().data();
/* Free the springs since they can't be correct if the vertices
* changed.

View File

@ -25,7 +25,7 @@
#include "BLI_threads.h"
#include "BLI_utildefines.h"
#include "BKE_cloth.h"
#include "BKE_cloth.hh"
#include "BKE_collection.h"
#include "BKE_effect.h"
#include "BKE_layer.h"

View File

@ -1217,15 +1217,14 @@ static BezTriple *cycle_offset_triple(
void BKE_fcurve_handles_recalc_ex(FCurve *fcu, eBezTriple_Flag handle_sel_flag)
{
int a = fcu->totvert;
/* Error checking:
* - Need at least two points.
* - Need bezier keys.
* - Only bezier-interpolation has handles (for now).
*/
if (ELEM(nullptr, fcu, fcu->bezt) ||
(a < 2) /*|| ELEM(fcu->ipo, BEZT_IPO_CONST, BEZT_IPO_LIN) */) {
(fcu->totvert < 2) /*|| ELEM(fcu->ipo, BEZT_IPO_CONST, BEZT_IPO_LIN) */)
{
return;
}
@ -1241,6 +1240,7 @@ void BKE_fcurve_handles_recalc_ex(FCurve *fcu, eBezTriple_Flag handle_sel_flag)
BezTriple *next = (bezt + 1);
/* Loop over all beztriples, adjusting handles. */
int a = fcu->totvert;
while (a--) {
/* Clamp timing of handles to be on either side of beztriple. */
if (bezt->vec[0][0] > bezt->vec[1][0]) {

View File

@ -48,7 +48,7 @@
#include "BKE_anim_data.h"
#include "BKE_anim_path.h"
#include "BKE_boids.h"
#include "BKE_cloth.h"
#include "BKE_cloth.hh"
#include "BKE_collection.h"
#include "BKE_colortools.h"
#include "BKE_deform.h"

View File

@ -55,7 +55,7 @@
#include "BKE_particle.h"
#include "BKE_bvhutils.h"
#include "BKE_cloth.h"
#include "BKE_cloth.hh"
#include "BKE_collection.h"
#include "BKE_lattice.h"
#include "BKE_material.h"

View File

@ -39,7 +39,7 @@
#include "PIL_time.h"
#include "BKE_appdir.h"
#include "BKE_cloth.h"
#include "BKE_cloth.hh"
#include "BKE_collection.h"
#include "BKE_dynamicpaint.h"
#include "BKE_fluid.h"

View File

@ -57,7 +57,7 @@
#include "BKE_animsys.h"
#include "BKE_blender.h"
#include "BKE_brush.hh"
#include "BKE_cloth.h"
#include "BKE_cloth.hh"
#include "BKE_collection.h"
#include "BKE_colortools.h"
#include "BKE_constraint.h"

View File

@ -13,6 +13,7 @@
#include "CLG_log.h"
#include "DNA_brush_types.h"
#include "DNA_camera_types.h"
#include "DNA_light_types.h"
#include "DNA_lightprobe_types.h"
#include "DNA_modifier_types.h"
@ -675,19 +676,7 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain)
FOREACH_NODETREE_END;
}
/**
* Versioning code until next subversion bump goes here.
*
* \note Be sure to check when bumping the version:
* - #do_versions_after_linking_400 in this file.
* - `versioning_userdef.cc`, #blo_do_versions_userdef
* - `versioning_userdef.cc`, #do_versions_theme
*
* \note Keep this message at the bottom of the function.
*/
{
/* Keep this block, even when empty. */
if (!MAIN_VERSION_FILE_ATLEAST(bmain, 400, 17)) {
if (!DNA_struct_find(fd->filesdna, "NodeShaderHairPrincipled")) {
FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
if (ntree->type == NTREE_SHADER) {
@ -697,6 +686,56 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain)
FOREACH_NODETREE_END;
}
/* Panorama properties shared with Eevee. */
if (!DNA_struct_elem_find(fd->filesdna, "Camera", "float", "fisheye_fov")) {
Camera default_cam = *DNA_struct_default_get(Camera);
LISTBASE_FOREACH (Camera *, camera, &bmain->cameras) {
IDProperty *ccam = version_cycles_properties_from_ID(&camera->id);
if (ccam) {
camera->panorama_type = version_cycles_property_int(
ccam, "panorama_type", default_cam.panorama_type);
camera->fisheye_fov = version_cycles_property_float(
ccam, "fisheye_fov", default_cam.fisheye_fov);
camera->fisheye_lens = version_cycles_property_float(
ccam, "fisheye_lens", default_cam.fisheye_lens);
camera->latitude_min = version_cycles_property_float(
ccam, "latitude_min", default_cam.latitude_min);
camera->latitude_max = version_cycles_property_float(
ccam, "latitude_max", default_cam.latitude_max);
camera->longitude_min = version_cycles_property_float(
ccam, "longitude_min", default_cam.longitude_min);
camera->longitude_max = version_cycles_property_float(
ccam, "longitude_max", default_cam.longitude_max);
/* Fit to match default projective camera with focal_length 50 and sensor_width 36. */
camera->fisheye_polynomial_k0 = version_cycles_property_float(
ccam, "fisheye_polynomial_k0", default_cam.fisheye_polynomial_k0);
camera->fisheye_polynomial_k1 = version_cycles_property_float(
ccam, "fisheye_polynomial_k1", default_cam.fisheye_polynomial_k1);
camera->fisheye_polynomial_k2 = version_cycles_property_float(
ccam, "fisheye_polynomial_k2", default_cam.fisheye_polynomial_k2);
camera->fisheye_polynomial_k3 = version_cycles_property_float(
ccam, "fisheye_polynomial_k3", default_cam.fisheye_polynomial_k3);
camera->fisheye_polynomial_k4 = version_cycles_property_float(
ccam, "fisheye_polynomial_k4", default_cam.fisheye_polynomial_k4);
}
else {
camera->panorama_type = default_cam.panorama_type;
camera->fisheye_fov = default_cam.fisheye_fov;
camera->fisheye_lens = default_cam.fisheye_lens;
camera->latitude_min = default_cam.latitude_min;
camera->latitude_max = default_cam.latitude_max;
camera->longitude_min = default_cam.longitude_min;
camera->longitude_max = default_cam.longitude_max;
/* Fit to match default projective camera with focal_length 50 and sensor_width 36. */
camera->fisheye_polynomial_k0 = default_cam.fisheye_polynomial_k0;
camera->fisheye_polynomial_k1 = default_cam.fisheye_polynomial_k1;
camera->fisheye_polynomial_k2 = default_cam.fisheye_polynomial_k2;
camera->fisheye_polynomial_k3 = default_cam.fisheye_polynomial_k3;
camera->fisheye_polynomial_k4 = default_cam.fisheye_polynomial_k4;
}
}
}
if (!DNA_struct_elem_find(fd->filesdna, "LightProbe", "float", "grid_flag")) {
LISTBASE_FOREACH (LightProbe *, lightprobe, &bmain->lightprobes) {
/* Keep old behavior of baking the whole lighting. */
@ -711,4 +750,18 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain)
}
}
}
/**
* Versioning code until next subversion bump goes here.
*
* \note Be sure to check when bumping the version:
* - #do_versions_after_linking_400 in this file.
* - `versioning_userdef.cc`, #blo_do_versions_userdef
* - `versioning_userdef.cc`, #do_versions_theme
*
* \note Keep this message at the bottom of the function.
*/
{
/* Keep this block, even when empty. */
}
}

View File

@ -536,6 +536,9 @@ void BLO_update_defaults_startup_blend(Main *bmain, const char *app_template)
STRNCPY(scene->view_settings.look, "None");
}
else {
/* Default to AgX view transform. */
STRNCPY(scene->view_settings.view_transform, "AgX");
/* AV Sync break physics sim caching, disable until that is fixed. */
scene->audio.flag &= ~AUDIO_SYNC;
scene->flag &= ~SCE_FRAME_DROP;

View File

@ -243,7 +243,7 @@ static bool eyedropper_cryptomatte_sample_image_fl(const bNode *node,
static bool eyedropper_cryptomatte_sample_fl(bContext *C,
Eyedropper *eye,
const int m_xy[2],
const int event_xy[2],
float r_col[3])
{
bNode *node = eye->crypto_node;
@ -254,17 +254,17 @@ static bool eyedropper_cryptomatte_sample_fl(bContext *C,
}
bScreen *screen = CTX_wm_screen(C);
ScrArea *area = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, m_xy);
ScrArea *area = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, event_xy);
if (!area || !ELEM(area->spacetype, SPACE_IMAGE, SPACE_NODE, SPACE_CLIP)) {
return false;
}
ARegion *region = BKE_area_find_region_xy(area, RGN_TYPE_WINDOW, m_xy);
ARegion *region = BKE_area_find_region_xy(area, RGN_TYPE_WINDOW, event_xy);
if (!region) {
return false;
}
int mval[2] = {m_xy[0] - region->winrct.xmin, m_xy[1] - region->winrct.ymin};
int mval[2] = {event_xy[0] - region->winrct.xmin, event_xy[1] - region->winrct.ymin};
float fpos[2] = {-1.0f, -1.0};
switch (area->spacetype) {
case SPACE_IMAGE: {
@ -313,12 +313,12 @@ static bool eyedropper_cryptomatte_sample_fl(bContext *C,
return false;
}
void eyedropper_color_sample_fl(bContext *C, const int m_xy[2], float r_col[3])
void eyedropper_color_sample_fl(bContext *C, const int event_xy[2], float r_col[3])
{
ScrArea *area = nullptr;
int mval[2];
wmWindow *win = WM_window_find_under_cursor(CTX_wm_window(C), m_xy, mval);
wmWindow *win = WM_window_find_under_cursor(CTX_wm_window(C), event_xy, mval);
if (win) {
bScreen *screen = WM_window_get_active_screen(win);
area = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, mval);
@ -393,17 +393,17 @@ static void eyedropper_color_set(bContext *C, Eyedropper *eye, const float col[3
RNA_property_update(C, &eye->ptr, eye->prop);
}
static void eyedropper_color_sample(bContext *C, Eyedropper *eye, const int m_xy[2])
static void eyedropper_color_sample(bContext *C, Eyedropper *eye, const int event_xy[2])
{
/* Accumulate color. */
float col[3];
if (eye->crypto_node) {
if (!eyedropper_cryptomatte_sample_fl(C, eye, m_xy, col)) {
if (!eyedropper_cryptomatte_sample_fl(C, eye, event_xy, col)) {
return;
}
}
else {
eyedropper_color_sample_fl(C, m_xy, col);
eyedropper_color_sample_fl(C, event_xy, col);
}
if (!eye->crypto_node) {
@ -426,13 +426,15 @@ static void eyedropper_color_sample(bContext *C, Eyedropper *eye, const int m_xy
eyedropper_color_set(C, eye, accum_col);
}
static void eyedropper_color_sample_text_update(bContext *C, Eyedropper *eye, const int m_xy[2])
static void eyedropper_color_sample_text_update(bContext *C,
Eyedropper *eye,
const int event_xy[2])
{
float col[3];
eye->sample_text[0] = '\0';
if (eye->cryptomatte_session) {
if (eyedropper_cryptomatte_sample_fl(C, eye, m_xy, col)) {
if (eyedropper_cryptomatte_sample_fl(C, eye, event_xy, col)) {
BKE_cryptomatte_find_name(
eye->cryptomatte_session, col[0], eye->sample_text, sizeof(eye->sample_text));
eye->sample_text[sizeof(eye->sample_text) - 1] = '\0';

View File

@ -137,7 +137,7 @@ static void datadropper_exit(bContext *C, wmOperator *op)
* \brief get the ID from the 3D view or outliner.
*/
static void datadropper_id_sample_pt(
bContext *C, wmWindow *win, ScrArea *area, DataDropper *ddr, const int m_xy[2], ID **r_id)
bContext *C, wmWindow *win, ScrArea *area, DataDropper *ddr, const int event_xy[2], ID **r_id)
{
wmWindow *win_prev = CTX_wm_window(C);
ScrArea *area_prev = CTX_wm_area(C);
@ -147,9 +147,9 @@ static void datadropper_id_sample_pt(
if (area) {
if (ELEM(area->spacetype, SPACE_VIEW3D, SPACE_OUTLINER)) {
ARegion *region = BKE_area_find_region_xy(area, RGN_TYPE_WINDOW, m_xy);
ARegion *region = BKE_area_find_region_xy(area, RGN_TYPE_WINDOW, event_xy);
if (region) {
const int mval[2] = {m_xy[0] - region->winrct.xmin, m_xy[1] - region->winrct.ymin};
const int mval[2] = {event_xy[0] - region->winrct.xmin, event_xy[1] - region->winrct.ymin};
Base *base;
CTX_wm_window_set(C, win);
@ -217,16 +217,16 @@ static bool datadropper_id_set(bContext *C, DataDropper *ddr, ID *id)
}
/* single point sample & set */
static bool datadropper_id_sample(bContext *C, DataDropper *ddr, const int m_xy[2])
static bool datadropper_id_sample(bContext *C, DataDropper *ddr, const int event_xy[2])
{
ID *id = nullptr;
int mval[2];
int event_xy_win[2];
wmWindow *win;
ScrArea *area;
datadropper_win_area_find(C, m_xy, mval, &win, &area);
datadropper_win_area_find(C, event_xy, event_xy_win, &win, &area);
datadropper_id_sample_pt(C, win, area, ddr, mval, &id);
datadropper_id_sample_pt(C, win, area, ddr, event_xy_win, &id);
return datadropper_id_set(C, ddr, id);
}
@ -288,15 +288,15 @@ static int datadropper_modal(bContext *C, wmOperator *op, const wmEvent *event)
else if (event->type == MOUSEMOVE) {
ID *id = nullptr;
int mval[2];
int event_xy_win[2];
wmWindow *win;
ScrArea *area;
datadropper_win_area_find(C, event->xy, mval, &win, &area);
datadropper_win_area_find(C, event->xy, event_xy_win, &win, &area);
/* Set the region for eyedropper cursor text drawing */
datadropper_set_draw_callback_region(area, ddr);
datadropper_id_sample_pt(C, win, area, ddr, mval, &id);
datadropper_id_sample_pt(C, win, area, ddr, event_xy_win, &id);
}
return OPERATOR_RUNNING_MODAL;

View File

@ -24,8 +24,11 @@ void eyedropper_draw_cursor_text_region(const int xy[2], const char *name);
* \return A button under the mouse which relates to some RNA Property, or NULL
*/
uiBut *eyedropper_get_property_button_under_mouse(bContext *C, const wmEvent *event);
void datadropper_win_area_find(
const bContext *C, const int mval[2], int r_mval[2], wmWindow **r_win, ScrArea **r_area);
void datadropper_win_area_find(const bContext *C,
const int event_xy[2],
int r_event_xy[2],
wmWindow **r_win,
ScrArea **r_area);
/* interface_eyedropper_color.c (expose for color-band picker) */

View File

@ -140,22 +140,25 @@ uiBut *eyedropper_get_property_button_under_mouse(bContext *C, const wmEvent *ev
return but;
}
void datadropper_win_area_find(
const bContext *C, const int mval[2], int r_mval[2], wmWindow **r_win, ScrArea **r_area)
void datadropper_win_area_find(const bContext *C,
const int event_xy[2],
int r_event_xy[2],
wmWindow **r_win,
ScrArea **r_area)
{
bScreen *screen = CTX_wm_screen(C);
*r_win = CTX_wm_window(C);
*r_area = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, mval);
*r_area = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, event_xy);
if (*r_area == nullptr) {
*r_win = WM_window_find_under_cursor(*r_win, mval, r_mval);
*r_win = WM_window_find_under_cursor(*r_win, event_xy, r_event_xy);
if (*r_win) {
screen = WM_window_get_active_screen(*r_win);
*r_area = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, r_mval);
*r_area = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, r_event_xy);
}
}
else if (mval != r_mval) {
copy_v2_v2_int(r_mval, mval);
else if (event_xy != r_event_xy) {
copy_v2_v2_int(r_event_xy, event_xy);
}
}

View File

@ -1055,16 +1055,13 @@ static uiTooltipData *ui_tooltip_data_from_gizmo(bContext *C, wmGizmo *gz)
std::string info = WM_operatortype_description_or_name(C, gzop->type, &gzop->ptr);
if (!info.empty()) {
const char *text = info.c_str();
uiTooltipField *field = text_field_add(
data, uiTooltipFormat::Style::Header, uiTooltipFormat::ColorID::Value, true);
if (gzop_actions[i].prefix != nullptr) {
text = BLI_sprintfN("%s: %s", gzop_actions[i].prefix, info.c_str());
field->text = BLI_sprintfN("%s: %s", gzop_actions[i].prefix, info.c_str());
}
if (text != nullptr) {
uiTooltipField *field = text_field_add(
data, uiTooltipFormat::Style::Header, uiTooltipFormat::ColorID::Value, true);
field->text = BLI_strdup(text);
else {
field->text = BLI_strdup(info.c_str());
}
}

View File

@ -2986,6 +2986,8 @@ static void constraint_ops_extra_draw(bContext *C, uiLayout *layout, void *con_v
uiLayoutSetUnitsX(layout, 4.0f);
UI_block_flag_enable(uiLayoutGetBlock(layout), UI_BLOCK_IS_FLIP);
/* Apply. */
uiItemO(layout,
CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Apply"),

View File

@ -779,8 +779,9 @@ static Mesh *create_applied_mesh_for_modifier(Depsgraph *depsgraph,
Mesh *mesh_temp = reinterpret_cast<Mesh *>(
BKE_id_copy_ex(nullptr, &me->id, nullptr, LIB_ID_COPY_LOCALIZE));
int numVerts = 0;
float(*deformedVerts)[3] = nullptr;
const int numVerts = mesh_temp->totvert;
float(*deformedVerts)[3] = reinterpret_cast<float(*)[3]>(
mesh_temp->vert_positions_for_write().data());
if (use_virtual_modifiers) {
VirtualModifierData virtual_modifier_data;
@ -799,31 +800,21 @@ static Mesh *create_applied_mesh_for_modifier(Depsgraph *depsgraph,
continue;
}
if (deformedVerts == nullptr) {
deformedVerts = BKE_mesh_vert_coords_alloc(me, &numVerts);
}
mti_virt->deform_verts(md_eval_virt, &mectx, mesh_temp, deformedVerts, numVerts);
}
}
Mesh *result = nullptr;
if (mti->type == eModifierTypeType_OnlyDeform) {
if (deformedVerts == nullptr) {
deformedVerts = BKE_mesh_vert_coords_alloc(me, &numVerts);
}
result = mesh_temp;
mti->deform_verts(md_eval, &mectx, result, deformedVerts, numVerts);
BKE_mesh_vert_coords_apply(result, deformedVerts);
BKE_mesh_tag_positions_changed(result);
if (build_shapekey_layers) {
add_shapekey_layers(*result, *me);
}
}
else {
if (deformedVerts != nullptr) {
BKE_mesh_vert_coords_apply(mesh_temp, deformedVerts);
}
if (build_shapekey_layers) {
add_shapekey_layers(*mesh_temp, *me);
}
@ -846,10 +837,6 @@ static Mesh *create_applied_mesh_for_modifier(Depsgraph *depsgraph,
}
}
if (deformedVerts != nullptr) {
MEM_freeN(deformedVerts);
}
return result;
}

View File

@ -3565,7 +3565,7 @@ bool ED_area_is_global(const ScrArea *area)
return area->global != nullptr;
}
ScrArea *ED_area_find_under_cursor(const bContext *C, int spacetype, const int xy[2])
ScrArea *ED_area_find_under_cursor(const bContext *C, int spacetype, const int event_xy[2])
{
bScreen *screen = CTX_wm_screen(C);
wmWindow *win = CTX_wm_window(C);
@ -3574,23 +3574,23 @@ ScrArea *ED_area_find_under_cursor(const bContext *C, int spacetype, const int x
if (win->parent) {
/* If active window is a child, check itself first. */
area = BKE_screen_find_area_xy(screen, spacetype, xy);
area = BKE_screen_find_area_xy(screen, spacetype, event_xy);
}
if (!area) {
/* Check all windows except the active one. */
int scr_pos[2];
wmWindow *win_other = WM_window_find_under_cursor(win, xy, scr_pos);
int event_xy_other[2];
wmWindow *win_other = WM_window_find_under_cursor(win, event_xy, event_xy_other);
if (win_other && win_other != win) {
win = win_other;
screen = WM_window_get_active_screen(win);
area = BKE_screen_find_area_xy(screen, spacetype, scr_pos);
area = BKE_screen_find_area_xy(screen, spacetype, event_xy_other);
}
}
if (!area && !win->parent) {
/* If active window is a parent window, check itself last. */
area = BKE_screen_find_area_xy(screen, spacetype, xy);
area = BKE_screen_find_area_xy(screen, spacetype, event_xy);
}
return area;

View File

@ -823,18 +823,19 @@ static bool azone_clipped_rect_calc(const AZone *az, rcti *r_rect_clip)
static void area_actionzone_get_rect(AZone *az, rcti *rect)
{
if (az->type == AZONE_REGION_SCROLL) {
const bool is_horizontal = az->direction == AZ_SCROLL_HOR;
const bool is_vertical = az->direction == AZ_SCROLL_VERT;
const bool is_right = is_vertical && bool(az->region->v2d.scroll & V2D_SCROLL_RIGHT);
const bool is_left = is_vertical && bool(az->region->v2d.scroll & V2D_SCROLL_LEFT);
const bool is_top = is_horizontal && bool(az->region->v2d.scroll & V2D_SCROLL_TOP);
const bool is_botton = is_horizontal && bool(az->region->v2d.scroll & V2D_SCROLL_BOTTOM);
/* For scroll azones use the area around the region's scroll-bar location. */
rcti scroller_vert = (az->direction == AZ_SCROLL_HOR) ? az->region->v2d.hor :
az->region->v2d.vert;
rcti scroller_vert = is_horizontal ? az->region->v2d.hor : az->region->v2d.vert;
BLI_rcti_translate(&scroller_vert, az->region->winrct.xmin, az->region->winrct.ymin);
rect->xmin = scroller_vert.xmin -
((az->direction == AZ_SCROLL_VERT) ? V2D_SCROLL_HIDE_HEIGHT : 0);
rect->ymin = scroller_vert.ymin -
((az->direction == AZ_SCROLL_HOR) ? V2D_SCROLL_HIDE_WIDTH : 0);
rect->xmax = scroller_vert.xmax +
((az->direction == AZ_SCROLL_VERT) ? V2D_SCROLL_HIDE_HEIGHT : 0);
rect->ymax = scroller_vert.ymax +
((az->direction == AZ_SCROLL_HOR) ? V2D_SCROLL_HIDE_WIDTH : 0);
rect->xmin = scroller_vert.xmin - (is_right ? V2D_SCROLL_HIDE_HEIGHT : 0);
rect->ymin = scroller_vert.ymin - (is_top ? V2D_SCROLL_HIDE_WIDTH : 0);
rect->xmax = scroller_vert.xmax + (is_left ? V2D_SCROLL_HIDE_HEIGHT : 0);
rect->ymax = scroller_vert.ymax + (is_botton ? V2D_SCROLL_HIDE_WIDTH : 0);
}
else {
azone_clipped_rect_calc(az, rect);

View File

@ -473,6 +473,8 @@ static void workspace_add_menu(bContext * /*C*/, uiLayout *layout, void *templat
WorkspaceConfigFileData *startup_config = workspace_config_file_read(app_template);
WorkspaceConfigFileData *builtin_config = workspace_system_file_read(app_template);
UI_block_flag_enable(uiLayoutGetBlock(layout), UI_BLOCK_IS_FLIP);
if (startup_config) {
LISTBASE_FOREACH (WorkSpace *, workspace, &startup_config->workspaces) {
uiLayout *row = uiLayoutRow(layout, false);

View File

@ -607,6 +607,11 @@ static void txt_write_file(Main *bmain, Text *text, ReportList *reports)
BLI_stat_t st;
char filepath[FILE_MAX];
if (text->filepath == nullptr) {
BKE_reportf(reports, RPT_ERROR, "No file path for \"%s\"", text->id.name + 2);
return;
}
STRNCPY(filepath, text->filepath);
BLI_path_abs(filepath, BKE_main_blendfile_path(bmain));

View File

@ -604,13 +604,31 @@ static void v3d_cursor_snap_update(V3DSnapCursorState *state,
V3DSnapCursorData *snap_data = &data_intern->snap_data;
ToolSettings *tool_settings = scene->toolsettings;
const bool use_surface_nor = tool_settings->plane_orient == V3D_PLACE_ORIENT_SURFACE;
const bool use_surface_co = tool_settings->plane_depth == V3D_PLACE_DEPTH_SURFACE;
eSnapMode snap_elements = v3d_cursor_snap_elements(tool_settings);
const bool calc_plane_omat = v3d_cursor_snap_calc_plane();
snap_data->is_enabled = true;
if (!(state->flag & V3D_SNAPCURSOR_TOGGLE_ALWAYS_TRUE)) {
#ifdef USE_SNAP_DETECT_FROM_KEYMAP_HACK
snap_data->is_snap_invert = v3d_cursor_is_snap_invert(data_intern, wm);
#endif
if (snap_data->is_snap_invert != !(tool_settings->snap_flag & SCE_SNAP)) {
snap_data->is_enabled = false;
if (!calc_plane_omat) {
snap_data->snap_elem = SCE_SNAP_TO_NONE;
return;
}
snap_elements = SCE_SNAP_TO_NONE;
}
}
const bool use_surface_nor = tool_settings->plane_orient == V3D_PLACE_ORIENT_SURFACE;
const bool use_surface_co = snap_data->is_enabled ||
tool_settings->plane_depth == V3D_PLACE_DEPTH_SURFACE;
float co[3], no[3], face_nor[3], obmat[4][4], omat[3][3];
eSnapMode snap_elem = SCE_SNAP_TO_NONE;
eSnapMode snap_elements = v3d_cursor_snap_elements(tool_settings);
int snap_elem_index[3] = {-1, -1, -1};
int index = -1;
@ -628,23 +646,6 @@ static void v3d_cursor_snap_update(V3DSnapCursorState *state,
snap_elements |= SCE_SNAP_TO_FACE;
}
snap_data->is_enabled = true;
#ifdef USE_SNAP_DETECT_FROM_KEYMAP_HACK
if (!(state->flag & V3D_SNAPCURSOR_TOGGLE_ALWAYS_TRUE)) {
snap_data->is_snap_invert = v3d_cursor_is_snap_invert(data_intern, wm);
const ToolSettings *ts = scene->toolsettings;
if (snap_data->is_snap_invert != !(ts->snap_flag & SCE_SNAP)) {
snap_data->is_enabled = false;
if (!calc_plane_omat) {
snap_data->snap_elem = SCE_SNAP_TO_NONE;
return;
}
snap_elements = data_intern->snap_elem_hidden = SCE_SNAP_TO_FACE;
}
}
#endif
if (snap_elements & SCE_SNAP_TO_GEOM) {
float prev_co[3] = {0.0f};
if (state->prevpoint) {

View File

@ -734,14 +734,11 @@ static void view3d_interactive_add_begin(bContext *C, wmOperator *op, const wmEv
/* Set this flag so snapping always updated. */
int mval[2];
WM_event_drag_start_mval(event, ipd->region, mval);
int flag_orig = snap_state_new->flag;
snap_state_new->flag |= V3D_SNAPCURSOR_TOGGLE_ALWAYS_TRUE;
/* Be sure to also compute the #V3DSnapCursorData.plane_omat. */
snap_state->draw_plane = true;
ED_view3d_cursor_snap_data_update(snap_state_new, C, mval[0], mval[1]);
snap_state_new->flag = eV3DSnapCursor(flag_orig);
}
}

View File

@ -240,6 +240,8 @@ static void gpencil_modifier_ops_extra_draw(bContext *C, uiLayout *layout, void
uiLayoutSetUnitsX(layout, 4.0f);
UI_block_flag_enable(uiLayoutGetBlock(layout), UI_BLOCK_IS_FLIP);
/* Apply. */
if (!(mti->flags & eGpencilModifierTypeFlag_NoApply)) {
uiItemO(layout,

View File

@ -470,7 +470,9 @@ inline size_t to_bytesize(eGPUTextureFormat format)
case GPU_DEPTH_COMPONENT32F:
return 32 / 8;
case GPU_DEPTH_COMPONENT24:
return 24 / 8;
/* Depth component 24 uses 3 bytes to store the depth value, and reserved 1 byte for
* alignment. */
return (24 + 8) / 8;
case GPU_DEPTH_COMPONENT16:
return 16 / 8;
}

View File

@ -71,7 +71,7 @@ class VKBuffer {
* VKIndexBuffer uses this when it is a subrange of another buffer.
*/
struct VKBufferWithOffset {
VKBuffer &buffer;
const VKBuffer &buffer;
VkDeviceSize offset;
};

View File

@ -58,9 +58,12 @@ VkImageAspectFlagBits to_vk_image_aspect_flag_bits(const eGPUTextureFormat forma
case GPU_DEPTH_COMPONENT32F:
case GPU_DEPTH_COMPONENT24:
case GPU_DEPTH_COMPONENT16:
return VK_IMAGE_ASPECT_DEPTH_BIT;
case GPU_DEPTH32F_STENCIL8:
case GPU_DEPTH24_STENCIL8:
return VK_IMAGE_ASPECT_DEPTH_BIT;
return static_cast<VkImageAspectFlagBits>(VK_IMAGE_ASPECT_DEPTH_BIT |
VK_IMAGE_ASPECT_STENCIL_BIT);
/* Texture only formats. */
case GPU_RGB32UI:
@ -583,6 +586,54 @@ VkFormat to_vk_format(const GPUVertCompType type, const uint32_t size, GPUVertFe
return VK_FORMAT_R32_SFLOAT;
}
VkFormat to_vk_format(const shader::Type type)
{
switch (type) {
case shader::Type::FLOAT:
return VK_FORMAT_R32_SFLOAT;
case shader::Type::VEC2:
return VK_FORMAT_R32G32_SFLOAT;
case shader::Type::VEC3:
return VK_FORMAT_R32G32B32_SFLOAT;
case shader::Type::VEC4:
return VK_FORMAT_R32G32B32A32_SFLOAT;
case shader::Type::UINT:
return VK_FORMAT_R32_UINT;
case shader::Type::UVEC2:
return VK_FORMAT_R32G32_UINT;
case shader::Type::UVEC3:
return VK_FORMAT_R32G32B32_UINT;
case shader::Type::UVEC4:
return VK_FORMAT_R32G32B32A32_UINT;
case shader::Type::INT:
return VK_FORMAT_R32_SINT;
case shader::Type::IVEC2:
return VK_FORMAT_R32G32_SINT;
case shader::Type::IVEC3:
return VK_FORMAT_R32G32B32_SINT;
case shader::Type::IVEC4:
return VK_FORMAT_R32G32B32A32_SINT;
case shader::Type::MAT4:
return VK_FORMAT_R32G32B32A32_SFLOAT;
case shader::Type::MAT3:
case shader::Type::BOOL:
case shader::Type::VEC3_101010I2:
case shader::Type::UCHAR:
case shader::Type::UCHAR2:
case shader::Type::UCHAR3:
case shader::Type::UCHAR4:
case shader::Type::CHAR:
case shader::Type::CHAR2:
case shader::Type::CHAR3:
case shader::Type::CHAR4:
break;
}
BLI_assert_unreachable();
return VK_FORMAT_R32G32B32A32_SFLOAT;
}
VkImageType to_vk_image_type(const eGPUTextureType type)
{
/* See

View File

@ -19,6 +19,7 @@
#include "vk_mem_alloc.h"
#include "gpu_index_buffer_private.hh"
#include "gpu_shader_create_info.hh"
#include "gpu_texture_private.hh"
namespace blender::gpu {
@ -42,6 +43,8 @@ VkFormat to_vk_format(const eGPUTextureFormat format);
VkFormat to_vk_format(const GPUVertCompType type,
const uint32_t size,
const GPUVertFetchMode fetch_mode);
VkFormat to_vk_format(const shader::Type type);
VkComponentMapping to_vk_component_mapping(const eGPUTextureFormat format);
VkImageViewType to_vk_image_view_type(const eGPUTextureType type, eImageViewUsage view_type);
VkImageType to_vk_image_type(const eGPUTextureType type);

View File

@ -78,6 +78,7 @@ void VKContext::sync_backbuffer()
command_buffer_.init(device.device_get(), device.queue_get(), command_buffer);
command_buffer_.begin_recording();
device.descriptor_pools_get().reset();
device.init_dummy_buffer(*this);
}
}

View File

@ -15,12 +15,15 @@
#include "vk_texture.hh"
#include "vk_vertex_buffer.hh"
#include "BLI_math_matrix_types.hh"
#include "GHOST_C-api.h"
namespace blender::gpu {
void VKDevice::deinit()
{
dummy_buffer_.free();
sampler_.free();
vmaDestroyAllocator(mem_allocator_);
mem_allocator_ = VK_NULL_HANDLE;
@ -90,6 +93,16 @@ void VKDevice::init_descriptor_pools()
descriptor_pools_.init(vk_device_);
}
void VKDevice::init_dummy_buffer(VKContext &context)
{
if (dummy_buffer_.is_allocated()) {
return;
}
dummy_buffer_.create(sizeof(float4x4), GPU_USAGE_DEVICE_ONLY, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT);
dummy_buffer_.clear(context, 0);
}
/* -------------------------------------------------------------------- */
/** \name Platform/driver/device information
* \{ */

View File

@ -11,6 +11,7 @@
#include "BLI_utility_mixins.hh"
#include "BLI_vector.hh"
#include "vk_buffer.hh"
#include "vk_common.hh"
#include "vk_debug.hh"
#include "vk_descriptor_pools.hh"
@ -65,6 +66,9 @@ class VKDevice : public NonCopyable {
/* Workarounds */
VKWorkarounds workarounds_;
/** Buffer to bind to unbound resource locations. */
VKBuffer dummy_buffer_;
public:
VkPhysicalDevice physical_device_get() const
{
@ -123,6 +127,12 @@ class VKDevice : public NonCopyable {
bool is_initialized() const;
void init(void *ghost_context);
/**
* Initialize a dummy buffer that can be bound for missing attributes.
*
* Dummy buffer can only be initialized after the command buffer of the context is retrieved.
*/
void init_dummy_buffer(VKContext &context);
void deinit();
eGPUDeviceType device_type() const;
@ -143,6 +153,11 @@ class VKDevice : public NonCopyable {
void context_unregister(VKContext &context);
const Vector<std::reference_wrapper<VKContext>> &contexts_get() const;
const VKBuffer &dummy_buffer_get() const
{
return dummy_buffer_;
}
/** \} */
private:

View File

@ -405,7 +405,11 @@ void VKFrameBuffer::render_pass_create()
/* Ensure texture is allocated to ensure the image view. */
VKTexture &texture = *static_cast<VKTexture *>(unwrap(attachment.tex));
texture.ensure_allocated();
image_views_.append(VKImageView(texture, attachment.layer, attachment.mip, name_));
image_views_.append(VKImageView(texture,
eImageViewUsage::Attachment,
IndexRange(max_ii(attachment.layer, 0), 1),
IndexRange(attachment.mip, 1),
name_));
image_views[attachment_location] = image_views_.last().vk_handle();
VkAttachmentDescription &attachment_description =

View File

@ -15,15 +15,34 @@
namespace blender::gpu {
VKImageView::VKImageView(VKTexture &texture, int layer, int mip_level, StringRefNull name)
: vk_image_view_(create_vk_image_view(texture, layer, mip_level, name))
VKImageView::VKImageView(VKTexture &texture,
eImageViewUsage usage,
IndexRange layer_range,
IndexRange mip_range,
StringRefNull name)
{
BLI_assert(vk_image_view_ != VK_NULL_HANDLE);
}
const VkImageAspectFlagBits allowed_bits = static_cast<VkImageAspectFlagBits>(
VK_IMAGE_ASPECT_COLOR_BIT | VK_IMAGE_ASPECT_DEPTH_BIT);
VkImageAspectFlagBits image_aspect = static_cast<VkImageAspectFlagBits>(
(to_vk_image_aspect_flag_bits(texture.format_get()) & allowed_bits));
VKImageView::VKImageView(VkImageView vk_image_view) : vk_image_view_(vk_image_view)
{
BLI_assert(vk_image_view_ != VK_NULL_HANDLE);
VK_ALLOCATION_CALLBACKS
VkImageViewCreateInfo image_view_info = {};
image_view_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
image_view_info.image = texture.vk_image_handle();
image_view_info.viewType = to_vk_image_view_type(texture.type_get(), usage);
image_view_info.format = to_vk_format(texture.format_get());
image_view_info.components = to_vk_component_mapping(texture.format_get());
image_view_info.subresourceRange.aspectMask = image_aspect;
image_view_info.subresourceRange.baseMipLevel = mip_range.first();
image_view_info.subresourceRange.levelCount = mip_range.size();
image_view_info.subresourceRange.baseArrayLayer = layer_range.first();
image_view_info.subresourceRange.layerCount = layer_range.size();
const VKDevice &device = VKBackend::get().device_get();
vkCreateImageView(
device.device_get(), &image_view_info, vk_allocation_callbacks, &vk_image_view_);
debug::object_label(vk_image_view_, name.c_str());
}
VKImageView::VKImageView(VKImageView &&other)
@ -40,31 +59,5 @@ VKImageView::~VKImageView()
vkDestroyImageView(device.device_get(), vk_image_view_, vk_allocation_callbacks);
}
}
VkImageView VKImageView::create_vk_image_view(VKTexture &texture,
int layer,
int mip_level,
StringRefNull name)
{
VK_ALLOCATION_CALLBACKS
VkImageViewCreateInfo image_view_info = {};
image_view_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
image_view_info.image = texture.vk_image_handle();
image_view_info.viewType = to_vk_image_view_type(texture.type_get(),
eImageViewUsage::Attachment);
image_view_info.format = to_vk_format(texture.format_get());
image_view_info.components = to_vk_component_mapping(texture.format_get());
image_view_info.subresourceRange.aspectMask = to_vk_image_aspect_flag_bits(texture.format_get());
image_view_info.subresourceRange.baseMipLevel = mip_level;
image_view_info.subresourceRange.levelCount = 1;
image_view_info.subresourceRange.baseArrayLayer = layer == -1 ? 0 : layer;
image_view_info.subresourceRange.layerCount = 1;
const VKDevice &device = VKBackend::get().device_get();
VkImageView image_view = VK_NULL_HANDLE;
vkCreateImageView(device.device_get(), &image_view_info, vk_allocation_callbacks, &image_view);
debug::object_label(image_view, name.c_str());
return image_view;
}
} // namespace blender::gpu

View File

@ -20,13 +20,11 @@ class VKImageView : NonCopyable {
VkImageView vk_image_view_ = VK_NULL_HANDLE;
public:
VKImageView(VKTexture &texture, int layer, int mip_level, StringRefNull name);
/**
* Wrap the given vk_image_view handle. Note that the vk_image_view handle ownership is
* transferred to VKImageView.
*/
VKImageView(VkImageView vk_image_view);
VKImageView(VKTexture &texture,
eImageViewUsage usage,
IndexRange layer_range,
IndexRange mip_range,
StringRefNull name);
VKImageView(VKImageView &&other);
~VKImageView();
@ -36,12 +34,6 @@ class VKImageView : NonCopyable {
BLI_assert(vk_image_view_ != VK_NULL_HANDLE);
return vk_image_view_;
}
private:
static VkImageView create_vk_image_view(VKTexture &texture,
int layer,
int mip_level,
StringRefNull name);
};
} // namespace blender::gpu

View File

@ -573,7 +573,10 @@ void VKShader::build_shader_module(Span<uint32_t> spirv_module, VkShaderModule *
const VKDevice &device = VKBackend::get().device_get();
VkResult result = vkCreateShaderModule(
device.device_get(), &create_info, vk_allocation_callbacks, r_shader_module);
if (result != VK_SUCCESS) {
if (result == VK_SUCCESS) {
debug::object_label(*r_shader_module, name);
}
else {
compilation_failed_ = true;
*r_shader_module = VK_NULL_HANDLE;
}

View File

@ -48,6 +48,11 @@ class VKShaderInterface : public ShaderInterface {
return push_constants_layout_;
}
shader::Type get_attribute_type(int location) const
{
return static_cast<shader::Type>(attr_types_[location]);
}
private:
/**
* Retrieve the shader input for the given resource.

View File

@ -543,25 +543,11 @@ void VKTexture::image_view_ensure()
void VKTexture::image_view_update()
{
VK_ALLOCATION_CALLBACKS
VkImageViewCreateInfo image_view_info = {};
image_view_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
image_view_info.image = vk_image_;
image_view_info.viewType = to_vk_image_view_type(type_, eImageViewUsage::ShaderBinding);
image_view_info.format = to_vk_format(format_);
image_view_info.components = to_vk_component_mapping(format_);
image_view_info.subresourceRange.aspectMask = to_vk_image_aspect_flag_bits(format_);
IndexRange mip_range = mip_map_range();
image_view_info.subresourceRange.baseMipLevel = mip_range.first();
image_view_info.subresourceRange.levelCount = mip_range.size();
image_view_info.subresourceRange.layerCount =
ELEM(type_, GPU_TEXTURE_CUBE, GPU_TEXTURE_CUBE_ARRAY) ? d_ : VK_REMAINING_ARRAY_LAYERS;
const VKDevice &device = VKBackend::get().device_get();
VkImageView image_view = VK_NULL_HANDLE;
vkCreateImageView(device.device_get(), &image_view_info, vk_allocation_callbacks, &image_view);
debug::object_label(image_view, name_);
image_view_.emplace(image_view);
IndexRange layer_range(
0, ELEM(type_, GPU_TEXTURE_CUBE, GPU_TEXTURE_CUBE_ARRAY) ? d_ : VK_REMAINING_ARRAY_LAYERS);
image_view_.emplace(
VKImageView(*this, eImageViewUsage::ShaderBinding, layer_range, mip_range, name_));
}
IndexRange VKTexture::mip_map_range() const

View File

@ -12,6 +12,7 @@
#include "vk_vertex_buffer.hh"
#include "BLI_array.hh"
#include "BLI_math_vector_types.hh"
namespace blender::gpu {
VKVertexAttributeObject::VKVertexAttributeObject()
@ -48,8 +49,24 @@ VKVertexAttributeObject &VKVertexAttributeObject::operator=(const VKVertexAttrib
return *this;
}
/* -------------------------------------------------------------------- */
/** \name Bind resources
* \{ */
void VKVertexAttributeObject::bind(VKContext &context)
{
const bool use_vbos = !vbos.is_empty();
if (use_vbos) {
bind_vbos(context);
}
else {
bind_buffers(context);
}
}
void VKVertexAttributeObject::bind_vbos(VKContext &context)
{
/* Bind VBOS from batches. */
Array<bool> visited_bindings(bindings.size());
visited_bindings.fill(false);
@ -59,22 +76,50 @@ void VKVertexAttributeObject::bind(VKContext &context)
}
visited_bindings[attribute.binding] = true;
/* Bind VBOS from batches. */
if (attribute.binding < vbos.size()) {
BLI_assert(vbos[attribute.binding]);
VKVertexBuffer &vbo = *vbos[attribute.binding];
vbo.upload();
context.command_buffer_get().bind(attribute.binding, vbo, 0);
}
else {
const VKBuffer &buffer = VKBackend::get().device_get().dummy_buffer_get();
const VKBufferWithOffset buffer_with_offset = {buffer, 0};
context.command_buffer_get().bind(attribute.binding, buffer_with_offset);
}
}
}
void VKVertexAttributeObject::bind_buffers(VKContext &context)
{
/* Bind dynamic buffers from immediate mode. */
Array<bool> visited_bindings(bindings.size());
visited_bindings.fill(false);
for (VkVertexInputAttributeDescription attribute : attributes) {
if (visited_bindings[attribute.binding]) {
continue;
}
visited_bindings[attribute.binding] = true;
/* Bind dynamic buffers from immediate mode. */
if (attribute.binding < buffers.size()) {
VKBufferWithOffset &buffer = buffers[attribute.binding];
context.command_buffer_get().bind(attribute.binding, buffer);
}
else {
const VKBuffer &buffer = VKBackend::get().device_get().dummy_buffer_get();
const VKBufferWithOffset buffer_with_offset = {buffer, 0};
context.command_buffer_get().bind(attribute.binding, buffer_with_offset);
}
}
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Update bindings
* \{ */
void VKVertexAttributeObject::update_bindings(const VKContext &context, VKBatch &batch)
{
clear();
@ -96,9 +141,89 @@ void VKVertexAttributeObject::update_bindings(const VKContext &context, VKBatch
}
}
if (occupied_attributes != interface.enabled_attr_mask_) {
fill_unused_bindings(interface, occupied_attributes);
}
is_valid = true;
}
/* Determine the number of binding location the given attribute uses. */
static uint32_t to_binding_location_len(const GPUVertAttr &attribute)
{
return ceil_division(attribute.comp_len, 4u);
}
/* Determine the number of binding location the given type uses. */
static uint32_t to_binding_location_len(const shader::Type type)
{
switch (type) {
case shader::Type::FLOAT:
case shader::Type::VEC2:
case shader::Type::VEC3:
case shader::Type::VEC4:
case shader::Type::UINT:
case shader::Type::UVEC2:
case shader::Type::UVEC3:
case shader::Type::UVEC4:
case shader::Type::INT:
case shader::Type::IVEC2:
case shader::Type::IVEC3:
case shader::Type::IVEC4:
case shader::Type::BOOL:
case shader::Type::VEC3_101010I2:
case shader::Type::UCHAR:
case shader::Type::UCHAR2:
case shader::Type::UCHAR3:
case shader::Type::UCHAR4:
case shader::Type::CHAR:
case shader::Type::CHAR2:
case shader::Type::CHAR3:
case shader::Type::CHAR4:
return 1;
case shader::Type::MAT3:
return 3;
case shader::Type::MAT4:
return 4;
}
return 1;
}
void VKVertexAttributeObject::fill_unused_bindings(const VKShaderInterface &interface,
const AttributeMask occupied_attributes)
{
for (int location : IndexRange(16)) {
AttributeMask location_mask = 1 << location;
/* Skip occupied slots */
if (occupied_attributes & location_mask) {
continue;
}
/* Skip slots that are not used by the vertex shader. */
if ((interface.enabled_attr_mask_ & location_mask) == 0) {
continue;
}
/* Use dummy binding...*/
shader::Type attribute_type = interface.get_attribute_type(location);
const uint32_t num_locations = to_binding_location_len(attribute_type);
for (const uint32_t location_offset : IndexRange(num_locations)) {
const uint32_t binding = bindings.size();
VkVertexInputAttributeDescription attribute_description = {};
attribute_description.binding = binding;
attribute_description.location = location + location_offset;
attribute_description.offset = 0;
attribute_description.format = to_vk_format(attribute_type);
attributes.append(attribute_description);
VkVertexInputBindingDescription vk_binding_descriptor = {};
vk_binding_descriptor.binding = binding;
vk_binding_descriptor.stride = 0;
vk_binding_descriptor.inputRate = VK_VERTEX_INPUT_RATE_INSTANCE;
bindings.append(vk_binding_descriptor);
}
}
}
void VKVertexAttributeObject::update_bindings(VKImmediate &immediate)
{
clear();
@ -148,9 +273,6 @@ void VKVertexAttributeObject::update_bindings(const GPUVertFormat &vertex_format
offset = attribute.offset;
}
const uint32_t binding = bindings.size();
bool attribute_used_by_shader = false;
for (uint32_t name_index = 0; name_index < attribute.name_len; name_index++) {
const char *name = GPU_vertformat_attr_name_get(&vertex_format, &attribute, name_index);
const ShaderInput *shader_input = interface.attr_get(name);
@ -164,34 +286,78 @@ void VKVertexAttributeObject::update_bindings(const GPUVertFormat &vertex_format
continue;
}
r_occupied_attributes |= attribute_mask;
attribute_used_by_shader = true;
const uint32_t num_locations = to_binding_location_len(attribute);
for (const uint32_t location_offset : IndexRange(num_locations)) {
const uint32_t binding = bindings.size();
VkVertexInputAttributeDescription attribute_description = {};
attribute_description.binding = binding;
attribute_description.location = shader_input->location + location_offset;
attribute_description.offset = offset + location_offset * sizeof(float4);
attribute_description.format = to_vk_format(
static_cast<GPUVertCompType>(attribute.comp_type),
attribute.size,
static_cast<GPUVertFetchMode>(attribute.fetch_mode));
attributes.append(attribute_description);
VkVertexInputAttributeDescription attribute_description = {};
attribute_description.binding = binding;
attribute_description.location = shader_input->location;
attribute_description.offset = offset;
attribute_description.format = to_vk_format(
static_cast<GPUVertCompType>(attribute.comp_type),
attribute.size,
static_cast<GPUVertFetchMode>(attribute.fetch_mode));
attributes.append(attribute_description);
}
if (attribute_used_by_shader) {
VkVertexInputBindingDescription vk_binding_descriptor = {};
vk_binding_descriptor.binding = binding;
vk_binding_descriptor.stride = stride;
vk_binding_descriptor.inputRate = use_instancing ? VK_VERTEX_INPUT_RATE_INSTANCE :
VK_VERTEX_INPUT_RATE_VERTEX;
bindings.append(vk_binding_descriptor);
if (vertex_buffer) {
vbos.append(vertex_buffer);
}
if (immediate_vertex_buffer) {
buffers.append(*immediate_vertex_buffer);
VkVertexInputBindingDescription vk_binding_descriptor = {};
vk_binding_descriptor.binding = binding;
vk_binding_descriptor.stride = stride;
vk_binding_descriptor.inputRate = use_instancing ? VK_VERTEX_INPUT_RATE_INSTANCE :
VK_VERTEX_INPUT_RATE_VERTEX;
bindings.append(vk_binding_descriptor);
if (vertex_buffer) {
vbos.append(vertex_buffer);
}
if (immediate_vertex_buffer) {
buffers.append(*immediate_vertex_buffer);
}
}
}
}
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Debugging
* \{ */
void VKVertexAttributeObject::debug_print() const
{
std::cout << __FILE__ << "::" << __func__ << "\n";
Array<bool> visited_bindings(bindings.size());
visited_bindings.fill(false);
for (VkVertexInputAttributeDescription attribute : attributes) {
std::cout << " - attribute(binding=" << attribute.binding
<< ", location=" << attribute.location << ")";
if (visited_bindings[attribute.binding]) {
std::cout << " WARNING: Already bound\n";
continue;
}
visited_bindings[attribute.binding] = true;
/* Bind VBOS from batches. */
if (!vbos.is_empty()) {
if (attribute.binding < vbos.size()) {
std::cout << " Attach to VBO [" << vbos[attribute.binding] << "]\n";
}
else {
std::cout << " WARNING: Attach to dummy\n";
}
}
else if (!buffers.is_empty()) {
if (attribute.binding < vbos.size()) {
std::cout << " Attach to ImmediateModeVBO\n";
}
else {
std::cout << " WARNING: Attach to dummy\n";
}
}
}
}
/** \} */
} // namespace blender::gpu

View File

@ -47,7 +47,12 @@ class VKVertexAttributeObject {
void update_bindings(const VKContext &context, VKBatch &batch);
void update_bindings(VKImmediate &immediate);
void debug_print() const;
private:
/** Update unused bindings with a dummy binding. */
void fill_unused_bindings(const VKShaderInterface &interface,
const AttributeMask occupied_attributes);
void update_bindings(const GPUVertFormat &vertex_format,
VKVertexBuffer *vertex_buffer,
VKBufferWithOffset *immediate_vertex_buffer,
@ -55,6 +60,9 @@ class VKVertexAttributeObject {
const VKShaderInterface &interface,
AttributeMask &r_occupied_attributes,
const bool use_instancing);
void bind_vbos(VKContext &context);
void bind_buffers(VKContext &context);
};
} // namespace blender::gpu

View File

@ -41,6 +41,20 @@
.ortho_scale = 6.0, \
.flag = CAM_SHOWPASSEPARTOUT, \
.passepartalpha = 0.5f, \
\
.panorama_type = CAM_PANORAMA_FISHEYE_EQUISOLID,\
.fisheye_fov = M_PI,\
.fisheye_lens = 10.5f,\
.latitude_min = -0.5f * (float)M_PI,\
.latitude_max = 0.5f * (float)M_PI,\
.longitude_min = -M_PI,\
.longitude_max = M_PI,\
/* Fit to match default projective camera with focal_length 50 and sensor_width 36. */ \
.fisheye_polynomial_k0 = -1.1735143712967577e-05f,\
.fisheye_polynomial_k1 = -0.019988736953434998f,\
.fisheye_polynomial_k2 = -3.3525322965709175e-06f,\
.fisheye_polynomial_k3 = 3.099275275886036e-06f,\
.fisheye_polynomial_k4 = -2.6064646454854524e-08f,\
\
.dof = _DNA_DEFAULT_CameraDOFSettings, \
\

View File

@ -91,6 +91,21 @@ typedef struct Camera {
float shiftx, shifty;
float dof_distance DNA_DEPRECATED;
char sensor_fit;
char panorama_type;
char _pad[2];
/** Fisheye properties. */
float fisheye_fov;
float fisheye_lens;
float latitude_min, latitude_max;
float longitude_min, longitude_max;
float fisheye_polynomial_k0;
float fisheye_polynomial_k1;
float fisheye_polynomial_k2;
float fisheye_polynomial_k3;
float fisheye_polynomial_k4;
/** Old animation system, deprecated for 2.5. */
struct Ipo *ipo DNA_DEPRECATED;
@ -101,9 +116,6 @@ typedef struct Camera {
/* CameraBGImage reference images */
struct ListBase bg_images;
char sensor_fit;
char _pad[7];
/* Stereo settings */
struct CameraStereoSettings stereo;
@ -120,6 +132,16 @@ enum {
CAM_PANO = 2,
};
/* panorama_type */
enum {
CAM_PANORAMA_EQUIRECTANGULAR = 0,
CAM_PANORAMA_FISHEYE_EQUIDISTANT = 1,
CAM_PANORAMA_FISHEYE_EQUISOLID = 2,
CAM_PANORAMA_MIRRORBALL = 3,
CAM_PANORAMA_FISHEYE_LENS_POLYNOMIAL = 4,
CAM_PANORAMA_EQUIANGULAR_CUBEMAP_FACE = 5,
};
/* dtx */
enum {
CAM_DTX_CENTER = (1 << 0),

View File

@ -218,7 +218,7 @@ typedef struct ClothCollSettings {
float selfepsilon;
float repel_force DNA_DEPRECATED;
float distance_repel DNA_DEPRECATED;
/** Collision flags defined in BKE_cloth.h. */
/** Collision flags defined in BKE_cloth.hh. */
int flags;
/** How many iterations for the selfcollision loop. */
short self_loop_count DNA_DEPRECATED;

View File

@ -593,6 +593,41 @@ void RNA_def_camera(BlenderRNA *brna)
{0, nullptr, 0, nullptr, nullptr},
};
static const EnumPropertyItem panorama_type_items[] = {
{CAM_PANORAMA_EQUIRECTANGULAR,
"EQUIRECTANGULAR",
0,
"Equirectangular",
"Spherical camera for environment maps, also known as Lat Long panorama"},
{CAM_PANORAMA_EQUIANGULAR_CUBEMAP_FACE,
"EQUIANGULAR_CUBEMAP_FACE",
0,
"Equiangular Cubemap Face",
"Single face of an equiangular cubemap"},
{CAM_PANORAMA_MIRRORBALL,
"MIRRORBALL",
0,
"Mirror Ball",
"Mirror ball mapping for environment maps"},
{CAM_PANORAMA_FISHEYE_EQUIDISTANT,
"FISHEYE_EQUIDISTANT",
0,
"Fisheye Equidistant",
"Ideal for fulldomes, ignore the sensor dimensions"},
{CAM_PANORAMA_FISHEYE_EQUISOLID,
"FISHEYE_EQUISOLID",
0,
"Fisheye Equisolid",
"Similar to most fisheye modern lens, takes sensor dimensions into consideration"},
{CAM_PANORAMA_FISHEYE_LENS_POLYNOMIAL,
"FISHEYE_LENS_POLYNOMIAL",
0,
"Fisheye Lens Polynomial",
"Defines the lens projection as polynomial to allow real world camera lenses to be "
"mimicked"},
{0, nullptr, 0, nullptr, nullptr},
};
srna = RNA_def_struct(brna, "Camera", "ID");
RNA_def_struct_ui_text(srna, "Camera", "Camera data-block for storing camera settings");
RNA_def_struct_ui_icon(srna, ICON_CAMERA_DATA);
@ -817,6 +852,75 @@ void RNA_def_camera(BlenderRNA *brna)
prop, "Harmonious Triangle B", "Display harmony B composition guide inside the camera view");
RNA_def_property_update(prop, NC_CAMERA | ND_DRAW_RENDER_VIEWPORT, nullptr);
/* Panoramic settings. */
prop = RNA_def_property(srna, "panorama_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, panorama_type_items);
RNA_def_property_ui_text(prop, "Panorama Type", "Distortion to use for the calculation");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
prop = RNA_def_property(srna, "fisheye_fov", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_range(prop, 0.1745, 10.0 * M_PI);
RNA_def_property_ui_range(prop, 0.1745, 2.0 * M_PI, 3, 2);
RNA_def_property_ui_text(prop, "Field of View", "Field of view for the fisheye lens");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
prop = RNA_def_property(srna, "fisheye_lens", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, 0.01, 100.0);
RNA_def_property_ui_range(prop, 0.01, 15.0, 3, 2);
RNA_def_property_ui_text(prop, "Fisheye Lens", "Lens focal length (mm)");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
prop = RNA_def_property(srna, "latitude_min", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_range(prop, -0.5 * M_PI, 0.5 * M_PI);
RNA_def_property_ui_range(prop, -0.5 * M_PI, 0.5 * M_PI, 3, 2);
RNA_def_property_ui_text(
prop, "Min Latitude", "Minimum latitude (vertical angle) for the equirectangular lens");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
prop = RNA_def_property(srna, "latitude_max", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_range(prop, -0.5 * M_PI, 0.5 * M_PI);
RNA_def_property_ui_range(prop, -0.5 * M_PI, 0.5 * M_PI, 3, 2);
RNA_def_property_ui_text(
prop, "Max Latitude", "Maximum latitude (vertical angle) for the equirectangular lens");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
prop = RNA_def_property(srna, "longitude_min", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_ui_range(prop, -M_PI, M_PI, 3, 2);
RNA_def_property_ui_text(
prop, "Min Longitude", "Minimum longitude (horizontal angle) for the equirectangular lens");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
prop = RNA_def_property(srna, "longitude_max", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_ui_range(prop, -M_PI, M_PI, 3, 2);
RNA_def_property_ui_text(
prop, "Max Longitude", "Maximum longitude (horizontal angle) for the equirectangular lens");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
prop = RNA_def_property(srna, "fisheye_polynomial_k0", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 0.1, 6);
RNA_def_property_ui_text(prop, "Fisheye Polynomial K0", "Coefficient K0 of the lens polynomial");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
prop = RNA_def_property(srna, "fisheye_polynomial_k1", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 0.1, 6);
RNA_def_property_ui_text(prop, "Fisheye Polynomial K1", "Coefficient K1 of the lens polynomial");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
prop = RNA_def_property(srna, "fisheye_polynomial_k2", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 0.1, 6);
RNA_def_property_ui_text(prop, "Fisheye Polynomial K2", "Coefficient K2 of the lens polynomial");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
prop = RNA_def_property(srna, "fisheye_polynomial_k3", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 0.1, 6);
RNA_def_property_ui_text(prop, "Fisheye Polynomial K3", "Coefficient K3 of the lens polynomial");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
prop = RNA_def_property(srna, "fisheye_polynomial_k4", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 0.1, 6);
RNA_def_property_ui_text(prop, "Fisheye Polynomial K4", "Coefficient K4 of the lens polynomial");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
/* pointers */
prop = RNA_def_property(srna, "dof", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "CameraDOFSettings");

View File

@ -17,7 +17,7 @@
#include "rna_internal.h"
#include "BKE_cloth.h"
#include "BKE_cloth.hh"
#include "BKE_modifier.h"
#include "SIM_mass_spring.h"

View File

@ -139,7 +139,7 @@ static const EnumPropertyItem part_fluid_type_items[] = {
# include "BLI_string_utils.h"
# include "BKE_boids.h"
# include "BKE_cloth.h"
# include "BKE_cloth.hh"
# include "BKE_colortools.h"
# include "BKE_context.h"
# include "BKE_deform.h"

View File

@ -125,9 +125,12 @@ static char *rna_path_token_in_brackets(const char **path,
return nullptr;
}
/* Empty, return. */
if (UNLIKELY(len == 0)) {
return nullptr;
/* Support empty strings in quotes, as this is a valid key for an ID-property. */
if (!quoted) {
/* Empty, return. */
if (UNLIKELY(len == 0)) {
return nullptr;
}
}
/* Try to use fixed buffer if possible. */

View File

@ -25,7 +25,7 @@
#include "MEM_guardedalloc.h"
#include "BKE_cloth.h"
#include "BKE_cloth.hh"
#include "BKE_context.h"
#include "BKE_effect.h"
#include "BKE_global.h"

View File

@ -206,6 +206,8 @@ static void modifier_ops_extra_draw(bContext *C, uiLayout *layout, void *md_v)
uiLayoutSetUnitsX(layout, 4.0f);
UI_block_flag_enable(uiLayoutGetBlock(layout), UI_BLOCK_IS_FLIP);
/* Apply. */
uiItemO(layout,
CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Apply"),

View File

@ -98,8 +98,6 @@ static Mesh *uvprojectModifier_do(UVProjectModifierData *umd,
Mesh *mesh)
{
using namespace blender;
float(*coords)[3], (*co)[3];
int i, verts_num;
Projector projectors[MOD_UVPROJECT_MAXPROJECTORS];
int projectors_num = 0;
char uvname[MAX_CUSTOMDATA_LAYER_NAME];
@ -109,7 +107,7 @@ static Mesh *uvprojectModifier_do(UVProjectModifierData *umd,
float scay = umd->scaley ? umd->scaley : 1.0f;
int free_uci = 0;
for (i = 0; i < umd->projectors_num; i++) {
for (int i = 0; i < umd->projectors_num; i++) {
if (umd->projectors[i] != nullptr) {
projectors[projectors_num++].ob = umd->projectors[i];
}
@ -128,7 +126,7 @@ static Mesh *uvprojectModifier_do(UVProjectModifierData *umd,
CustomData_validate_layer_name(&mesh->loop_data, CD_PROP_FLOAT2, umd->uvlayer_name, uvname);
/* calculate a projection matrix and normal for each projector */
for (i = 0; i < projectors_num; i++) {
for (int i = 0; i < projectors_num; i++) {
float tmpmat[4][4];
float offsetmat[4][4];
Camera *cam = nullptr;
@ -182,30 +180,30 @@ static Mesh *uvprojectModifier_do(UVProjectModifierData *umd,
mul_mat3_m4_v3(projectors[i].ob->object_to_world, projectors[i].normal);
}
const blender::Span<blender::float3> positions = mesh->vert_positions();
const blender::OffsetIndices faces = mesh->faces();
const Span<float3> positions = mesh->vert_positions();
const OffsetIndices faces = mesh->faces();
const Span<int> corner_verts = mesh->corner_verts();
float(*mloop_uv)[2] = static_cast<float(*)[2]>(CustomData_get_layer_named_for_write(
&mesh->loop_data, CD_PROP_FLOAT2, uvname, corner_verts.size()));
coords = BKE_mesh_vert_coords_alloc(mesh, &verts_num);
Array<float3> coords(positions.size());
/* Convert coords to world-space. */
for (i = 0, co = coords; i < verts_num; i++, co++) {
mul_m4_v3(ob->object_to_world, *co);
for (int64_t i = 0; i < positions.size(); i++) {
mul_v3_m4v3(coords[i], ob->object_to_world, positions[i]);
}
/* if only one projector, project coords to UVs */
if (projectors_num == 1 && projectors[0].uci == nullptr) {
for (i = 0, co = coords; i < verts_num; i++, co++) {
mul_project_m4_v3(projectors[0].projmat, *co);
for (int64_t i = 0; i < coords.size(); i++) {
mul_project_m4_v3(projectors[0].projmat, coords[i]);
}
}
/* apply coords as UVs */
for (const int i : faces.index_range()) {
const blender::IndexRange face = faces[i];
const IndexRange face = faces[i];
if (projectors_num == 1) {
if (projectors[0].uci) {
for (const int corner : face) {
@ -229,8 +227,8 @@ static Mesh *uvprojectModifier_do(UVProjectModifierData *umd,
float best_dot;
/* get the untransformed face normal */
const blender::float3 face_no = blender::bke::mesh::face_normal_calc(
positions, corner_verts.slice(face));
const float3 face_no = blender::bke::mesh::face_normal_calc(positions,
corner_verts.slice(face));
/* find the projector which the face points at most directly
* (projector normal with largest dot product is best)
@ -262,8 +260,6 @@ static Mesh *uvprojectModifier_do(UVProjectModifierData *umd,
}
}
MEM_freeN(coords);
if (free_uci) {
int j;
for (j = 0; j < projectors_num; j++) {

View File

@ -35,32 +35,32 @@ static void node_declare(NodeDeclarationBuilder &b)
.translation_context(BLT_I18NCONTEXT_ID_ID)
.supported_type(GeometryComponent::Type::Volume);
std::string grid_socket_description =
"Expects a Named Attribute with the name of a Grid in the Volume";
std::string grid_socket_description = N_(
"Expects a Named Attribute with the name of a Grid in the Volume");
b.add_input<decl::Vector>(("Grid"), "Grid_Vector")
b.add_input<decl::Vector>("Grid", "Grid_Vector")
.field_on_all()
.hide_value()
.description(grid_socket_description);
b.add_input<decl::Float>(("Grid"), "Grid_Float")
b.add_input<decl::Float>("Grid", "Grid_Float")
.field_on_all()
.hide_value()
.description(grid_socket_description);
b.add_input<decl::Bool>(("Grid"), "Grid_Bool")
b.add_input<decl::Bool>("Grid", "Grid_Bool")
.field_on_all()
.hide_value()
.description(grid_socket_description);
b.add_input<decl::Int>(("Grid"), "Grid_Int")
b.add_input<decl::Int>("Grid", "Grid_Int")
.field_on_all()
.hide_value()
.description(grid_socket_description);
b.add_input<decl::Vector>(("Position")).implicit_field(implicit_field_inputs::position);
b.add_input<decl::Vector>("Position").implicit_field(implicit_field_inputs::position);
b.add_output<decl::Vector>(("Value"), "Value_Vector").dependent_field({5});
b.add_output<decl::Float>(("Value"), "Value_Float").dependent_field({5});
b.add_output<decl::Bool>(("Value"), "Value_Bool").dependent_field({5});
b.add_output<decl::Int>(("Value"), "Value_Int").dependent_field({5});
b.add_output<decl::Vector>("Value", "Value_Vector").dependent_field({5});
b.add_output<decl::Float>("Value", "Value_Float").dependent_field({5});
b.add_output<decl::Bool>("Value", "Value_Bool").dependent_field({5});
b.add_output<decl::Int>("Value", "Value_Int").dependent_field({5});
}
static void search_node_add_ops(GatherAddNodeSearchParams &params)

View File

@ -122,6 +122,8 @@ static void gpencil_shaderfx_ops_extra_draw(bContext *C, uiLayout *layout, void
uiLayoutSetUnitsX(layout, 4.0f);
UI_block_flag_enable(uiLayoutGetBlock(layout), UI_BLOCK_IS_FLIP);
/* Duplicate. */
uiItemO(layout,
CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Duplicate"),

View File

@ -20,7 +20,7 @@
#include "BLI_math_vector.h"
#include "BLI_utildefines.h"
#include "BKE_cloth.h"
#include "BKE_cloth.hh"
#include "BKE_collision.h"
#include "BKE_effect.h"

View File

@ -23,7 +23,7 @@
# include "BLI_math_vector.h"
# include "BLI_utildefines.h"
# include "BKE_cloth.h"
# include "BKE_cloth.hh"
# include "BKE_collision.h"
# include "BKE_effect.h"

View File

@ -57,7 +57,7 @@ extern "C" {
# include "BLI_linklist.h"
# include "BLI_utildefines.h"
# include "BKE_cloth.h"
# include "BKE_cloth.hh"
# include "BKE_collision.h"
# include "BKE_effect.h"
# include "BKE_global.h"

View File

@ -188,7 +188,9 @@ void WM_reinit_gizmomap_all(Main *bmain);
*/
void WM_script_tag_reload();
wmWindow *WM_window_find_under_cursor(wmWindow *win, const int mval[2], int r_mval[2]);
wmWindow *WM_window_find_under_cursor(wmWindow *win,
const int event_xy[2],
int r_event_xy_other[2]);
/**
* Knowing the area, return its screen.

View File

@ -252,8 +252,8 @@ void wm_drags_exit(wmWindowManager *wm, wmWindow *win)
}
/* Active area should always redraw, even if cancelled. */
int r_mval[2];
wmWindow *target_win = WM_window_find_under_cursor(win, win->eventstate->xy, &r_mval[0]);
int event_xy_target[2];
wmWindow *target_win = WM_window_find_under_cursor(win, win->eventstate->xy, event_xy_target);
if (target_win) {
const bScreen *screen = WM_window_get_active_screen(target_win);
ED_region_tag_redraw_no_rebuild(screen->active_region);

View File

@ -2267,21 +2267,23 @@ bool wm_window_get_swap_interval(wmWindow *win, int *intervalOut)
/** \name Find Window Utility
* \{ */
wmWindow *WM_window_find_under_cursor(wmWindow *win, const int mval[2], int r_mval[2])
wmWindow *WM_window_find_under_cursor(wmWindow *win,
const int event_xy[2],
int r_event_xy_other[2])
{
int tmp[2];
copy_v2_v2_int(tmp, mval);
wm_cursor_position_to_ghost_screen_coords(win, &tmp[0], &tmp[1]);
int temp_xy[2];
copy_v2_v2_int(temp_xy, event_xy);
wm_cursor_position_to_ghost_screen_coords(win, &temp_xy[0], &temp_xy[1]);
GHOST_WindowHandle ghostwin = GHOST_GetWindowUnderCursor(g_system, tmp[0], tmp[1]);
GHOST_WindowHandle ghostwin = GHOST_GetWindowUnderCursor(g_system, temp_xy[0], temp_xy[1]);
if (!ghostwin) {
return nullptr;
}
wmWindow *win_other = static_cast<wmWindow *>(GHOST_GetWindowUserData(ghostwin));
wm_cursor_position_from_ghost_screen_coords(win_other, &tmp[0], &tmp[1]);
copy_v2_v2_int(r_mval, tmp);
wm_cursor_position_from_ghost_screen_coords(win_other, &temp_xy[0], &temp_xy[1]);
copy_v2_v2_int(r_event_xy_other, temp_xy);
return win_other;
}

View File

@ -65,6 +65,10 @@ class ImBufTest(AbstractImBufTest):
# Save the image in the desired format with the desired settings
scene = bpy.data.scenes[0]
# The reference images were saved using Filmic view transform.
scene.view_settings.view_transform = "Filmic"
ref_image_path = self.reference_dir.joinpath(img.name)
out_image_path = self.output_dir.joinpath(img.name)
img.save_render(str(out_image_path), scene=scene)

View File

@ -266,6 +266,29 @@ if np is not None:
class TestRNAData(TestHelper, unittest.TestCase):
def test_custom_properties_access(self):
# Ensure the RNA path resolving behaves as expected & is compatible with ID-property keys.
keys_to_test = (
"test",
"\\"
'"',
'""',
'"""',
'[',
']',
'[]',
'["]',
'[""]',
'["""]',
'[""""]',
# Empty properties are also valid.
"",
)
for key_id in keys_to_test:
self.id[key_id] = 1
self.assertEqual(self.id[key_id], self.id.path_resolve('["%s"]' % bpy.utils.escape_identifier(key_id)))
del self.id[key_id]
def test_custom_properties_none(self):
bpy.data.objects.new("test", None)
test_object = bpy.data.objects["test"]