Compare commits

..

89 Commits

Author SHA1 Message Date
192719bdca Don't make a local variable to load the WorldClipPlanes. 2022-12-12 12:21:05 +01:00
275bbb8a4c Use GPU_SHADER; not GPU_VULKAN. 2022-12-12 12:20:23 +01:00
3a4d2df7b1 Vulkan: add cube map array. 2022-12-12 11:06:04 +01:00
c14af6b4d7 Prefix push constants to work around double macro expansion. 2022-12-12 09:47:04 +01:00
f676dbebf5 Merge branch 'master' into temp-vulkan-shader 2022-12-12 09:29:27 +01:00
320659068a Wortk around shaderc issue by converting view macros to functions. 2022-12-06 10:45:34 +01:00
1cdcfa3a89 Enable performance optimizations. 2022-12-06 10:09:26 +01:00
248299fc95 Nicer comments describing the issue. 2022-12-06 10:08:59 +01:00
a8a7b84659 Converted world_clip_planes macros to functions. 2022-12-06 08:38:13 +01:00
f1b4dce33e Remove const keyword from shader global. 2022-12-06 08:15:20 +01:00
0ae912a28a Merge branch 'master' into temp-vulkan-shader 2022-12-06 08:14:12 +01:00
f5f1ac9f03 Revert whitespace change. 2022-12-02 13:44:35 +01:00
5033453735 Merge branch 'master' into temp-vulkan-shader 2022-12-02 13:44:10 +01:00
da4b09ac6f Remove code that hides missing feature in master as it is now fixed in master. 2022-12-02 13:35:32 +01:00
df3c418866 Merge branch 'master' into temp-vulkan-shader 2022-12-02 12:52:51 +01:00
f23b870def Removed debug code. 2022-12-02 12:46:53 +01:00
94e1e694bc Merge branch 'temp-vulkan-shader' of git.blender.org:blender into temp-vulkan-shader 2022-12-02 12:28:28 +01:00
78abdcf31e Tweaked gpu_InstanceIndex. 2022-12-02 12:27:42 +01:00
99e4bfd5e4 Tweaked gpu_InstanceIndex. 2022-12-02 12:24:30 +01:00
794ce2a08f Removed debug code. 2022-12-02 12:12:21 +01:00
67b3796723 Revert change to device restriction. 2022-12-02 12:09:20 +01:00
f1d9fe95e8 Fixed lens distortion compilation. 2022-12-02 12:04:44 +01:00
bbbe5a3894 Fix Eevee-next depth of field compilation. 2022-12-02 12:04:18 +01:00
b1ba82ba97 Fix sampler is a keyword, do not use a parameter name. 2022-12-02 11:26:21 +01:00
db6db0b754 Remove warning (pragma once not implemented). 2022-12-02 11:12:16 +01:00
642bba24a9 Added support for compute and shader storage. 2022-12-02 11:10:16 +01:00
244f61e9e9 Fix motion patch shaders. 2022-12-02 10:59:41 +01:00
12b9ebc690 Moved debug code. 2022-12-02 10:29:38 +01:00
49723cca42 Enable OpenGL/Metal shader compilation. (was disabled for debugging). 2022-12-02 10:29:18 +01:00
8781886cf7 Fix compilation of line dashed shader. 2022-12-02 10:17:20 +01:00
37ee9595a0 Fix gpencil shaders. 2022-12-02 10:16:23 +01:00
be1dce8dfb Fix compilation issues in workbench shadow. 2022-12-02 09:58:31 +01:00
2d6dfbf038 Fix vulkan compilation of common_smaa_lib.glsl 2022-12-02 09:31:04 +01:00
7214298cd1 Merge branch 'master' into temp-vulkan-shader 2022-12-02 08:37:58 +01:00
63084dc7dd Merge branch 'master' into temp-vulkan-shader 2022-12-02 08:05:34 +01:00
42645b33d6 Use correct layout location. 2022-11-29 15:54:43 +01:00
cf52e4a07f Add definition of gl_InstanceID. 2022-11-29 15:28:53 +01:00
4a3cbfd90e Add glsl shader defines. 2022-11-29 15:25:22 +01:00
dc973dfa28 Fixed geometry layout. 2022-11-29 15:16:12 +01:00
bf3eea036d Remove debug code. 2022-11-29 14:43:14 +01:00
8244f55530 regular stage interfaces working. 2022-11-29 14:37:42 +01:00
cfb44574d9 Fixed stage interface declaration. 2022-11-29 12:19:11 +01:00
c836b7e603 Merge branch 'master' into temp-vulkan-shader 2022-11-29 11:30:14 +01:00
a246ad9559 Remove unused cmake includes/libs. 2022-11-25 14:50:10 +01:00
36127e042b Improve shader log to add correct filenames. 2022-11-25 14:16:46 +01:00
94a98b9365 Copied over GLSL code gen functions from GLShader. 2022-11-25 14:16:46 +01:00
5ca4e9e545 Added other stages to VKShader. 2022-11-25 10:03:10 +01:00
8a3329e72b Initialize GCaps from VKContext. 2022-11-25 10:00:31 +01:00
7d7a39d00b Make sure that shader compiler doesn't crash when using Vulkan. 2022-11-25 09:24:03 +01:00
74bfeec1a5 Merge branch 'master' into temp-vulkan-shader 2022-11-25 09:00:38 +01:00
1273af7a01 Vulkan: create shader module. 2022-11-22 17:01:33 +01:00
e2d18eda75 Merge branch 'temp-vulkan-memory-allocator' into temp-vulkan-shader 2022-11-22 16:38:41 +01:00
bfa1f2d351 Add destructor and accessor for VKContext::mem_allocator_. 2022-11-22 14:22:46 +01:00
1effef805e Merge branch 'master' into temp-vulkan-shader 2022-11-22 14:19:26 +01:00
6f1197c6b9 Some tweaks in make file to reduce branching. 2022-11-22 14:11:32 +01:00
23503dec99 Merge branch 'master' into temp-vulkan-memory-allocator 2022-11-22 14:08:14 +01:00
b43e11deda Don't use curly brackets to group code. 2022-11-22 13:17:08 +01:00
d45bbff511 Change vulkan version to 1.2 2022-11-22 13:14:29 +01:00
9b467c591d Change license header. 2022-11-22 13:14:17 +01:00
0bc4eb987c GPU: add vulkan memory allocator to VKContext. 2022-11-22 13:06:52 +01:00
648158dfbd Merge branch 'master' into temp-vulkan-memory-allocator 2022-11-22 12:48:03 +01:00
fc0b8cb085 Fix compilation vk_mem_alloc on Apple. 2022-11-22 12:32:06 +01:00
b3254da333 Merge branch 'master' into temp-vulkan-shader 2022-11-22 12:26:43 +01:00
72e5cbf0c7 Vulkan: Add VK memory allocator 3.0.1 to extern.
Vulkan doesn't have a memory allocator builtin. The application should
provide the memory allocator at runtime. Vulkan Memory Allocator is a
widely used implementation.

Vulkan Memory Allocator is a header only implementation, but the using
application should compile a part in a CPP compile unit. The file
`vk_mem_alloc_impl.cc` and `extern_vulkan_memory_allocator` library
is therefore introduced.

Before continuing with this patch the GHOST vulkan branch should added.

Differential Revision: https://developer.blender.org/D16572
2022-11-22 12:03:08 +01:00
44ad59592b Vulkan: compile shader to spirv. 2022-11-21 14:01:47 +01:00
72b395a7e6 Find includes and libs for shaderc.
Don't use the default find_pavkage(vulkan) as that won't find the SDK.
ShaderC is only part of the SDK, not of the distributed driver part.
2022-11-18 15:49:42 +01:00
041900ae95 GHOST: Command pool should be able to reset. 2022-11-18 11:45:15 +01:00
b271ed8ac9 Code style struct initialization. 2022-11-18 11:35:44 +01:00
6ccd38ea90 GHOST: Vulkan swapbuffer should wait for graphics queue idling. 2022-11-18 11:35:12 +01:00
7d691969e6 Remove (void) parameters from GHOST_ContextVK. 2022-11-18 11:28:14 +01:00
1a47f3ae17 CMAKE: Move WITH_VULKAN_BACKEND from global to specific modules. 2022-11-18 11:24:23 +01:00
7211f3ab5b Merge branch 'master' into temp-ghost-vulkan 2022-11-18 11:04:32 +01:00
fad06751a6 Merge branch 'master' into temp-ghost-vulkan 2022-11-15 11:12:27 +01:00
0fae43efb2 Apply formatting. 2022-11-08 14:32:27 +01:00
31ecc30283 Added support for Linux. Thanks to Qiang Yu for the patch! 2022-11-08 14:29:25 +01:00
d64d789174 Initialize vk backend. 2022-11-07 08:03:50 +01:00
975e9020cb Create VKBackend when selecting vulkan from the command line. 2022-11-01 14:52:33 +01:00
d2c6a27f58 Finding MOLTENVK. 2022-11-01 13:51:16 +01:00
6ca82bbf34 Fix missing import in GHOST_SystemWin32.cpp 2022-11-01 12:02:27 +01:00
86868a4bcc Changes to cmake to select vulkan from libs. 2022-11-01 12:00:28 +01:00
5db147c5be Merge branch 'master' into temp-ghost-vulkan 2022-11-01 09:26:54 +01:00
39db9b836b Removed debug code. 2022-11-01 08:42:49 +01:00
b0800197e6 Removed debug code. 2022-11-01 08:42:49 +01:00
16f5cda14a Removed obsolete comments. 2022-11-01 08:42:49 +01:00
50e0d346f1 Implemented newDrawingContext. 2022-11-01 08:42:49 +01:00
7cd24fb70a Implemented createOffscreenContext. 2022-11-01 08:42:49 +01:00
1b04b5cf08 Find MoltenVK (WIP). 2022-11-01 08:42:49 +01:00
18ba57ddb6 Copied from tmp-vulkan branch. 2022-11-01 08:42:49 +01:00
ed2b382490 Add vulkan changes to cmake files. 2022-11-01 08:42:49 +01:00
66 changed files with 518 additions and 3275 deletions

View File

@@ -5,7 +5,7 @@
update-code:
git:
submodules:
- branch: xr-dev
- branch: master
commit_id: HEAD
path: release/scripts/addons
- branch: master

View File

@@ -22,15 +22,16 @@
CCL_NAMESPACE_BEGIN
/* TODO: this seems like a relative expensive computation. We can make it a lot cheaper by using a
* bounding sphere instead of a bounding box, but this will reduce the accuracy sometimes. */
/* TODO: this seems like a relative expensive computation, and we can make it a lot cheaper
* by using a bounding sphere instead of a bounding box. This will be more inaccurate, but it
* might be fine when used along with the adaptive splitting. */
ccl_device float light_tree_cos_bounding_box_angle(const BoundingBox bbox,
const float3 P,
const float3 point_to_centroid)
{
if (P.x > bbox.min.x && P.y > bbox.min.y && P.z > bbox.min.z && P.x < bbox.max.x &&
P.y < bbox.max.y && P.z < bbox.max.z) {
/* If P is inside the bbox, `theta_u` covers the whole sphere. */
/* If P is inside the bbox, `theta_u` covers the whole sphere */
return -1.0f;
}
float cos_theta_u = 1.0f;
@@ -52,7 +53,7 @@ ccl_device_forceinline float sin_from_cos(const float c)
return safe_sqrtf(1.0f - sqr(c));
}
/* Compute vector v as in Fig .8. P_v is the corresponding point along the ray. */
/* Compute vector v as in Fig .8. P_v is the corresponding point along the ray ccl_device float3 */
ccl_device float3 compute_v(
const float3 centroid, const float3 P, const float3 D, const float3 bcone_axis, const float t)
{
@@ -94,12 +95,12 @@ ccl_device void light_tree_importance(const float3 N_or_D,
const float sin_theta_u = sin_from_cos(cos_theta_u);
/* cos(theta_i') in the paper, omitted for volume. */
/* cos(theta_i') in the paper, omitted for volume */
float cos_min_incidence_angle = 1.0f;
float cos_max_incidence_angle = 1.0f;
/* When sampling the light tree for the second time in `shade_volume.h` and when query the pdf in
* `sample.h`. */
/* when sampling the light tree for the second time in `shade_volume.h` and when query the pdf in
* `sample.h` */
const bool in_volume = is_zero(N_or_D);
if (!in_volume_segment && !in_volume) {
const float3 N = N_or_D;
@@ -115,7 +116,7 @@ ccl_device void light_tree_importance(const float3 N_or_D,
/* If the node is guaranteed to be behind the surface we're sampling, and the surface is
* opaque, then we can give the node an importance of 0 as it contributes nothing to the
* surface. This is more accurate than the bbox test if we are calculating the importance of
* an emitter with radius. */
* an emitter with radius */
if (!has_transmission && cos_min_incidence_angle < 0) {
return;
}
@@ -132,8 +133,8 @@ ccl_device void light_tree_importance(const float3 N_or_D,
float cos_theta_o, sin_theta_o;
fast_sincosf(bcone.theta_o, &sin_theta_o, &cos_theta_o);
/* Minimum angle an emitters axis would form with the direction to the shading point,
* cos(theta') in the paper. */
/* minimum angle an emitters axis would form with the direction to the shading point,
* cos(theta') in the paper */
float cos_min_outgoing_angle;
if ((cos_theta >= cos_theta_u) || (cos_theta_minus_theta_u >= cos_theta_o)) {
/* theta - theta_o - theta_u <= 0 */
@@ -150,7 +151,7 @@ ccl_device void light_tree_importance(const float3 N_or_D,
sin_theta_minus_theta_u * sin_theta_o;
}
else {
/* Cluster is invisible. */
/* cluster invisible */
return;
}
@@ -199,14 +200,14 @@ ccl_device bool compute_emitter_centroid_and_dir(KernelGlobals kg,
dir = klight->spot.dir;
break;
case LIGHT_POINT:
/* Disk-oriented normal. */
/* Disk-oriented normal */
dir = safe_normalize(P - centroid);
break;
case LIGHT_AREA:
dir = klight->area.dir;
break;
case LIGHT_BACKGROUND:
/* Arbitrary centroid and direction. */
/* Aarbitrary centroid and direction */
centroid = make_float3(0.0f, 0.0f, 1.0f);
dir = make_float3(0.0f, 0.0f, -1.0f);
return !in_volume_segment;
@@ -230,7 +231,7 @@ ccl_device bool compute_emitter_centroid_and_dir(KernelGlobals kg,
dir = -safe_normalize(cross(vertices[1] - vertices[0], vertices[2] - vertices[0]));
}
else {
/* Double-sided: any vector in the plane. */
/* Double sided: any vector in the plane. */
dir = safe_normalize(vertices[0] - vertices[1]);
}
}
@@ -268,9 +269,9 @@ ccl_device void light_tree_emitter_importance(KernelGlobals kg,
if (in_volume_segment) {
const float3 D = N_or_D;
/* Closest point. */
/* Closest point */
P_c = P + dot(centroid - P, D) * D;
/* Minimal distance of the ray to the cluster. */
/* minimal distance of the ray to the cluster */
distance.x = len(centroid - P_c);
distance.y = distance.x;
point_to_centroid = -compute_v(centroid, P, D, bcone.axis, t);
@@ -283,7 +284,7 @@ ccl_device void light_tree_emitter_importance(KernelGlobals kg,
if (prim_id < 0) {
const ccl_global KernelLight *klight = &kernel_data_fetch(lights, ~prim_id);
switch (klight->type) {
/* Function templates only modifies cos_theta_u when in_volume_segment = true. */
/* Function templates only modifies cos_theta_u when in_volume_segment = true */
case LIGHT_SPOT:
is_visible = spot_light_tree_parameters<in_volume_segment>(
klight, centroid, P_c, cos_theta_u, distance, point_to_centroid);
@@ -309,7 +310,7 @@ ccl_device void light_tree_emitter_importance(KernelGlobals kg,
return;
}
}
else { /* Mesh light. */
else { /* mesh light */
is_visible = triangle_light_tree_parameters<in_volume_segment>(
kg, kemitter, centroid, P_c, N_or_D, bcone, cos_theta_u, distance, point_to_centroid);
}
@@ -345,7 +346,7 @@ ccl_device void light_tree_node_importance(KernelGlobals kg,
max_importance = 0.0f;
min_importance = 0.0f;
if (knode->num_prims == 1) {
/* At a leaf node with only one emitter. */
/* At a leaf node with only one emitter */
light_tree_emitter_importance<in_volume_segment>(
kg, P, N_or_D, t, has_transmission, -knode->child_index, max_importance, min_importance);
}
@@ -357,7 +358,7 @@ ccl_device void light_tree_node_importance(KernelGlobals kg,
float cos_theta_u;
float distance;
if (knode->bit_trail == 1) {
/* Distant light node. */
/* distant light node */
if (in_volume_segment) {
return;
}
@@ -371,7 +372,7 @@ ccl_device void light_tree_node_importance(KernelGlobals kg,
if (in_volume_segment) {
const float3 D = N_or_D;
const float3 closest_point = P + dot(centroid - P, D) * D;
/* Minimal distance of the ray to the cluster. */
/* minimal distance of the ray to the cluster */
distance = len(centroid - closest_point);
point_to_centroid = -compute_v(centroid, P, D, bcone.axis, t);
cos_theta_u = light_tree_cos_bounding_box_angle(bbox, closest_point, point_to_centroid);
@@ -392,7 +393,7 @@ ccl_device void light_tree_node_importance(KernelGlobals kg,
point_to_centroid = normalize_len(centroid - P, &distance);
cos_theta_u = light_tree_cos_bounding_box_angle(bbox, P, point_to_centroid);
}
/* Clamp distance to half the radius of the cluster when splitting is disabled. */
/* clamp distance to half the radius of the cluster when splitting is disabled */
distance = fmaxf(0.5f * len(centroid - bbox.max), distance);
}
/* TODO: currently max_distance = min_distance, max_importance = min_importance for the
@@ -435,8 +436,8 @@ ccl_device void sample_resevoir(const int current_index,
return;
}
/* Pick an emitter from a leaf node using resevoir sampling, keep two reservoirs for upper and
* lower bounds. */
/* pick an emitter from a leaf node using resevoir sampling, keep two reservoirs for upper and
* lower bounds */
template<bool in_volume_segment>
ccl_device int light_tree_cluster_select_emitter(KernelGlobals kg,
ccl_private float &rand,
@@ -451,11 +452,11 @@ ccl_device int light_tree_cluster_select_emitter(KernelGlobals kg,
float total_importance[2] = {0.0f, 0.0f};
int selected_index = -1;
/* Mark emitters with zero importance. Used for resevoir when total minimum importance = 0. */
/* Mark emitters with zero importance. Used for resevoir when total minimum importance = 0 */
kernel_assert(knode->num_prims <= sizeof(uint) * 8);
uint has_importance = 0;
const bool sample_max = (rand > 0.5f); /* Sampling using the maximum importance. */
const bool sample_max = (rand > 0.5f); /* sampling using the maximum importance */
rand = rand * 2.0f - float(sample_max);
for (int i = 0; i < knode->num_prims; i++) {
@@ -484,7 +485,7 @@ ccl_device int light_tree_cluster_select_emitter(KernelGlobals kg,
}
if (total_importance[1] == 0.0f) {
/* Uniformly sample emitters with positive maximum importance. */
/* uniformly sample emitters with positive maximum importance */
if (sample_max) {
selected_importance[1] = 1.0f;
total_importance[1] = float(popcount(has_importance));
@@ -539,7 +540,7 @@ ccl_device bool get_left_probability(KernelGlobals kg,
}
const float total_min_importance = min_left_importance + min_right_importance;
/* Average two probabilities of picking the left child node using lower and upper bounds. */
/* average two probabilities of picking the left child node using lower and upper bounds */
const float probability_max = max_left_importance / total_max_importance;
const float probability_min = total_min_importance > 0 ?
min_left_importance / total_min_importance :
@@ -571,28 +572,28 @@ ccl_device_noinline bool light_tree_sample(KernelGlobals kg,
float pdf_emitter_from_leaf = 1.0f;
int selected_light = -1;
int node_index = 0; /* Root node. */
int node_index = 0; /* root node */
/* Traverse the light tree until a leaf node is reached. */
while (true) {
const ccl_global KernelLightTreeNode *knode = &kernel_data_fetch(light_tree_nodes, node_index);
if (knode->child_index <= 0) {
/* At a leaf node, we pick an emitter. */
/* At a leaf node, we pick an emitter */
selected_light = light_tree_cluster_select_emitter<in_volume_segment>(
kg, randv, P, N_or_D, t, has_transmission, knode, &pdf_emitter_from_leaf);
break;
}
/* At an interior node, the left child is directly after the parent, while the right child is
* stored as the child index. */
/* At an interior node, the left child is directly after the parent,
* while the right child is stored as the child index. */
const int left_index = node_index + 1;
const int right_index = knode->child_index;
float left_prob;
if (!get_left_probability<in_volume_segment>(
kg, P, N_or_D, t, has_transmission, left_index, right_index, left_prob)) {
return false; /* Both child nodes have zero importance. */
return false; /* both child nodes have zero importance */
}
float discard;
@@ -606,7 +607,7 @@ ccl_device_noinline bool light_tree_sample(KernelGlobals kg,
return false;
}
/* Sample a point on the chosen emitter. */
/* Sample a point on the chosen emitter */
ccl_global const KernelLightTreeEmitter *kemitter = &kernel_data_fetch(light_tree_emitters,
selected_light);
@@ -649,7 +650,7 @@ ccl_device float light_tree_pdf(
KernelGlobals kg, const float3 P, const float3 N, const int path_flag, const int prim)
{
const bool has_transmission = (path_flag & PATH_RAY_MIS_HAD_TRANSMISSION);
/* Target emitter info. */
/* Target emitter info */
const int target_emitter = (prim >= 0) ? kernel_data_fetch(triangle_to_tree, prim) :
kernel_data_fetch(light_to_tree, ~prim);
ccl_global const KernelLightTreeEmitter *kemitter = &kernel_data_fetch(light_tree_emitters,
@@ -658,11 +659,11 @@ ccl_device float light_tree_pdf(
ccl_global const KernelLightTreeNode *kleaf = &kernel_data_fetch(light_tree_nodes, target_leaf);
uint bit_trail = kleaf->bit_trail;
int node_index = 0; /* Root node. */
int node_index = 0; /* root node */
float pdf = 1.0f;
/* Traverse the light tree until we reach the target leaf node. */
/* Traverse the light tree until we reach the target leaf node */
while (true) {
const ccl_global KernelLightTreeNode *knode = &kernel_data_fetch(light_tree_nodes, node_index);
@@ -670,7 +671,7 @@ ccl_device float light_tree_pdf(
break;
}
/* Interior node. */
/* Interior node */
const int left_index = node_index + 1;
const int right_index = knode->child_index;

View File

@@ -689,10 +689,6 @@ enum {
* (use DirectX fallback instead). */
GHOST_kXrContextGpuNVIDIA = (1 << 2),
# endif
/* Needed to selectively enable the #XR_HTCX_vive_tracker_interaction extension, as it causes
incorrect controller poses with SteamVR (1.21). Although not ideal, either trackers or
controllers (but not both) can be used during a given session. */
GHOST_kXrContextEnableViveTrackerExtension = (1 << 3),
};
typedef struct {

View File

@@ -82,7 +82,7 @@ void GHOST_XrContext::initialize(const GHOST_XrContextCreateInfo *create_info)
determineGraphicsBindingTypesToEnable(create_info);
assert(m_oxr->instance == XR_NULL_HANDLE);
createOpenXRInstance(graphics_binding_types, create_info);
createOpenXRInstance(graphics_binding_types);
storeInstanceProperties();
/* Multiple bindings may be enabled. Now that we know the runtime in use, settle for one. */
@@ -95,8 +95,7 @@ void GHOST_XrContext::initialize(const GHOST_XrContextCreateInfo *create_info)
}
void GHOST_XrContext::createOpenXRInstance(
const std::vector<GHOST_TXrGraphicsBinding> &graphics_binding_types,
const GHOST_XrContextCreateInfo *ctx_create_info)
const std::vector<GHOST_TXrGraphicsBinding> &graphics_binding_types)
{
XrInstanceCreateInfo create_info = {XR_TYPE_INSTANCE_CREATE_INFO};
@@ -105,7 +104,7 @@ void GHOST_XrContext::createOpenXRInstance(
create_info.applicationInfo.apiVersion = XR_CURRENT_API_VERSION;
getAPILayersToEnable(m_enabled_layers);
getExtensionsToEnable(graphics_binding_types, ctx_create_info, m_enabled_extensions);
getExtensionsToEnable(graphics_binding_types, m_enabled_extensions);
create_info.enabledApiLayerCount = m_enabled_layers.size();
create_info.enabledApiLayerNames = m_enabled_layers.data();
create_info.enabledExtensionCount = m_enabled_extensions.size();
@@ -401,7 +400,6 @@ static const char *openxr_ext_name_from_wm_gpu_binding(GHOST_TXrGraphicsBinding
*/
void GHOST_XrContext::getExtensionsToEnable(
const std::vector<GHOST_TXrGraphicsBinding> &graphics_binding_types,
const GHOST_XrContextCreateInfo *create_info,
std::vector<const char *> &r_ext_names)
{
std::vector<std::string_view> try_ext;
@@ -417,11 +415,6 @@ void GHOST_XrContext::getExtensionsToEnable(
#ifdef XR_HTC_VIVE_FOCUS3_CONTROLLER_INTERACTION_EXTENSION_NAME
try_ext.push_back(XR_HTC_VIVE_FOCUS3_CONTROLLER_INTERACTION_EXTENSION_NAME);
#endif
if ((create_info->context_flag & GHOST_kXrContextEnableViveTrackerExtension) != 0) {
#ifdef XR_HTCX_VIVE_TRACKER_INTERACTION_EXTENSION_NAME
try_ext.push_back(XR_HTCX_VIVE_TRACKER_INTERACTION_EXTENSION_NAME);
#endif
}
try_ext.push_back(XR_HUAWEI_CONTROLLER_INTERACTION_EXTENSION_NAME);
/* Controller model extension. */

View File

@@ -108,8 +108,7 @@ class GHOST_XrContext : public GHOST_IXrContext {
bool m_debug = false;
bool m_debug_time = false;
void createOpenXRInstance(const std::vector<GHOST_TXrGraphicsBinding> &graphics_binding_types,
const GHOST_XrContextCreateInfo *create_info);
void createOpenXRInstance(const std::vector<GHOST_TXrGraphicsBinding> &graphics_binding_types);
void storeInstanceProperties();
void initDebugMessenger();
@@ -123,7 +122,6 @@ class GHOST_XrContext : public GHOST_IXrContext {
void initExtensionsEx(std::vector<XrExtensionProperties> &extensions, const char *layer_name);
void getAPILayersToEnable(std::vector<const char *> &r_ext_names);
void getExtensionsToEnable(const std::vector<GHOST_TXrGraphicsBinding> &graphics_binding_types,
const GHOST_XrContextCreateInfo *create_info,
std::vector<const char *> &r_ext_names);
std::vector<GHOST_TXrGraphicsBinding> determineGraphicsBindingTypesToEnable(
const GHOST_XrContextCreateInfo *create_info);

View File

@@ -1223,7 +1223,6 @@ void BKE_nodetree_remove_layer_n(struct bNodeTree *ntree, struct Scene *scene, i
#define SH_NODE_COMBINE_COLOR 711
#define SH_NODE_SEPARATE_COLOR 712
#define SH_NODE_MIX 713
#define SH_NODE_VIRTUAL_MONITOR 714
/** \} */

View File

@@ -41,8 +41,6 @@
#include "DEG_depsgraph_query.h"
#include "GPU_viewport.h"
#include "MEM_guardedalloc.h"
#include "BLO_read_write.h"
@@ -59,20 +57,6 @@ static void camera_init_data(ID *id)
MEMCPY_STRUCT_AFTER(cam, DNA_struct_default_get(Camera), id);
}
/** Free (or release) any data used by this camera (does not free the camera itself). */
static void camera_free_runtime_data(Camera *cam, const Camera *cam_src)
{
if (cam->runtime.virtual_monitor_offscreen) {
if (!cam_src ||
(cam_src->runtime.virtual_monitor_offscreen != cam->runtime.virtual_monitor_offscreen)) {
GPU_offscreen_free(cam->runtime.virtual_monitor_offscreen);
}
cam->runtime.virtual_monitor_offscreen = NULL;
}
/* GPU texture is owned by the GPUOffscreen instance. */
cam->runtime.offscreen_color_texture = NULL;
}
/**
* Only copy internal data of Camera ID from source
* to already allocated/initialized destination.
@@ -96,17 +80,13 @@ static void camera_copy_data(Main *UNUSED(bmain), ID *id_dst, const ID *id_src,
CameraBGImage *bgpic_dst = BKE_camera_background_image_copy(bgpic_src, flag_subdata);
BLI_addtail(&cam_dst->bg_images, bgpic_dst);
}
/* Free runtime data to prevent virtual monitor offscreen from being shared across data-blocks.
*/
camera_free_runtime_data(cam_dst, cam_src);
}
/** Free (or release) any data used by this camera (does not free the camera itself). */
static void camera_free_data(ID *id)
{
Camera *cam = (Camera *)id;
BLI_freelistN(&cam->bg_images);
camera_free_runtime_data(cam, NULL);
}
static void camera_foreach_id(ID *id, LibraryForeachIDData *data)
@@ -157,8 +137,6 @@ static void camera_blend_read_data(BlendDataReader *reader, ID *id)
bgpic->flag &= ~CAM_BGIMG_FLAG_OVERRIDE_LIBRARY_LOCAL;
}
}
ca->runtime.virtual_monitor_offscreen = NULL;
ca->runtime.offscreen_color_texture = NULL;
}
static void camera_blend_read_lib(BlendLibReader *reader, ID *id)

View File

@@ -500,19 +500,14 @@ static int customdata_compare(
for (int i1 = 0; i1 < c1->totlayer; i1++) {
l1 = c1->layers + i1;
if (l1->anonymous_id != nullptr) {
continue;
}
bool found_corresponding_layer = false;
for (int i2 = 0; i2 < c2->totlayer; i2++) {
l2 = c2->layers + i2;
if (l1->type != l2->type || !STREQ(l1->name, l2->name) || l2->anonymous_id != nullptr) {
if (l1->type != l2->type || !STREQ(l1->name, l2->name) || l1->anonymous_id != nullptr ||
l2->anonymous_id != nullptr) {
continue;
}
/* At this point `l1` and `l2` have the same name and type, so they should be compared. */
found_corresponding_layer = true;
switch (l1->type) {
case CD_MVERT: {
@@ -724,11 +719,6 @@ static int customdata_compare(
}
}
}
if (!found_corresponding_layer) {
if ((1 << l1->type) & CD_MASK_PROP_ALL) {
return MESHCMP_CDLAYERS_MISMATCH;
}
}
}
return 0;

View File

@@ -2333,10 +2333,6 @@ static void lib_link_wm_xr_data_restore(IDNameLib_Map *id_map, wmXrData *xr_data
{
xr_data->session_settings.base_pose_object = static_cast<Object *>(restore_pointer_by_name(
id_map, (ID *)xr_data->session_settings.base_pose_object, USER_REAL));
LISTBASE_FOREACH (XrMotionCaptureObject *, mocap_ob, &xr_data->session_settings.mocap_objects) {
mocap_ob->ob = (Object *)restore_pointer_by_name(id_map, (ID *)mocap_ob->ob, USER_REAL);
}
}
static void lib_link_window_scene_data_restore(wmWindow *win, Scene *scene, ViewLayer *view_layer)

View File

@@ -99,7 +99,6 @@ void DRW_draw_render_loop_offscreen(struct Depsgraph *depsgraph,
bool is_image_render,
bool draw_background,
bool do_color_management,
bool is_virtual_camera,
struct GPUOffScreen *ofs,
struct GPUViewport *viewport);
void DRW_draw_render_loop_2d_ex(struct Depsgraph *depsgraph,

View File

@@ -861,12 +861,6 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata,
continue;
}
/* Virtual cameras can only be used in the main scene. */
if (DRW_state_is_virtual_camera() &&
GPU_material_flag_get(gpumat_array[i], GPU_MATFLAG_VIRTUAL_MONITOR)) {
continue;
}
/* Do not render surface if we are rendering a volume object
* and do not have a surface closure. */
if (use_volume_material &&

View File

@@ -943,10 +943,6 @@ bool DRW_state_is_scene_render(void);
*/
bool DRW_state_is_opengl_render(void);
bool DRW_state_is_playback(void);
/**
* Whether we are rendering a virtual camera, false when rendering the main camera/viewport.
*/
bool DRW_state_is_virtual_camera(void);
/**
* Is the user navigating the region.
*/

View File

@@ -1809,7 +1809,6 @@ void DRW_draw_render_loop_offscreen(struct Depsgraph *depsgraph,
const bool is_image_render,
const bool draw_background,
const bool do_color_management,
const bool is_virtual_camera,
GPUOffScreen *ofs,
GPUViewport *viewport)
{
@@ -1833,7 +1832,6 @@ void DRW_draw_render_loop_offscreen(struct Depsgraph *depsgraph,
drw_state_prepare_clean_for_draw(&DST);
DST.options.is_image_render = is_image_render;
DST.options.draw_background = draw_background;
DST.options.is_virtual_camera = is_virtual_camera;
DRW_draw_render_loop_ex(depsgraph, engine_type, region, v3d, render_viewport, NULL);
if (draw_background) {
@@ -2926,11 +2924,6 @@ bool DRW_state_is_opengl_render(void)
return DST.options.is_image_render && !DST.options.is_scene_render;
}
bool DRW_state_is_virtual_camera(void)
{
return DST.options.is_virtual_camera;
}
bool DRW_state_is_playback(void)
{
if (DST.draw_ctx.evil_C != NULL) {

View File

@@ -612,7 +612,6 @@ typedef struct DRWManager {
uint is_depth : 1;
uint is_image_render : 1;
uint is_scene_render : 1;
uint is_virtual_camera : 1;
uint draw_background : 1;
uint draw_text : 1;
} options;

View File

@@ -1835,11 +1835,6 @@ void DRW_shgroup_add_material_resources(DRWShadingGroup *grp, GPUMaterial *mater
DRW_shgroup_uniform_texture_ex(
grp, tex->sampler_name, *tex->sky, eGPUSamplerState(tex->sampler_state));
}
else if (tex->camera && tex->camera[0]) {
/* VirtualCamera */
DRW_shgroup_uniform_texture_ex(
grp, tex->sampler_name, *tex->camera, eGPUSamplerState(tex->sampler_state));
}
}
GPUUniformBuf *ubo = GPU_material_uniform_buffer_get(material);

View File

@@ -13,13 +13,10 @@ extern "C" {
/* ******************* Registration Function ********************** */
struct ID;
struct Object;
struct bContext;
struct ViewLayer;
struct wmKeyConfig;
struct wmOperatorType;
struct wmTimer;
void ED_keymap_transform(struct wmKeyConfig *keyconf);
void transform_operatortypes(void);
@@ -206,19 +203,6 @@ int ED_transform_calc_gizmo_stats(const struct bContext *C,
const struct TransformCalcParams *params,
struct TransformBounds *tbounds);
/* transform_convert.c */
void ED_transform_animrecord_check_state(struct Scene *scene,
struct wmTimer *animtimer,
struct ID *id);
/* transform_convert_object.c */
void ED_transform_autokeyframe_object(struct bContext *C,
struct Scene *scene,
struct ViewLayer *view_layer,
struct Object *ob,
int tmode);
bool ED_transform_motionpath_need_update_object(struct Scene *scene, struct Object *ob);
/**
* Iterates over all the strips and finds the closest snapping candidate of either \a frame_1 or \a
* frame_2. The closest snapping candidate will be the closest start or end frame of an existing

View File

@@ -976,12 +976,6 @@ void ED_view3d_viewcontext_init(struct bContext *C,
* So object-mode specific values should remain cleared when initialized with another object.
*/
void ED_view3d_viewcontext_init_object(struct ViewContext *vc, struct Object *obact);
/**
* Deselect all except b.
*/
bool ED_view3d_object_deselect_all_except(const struct Scene *scene,
struct ViewLayer *view_layer,
struct Base *b);
/**
* Use this call when executing an operator,
* event system doesn't set for each event the OpenGL drawing context.
@@ -1346,7 +1340,7 @@ void ED_view3d_local_collections_reset(struct bContext *C, bool reset_all);
#ifdef WITH_XR_OPENXR
void ED_view3d_xr_mirror_update(const struct ScrArea *area, const struct View3D *v3d, bool enable);
void ED_view3d_xr_shading_update(struct wmWindowManager *wm,
const struct View3D *v3d,
const View3D *v3d,
const struct Scene *scene);
bool ED_view3d_is_region_xr_mirror_active(const struct wmWindowManager *wm,
const struct View3D *v3d,

View File

@@ -39,7 +39,6 @@ void ED_view3d_draw_offscreen(struct Depsgraph *depsgraph,
const char *viewname,
bool do_color_management,
bool restore_rv3d_mats,
bool is_virtual_camera,
struct GPUOffScreen *ofs,
struct GPUViewport *viewport);
/**

View File

@@ -2417,7 +2417,6 @@ void uiTemplateEditModeSelection(uiLayout *layout, struct bContext *C);
void uiTemplateReportsBanner(uiLayout *layout, struct bContext *C);
void uiTemplateInputStatus(uiLayout *layout, struct bContext *C);
void uiTemplateKeymapItemProperties(uiLayout *layout, struct PointerRNA *ptr);
void uiTemplateXrActionmapItemProperties(uiLayout *layout, struct PointerRNA *ptr);
bool uiTemplateEventFromKeymapItem(struct uiLayout *layout,
const char *text,

View File

@@ -110,9 +110,6 @@ if(WIN32 OR APPLE)
endif()
endif()
if(WITH_XR_OPENXR)
add_definitions(-DWITH_XR_OPENXR)
endif()
blender_add_lib(bf_editor_interface "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")

View File

@@ -6567,44 +6567,6 @@ void uiTemplateKeymapItemProperties(uiLayout *layout, PointerRNA *ptr)
/** \} */
/* -------------------------------------------------------------------- */
/** \name XR Actionmap Template
* \{ */
#ifdef WITH_XR_OPENXR
static void xr_actionmap_item_modified(bContext *UNUSED(C),
void *UNUSED(ami_p),
void *UNUSED(unused))
{
}
#endif
void uiTemplateXrActionmapItemProperties(uiLayout *layout, PointerRNA *ptr)
{
#ifdef WITH_XR_OPENXR
PointerRNA propptr = RNA_pointer_get(ptr, "op_properties");
if (propptr.data) {
uiBut *but = static_cast<uiBut *>(uiLayoutGetBlock(layout)->buttons.last);
WM_operator_properties_sanitize(&propptr, false);
/* Use same template as keymap item properties. */
template_keymap_item_properties(layout, nullptr, &propptr);
for (; but; but = but->next) {
if (but->rnaprop) {
UI_but_func_set(but, xr_actionmap_item_modified, ptr->data, nullptr);
UI_but_flag_enable(but, UI_BUT_UPDATE_DELAY);
}
}
}
#else
UNUSED_VARS(layout, ptr);
#endif
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Event Icon Template
* \{ */

View File

@@ -432,20 +432,6 @@ static void node_shader_buts_tex_environment(uiLayout *layout, bContext *C, Poin
node_buts_image_user(layout, C, &iuserptr, &imaptr, &iuserptr, false, true);
}
static void node_shader_buts_virtual_monitor(uiLayout *layout, bContext *C, PointerRNA *ptr)
{
uiTemplateID(layout,
C,
ptr,
"camera",
nullptr,
nullptr,
nullptr,
UI_TEMPLATE_ID_FILTER_ALL,
false,
nullptr);
}
static void node_shader_buts_tex_environment_ex(uiLayout *layout, bContext *C, PointerRNA *ptr)
{
PointerRNA iuserptr = RNA_pointer_get(ptr, "image_user");
@@ -513,9 +499,6 @@ static void node_shader_set_butfunc(bNodeType *ntype)
ntype->draw_buttons = node_shader_buts_tex_environment;
ntype->draw_buttons_ex = node_shader_buts_tex_environment_ex;
break;
case SH_NODE_VIRTUAL_MONITOR:
ntype->draw_buttons = node_shader_buts_virtual_monitor;
break;
case SH_NODE_DISPLACEMENT:
case SH_NODE_VECTOR_DISPLACEMENT:
ntype->draw_buttons = node_shader_buts_displacement;

View File

@@ -7,7 +7,6 @@
#include <cmath>
#include "BLI_float4x4.hh"
#include "BLI_jitter_2d.h"
#include "BLI_listbase.h"
#include "BLI_math.h"
@@ -16,7 +15,6 @@
#include "BLI_string.h"
#include "BLI_string_utils.h"
#include "BLI_threads.h"
#include "BLI_vector.hh"
#include "BKE_armature.h"
#include "BKE_camera.h"
@@ -28,7 +26,6 @@
#include "BKE_key.h"
#include "BKE_layer.h"
#include "BKE_main.h"
#include "BKE_node.h"
#include "BKE_object.h"
#include "BKE_paint.h"
#include "BKE_scene.h"
@@ -43,7 +40,6 @@
#include "DNA_brush_types.h"
#include "DNA_camera_types.h"
#include "DNA_key_types.h"
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
#include "DNA_object_types.h"
#include "DNA_view3d_types.h"
@@ -65,7 +61,6 @@
#include "GPU_batch.h"
#include "GPU_batch_presets.h"
#include "GPU_debug.h"
#include "GPU_framebuffer.h"
#include "GPU_immediate.h"
#include "GPU_immediate_util.h"
@@ -92,9 +87,6 @@
#include "view3d_intern.h" /* own include */
using blender::float4;
using blender::float4x4;
using blender::int2;
using blender::Vector;
#define M_GOLDEN_RATIO_CONJUGATE 0.618033988749895f
@@ -1543,120 +1535,14 @@ void view3d_draw_region_info(const bContext *C, ARegion *region)
/** \name Draw Viewport Contents
* \{ */
static void view3d_virtual_camera_update(
Scene *scene, Depsgraph *depsgraph, View3D *v3d, ARegion *region, Object *object)
{
BLI_assert(object->type == OB_CAMERA);
int2 resolution(1920 / 2, 1080 / 2);
RegionView3D *old_rv3d = static_cast<RegionView3D *>(region->regiondata);
RegionView3D rv3d;
memcpy(&rv3d, old_rv3d, sizeof(RegionView3D));
region->regiondata = &rv3d;
Object *old_camera = v3d->camera;
v3d->camera = object;
rv3d.persp = RV3D_CAMOB;
Camera *camera = static_cast<Camera *>(object->data);
if (camera->runtime.virtual_monitor_offscreen == nullptr) {
camera->runtime.virtual_monitor_offscreen = GPU_offscreen_create(
UNPACK2(resolution), true, GPU_RGBA16F, nullptr);
}
float4x4 winmat;
// TODO: Multi view support?
CameraParams params;
BKE_camera_params_init(&params);
/* fallback for non camera objects */
params.clip_start = v3d->clip_start;
params.clip_end = v3d->clip_end;
BKE_camera_params_from_object(&params, object);
BKE_camera_params_compute_viewplane(&params, UNPACK2(resolution), scene->r.xasp, scene->r.yasp);
BKE_camera_params_compute_matrix(&params);
copy_m4_m4(winmat.ptr(), params.winmat);
GPUOffScreen *offscreen = camera->runtime.virtual_monitor_offscreen;
GPU_offscreen_bind(offscreen, true);
ED_view3d_draw_offscreen(depsgraph,
scene,
OB_MATERIAL,
v3d,
region,
UNPACK2(resolution),
nullptr,
winmat.ptr(),
false,
true,
nullptr,
false,
true,
true,
offscreen,
nullptr);
GPU_offscreen_unbind(offscreen, true);
camera->runtime.offscreen_color_texture = GPU_offscreen_color_texture(
camera->runtime.virtual_monitor_offscreen);
v3d->camera = old_camera;
region->regiondata = old_rv3d;
}
static void view3d_draw_virtual_camera(Scene *scene,
Depsgraph *depsgraph,
View3D *v3d,
ARegion *region)
{
/* TODO: Bad call! */
Main *bmain = DEG_get_bmain(depsgraph);
/* Collect all cameras in the scene that is used inside a virtual monitor. This should be
* optimized by a tagging system. There are far more materials then cameras in a typical scene.
*/
Vector<Object *> virtual_cameras;
LISTBASE_FOREACH (Material *, material, &bmain->materials) {
if (!material->nodetree) {
continue;
}
LISTBASE_FOREACH (bNode *, node, &material->nodetree->nodes) {
if (node->type != SH_NODE_VIRTUAL_MONITOR) {
continue;
}
Object *ob = static_cast<Object *>(static_cast<void *>(node->id));
if (ob == nullptr || ob->type != OB_CAMERA) {
continue;
}
virtual_cameras.append(ob);
}
}
if (virtual_cameras.is_empty()) {
/* No cameras used as virtual monitor, so skip updating. */
return;
}
GPU_debug_group_begin("VirtualCameras");
for (Object *object : virtual_cameras) {
view3d_virtual_camera_update(scene, depsgraph, v3d, region, object);
}
GPU_debug_group_end();
}
static void view3d_draw_view(const bContext *C, ARegion *region)
{
Scene *scene = CTX_data_scene(C);
Depsgraph *depsgraph = CTX_data_expect_evaluated_depsgraph(C);
View3D *v3d = CTX_wm_view3d(C);
view3d_draw_virtual_camera(scene, depsgraph, v3d, region);
ED_view3d_draw_setup_view(CTX_wm_manager(C),
CTX_wm_window(C),
depsgraph,
scene,
CTX_data_expect_evaluated_depsgraph(C),
CTX_data_scene(C),
region,
v3d,
CTX_wm_view3d(C),
nullptr,
nullptr,
nullptr);
@@ -1754,7 +1640,6 @@ void ED_view3d_draw_offscreen(Depsgraph *depsgraph,
const char *viewname,
const bool do_color_management,
const bool restore_rv3d_mats,
const bool is_virtual_camera,
GPUOffScreen *ofs,
GPUViewport *viewport)
{
@@ -1830,7 +1715,6 @@ void ED_view3d_draw_offscreen(Depsgraph *depsgraph,
is_image_render,
draw_background,
do_color_management,
is_virtual_camera,
ofs,
viewport);
DRW_cache_free_old_subdiv();
@@ -1946,8 +1830,6 @@ void ED_view3d_draw_offscreen_simple(Depsgraph *depsgraph,
/* Actually not used since we pass in the projection matrix. */
v3d.lens = 0;
view3d_draw_virtual_camera(scene, depsgraph, &v3d, &ar);
ED_view3d_draw_offscreen(depsgraph,
scene,
drawtype,
@@ -1962,7 +1844,6 @@ void ED_view3d_draw_offscreen_simple(Depsgraph *depsgraph,
viewname,
do_color_management,
true,
false,
ofs,
viewport);
}
@@ -2086,7 +1967,6 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Depsgraph *depsgraph,
viewname,
do_color_management,
restore_rv3d_mats,
false,
ofs,
nullptr);

View File

@@ -136,21 +136,6 @@ void ED_view3d_viewcontext_init_object(ViewContext *vc, Object *obact)
}
}
bool ED_view3d_object_deselect_all_except(const Scene *scene, ViewLayer *view_layer, Base *b)
{
bool changed = false;
BKE_view_layer_synced_ensure(scene, view_layer);
LISTBASE_FOREACH (Base *, base, BKE_view_layer_object_bases_get(view_layer)) {
if (base->flag & BASE_SELECTED) {
if (b != base) {
ED_object_base_select(base, BA_DESELECT);
changed = true;
}
}
}
return changed;
}
/** \} */
/* -------------------------------------------------------------------- */
@@ -172,6 +157,22 @@ static bool object_deselect_all_visible(const Scene *scene, ViewLayer *view_laye
return changed;
}
/* deselect all except b */
static bool object_deselect_all_except(const Scene *scene, ViewLayer *view_layer, Base *b)
{
bool changed = false;
BKE_view_layer_synced_ensure(scene, view_layer);
LISTBASE_FOREACH (Base *, base, BKE_view_layer_object_bases_get(view_layer)) {
if (base->flag & BASE_SELECTED) {
if (b != base) {
ED_object_base_select(base, BA_DESELECT);
changed = true;
}
}
}
return changed;
}
/** \} */
/* -------------------------------------------------------------------- */
@@ -1528,7 +1529,7 @@ static int object_select_menu_exec(bContext *C, wmOperator *op)
}
}
else {
ED_view3d_object_deselect_all_except(scene, view_layer, basact);
object_deselect_all_except(scene, view_layer, basact);
ED_object_base_select(basact, BA_SELECT);
changed = true;
}
@@ -2796,7 +2797,7 @@ static bool ed_object_select_pick(bContext *C,
else if (found || params->deselect_all) {
/* Deselect everything. */
/* `basact` may be nullptr. */
if (ED_view3d_object_deselect_all_except(scene, view_layer, basact)) {
if (object_deselect_all_except(scene, view_layer, basact)) {
changed_object = true;
}
}
@@ -2808,7 +2809,7 @@ static bool ed_object_select_pick(bContext *C,
if (vc.obedit) {
/* Only do the select (use for setting vertex parents & hooks).
* In edit-mode do not activate. */
ED_view3d_object_deselect_all_except(scene, view_layer, basact);
object_deselect_all_except(scene, view_layer, basact);
ED_object_base_select(basact, BA_SELECT);
changed_object = true;
@@ -2839,7 +2840,7 @@ static bool ed_object_select_pick(bContext *C,
break;
}
case SEL_OP_SET: {
ED_view3d_object_deselect_all_except(scene, view_layer, basact);
object_deselect_all_except(scene, view_layer, basact);
ED_object_base_select(basact, BA_SELECT);
break;
}

View File

@@ -1157,8 +1157,10 @@ void transform_convert_clip_mirror_modifier_apply(TransDataContainer *tc)
}
}
void ED_transform_animrecord_check_state(Scene *scene, wmTimer *animtimer, struct ID *id)
void animrecord_check_state(TransInfo *t, struct ID *id)
{
Scene *scene = t->scene;
wmTimer *animtimer = t->animtimer;
ScreenAnimData *sad = (animtimer) ? animtimer->customdata : NULL;
/* sanity checks */

View File

@@ -105,6 +105,10 @@ char transform_convert_frame_side_dir_get(TransInfo *t, float cframe);
*/
bool FrameOnMouseSide(char side, float frame, float cframe);
void transform_convert_clip_mirror_modifier_apply(TransDataContainer *tc);
/**
* For the realtime animation recording feature, handle overlapping data.
*/
void animrecord_check_state(TransInfo *t, struct ID *id);
/* transform_convert_action.c */

View File

@@ -1472,7 +1472,7 @@ static void recalcData_pose(TransInfo *t)
/* XXX: this currently doesn't work, since flags aren't set yet! */
int targetless_ik = (t->flag & T_AUTOIK);
ED_transform_animrecord_check_state(t->scene, t->animtimer, &ob->id);
animrecord_check_state(t, &ob->id);
autokeyframe_pose(t->context, t->scene, ob, t->mode, targetless_ik);
}

View File

@@ -729,7 +729,7 @@ static void createTransObject(bContext *C, TransInfo *t)
* \note Context may not always be available,
* so must check before using it as it's a luxury for a few cases.
*/
void ED_transform_autokeyframe_object(
static void autokeyframe_object(
bContext *C, Scene *scene, ViewLayer *view_layer, Object *ob, int tmode)
{
Main *bmain = CTX_data_main(C);
@@ -853,7 +853,7 @@ void ED_transform_autokeyframe_object(
/* Return if we need to update motion paths, only if they already exist,
* and we will insert a keyframe at the end of transform. */
bool ED_transform_motionpath_need_update_object(Scene *scene, Object *ob)
static bool motionpath_need_update_object(Scene *scene, Object *ob)
{
/* XXX: there's potential here for problems with unkeyed rotations/scale,
* but for now (until proper data-locality for baking operations),
@@ -897,11 +897,11 @@ static void recalcData_objects(TransInfo *t)
/* TODO: autokeyframe calls need some setting to specify to add samples
* (FPoints) instead of keyframes? */
if ((t->animtimer) && IS_AUTOKEY_ON(t->scene)) {
ED_transform_animrecord_check_state(t->scene, t->animtimer, &ob->id);
ED_transform_autokeyframe_object(t->context, t->scene, t->view_layer, ob, t->mode);
animrecord_check_state(t, &ob->id);
autokeyframe_object(t->context, t->scene, t->view_layer, ob, t->mode);
}
motionpath_update |= ED_transform_motionpath_need_update_object(t->scene, ob);
motionpath_update |= motionpath_need_update_object(t->scene, ob);
/* sets recalc flags fully, instead of flushing existing ones
* otherwise proxies don't function correctly
@@ -974,10 +974,10 @@ static void special_aftertrans_update__object(bContext *C, TransInfo *t)
/* Set auto-key if necessary. */
if (!canceled) {
ED_transform_autokeyframe_object(C, t->scene, t->view_layer, ob, t->mode);
autokeyframe_object(C, t->scene, t->view_layer, ob, t->mode);
}
motionpath_update |= ED_transform_motionpath_need_update_object(t->scene, ob);
motionpath_update |= motionpath_need_update_object(t->scene, ob);
/* Restore rigid body transform. */
if (ob->rigidbody_object && canceled) {

View File

@@ -239,7 +239,7 @@ static void recalcData_sequencer_image(TransInfo *t)
}
if ((t->animtimer) && IS_AUTOKEY_ON(t->scene)) {
ED_transform_animrecord_check_state(t->scene, t->animtimer, &t->scene->id);
animrecord_check_state(t, &t->scene->id);
autokeyframe_sequencer_image(t->context, t->scene, transform, t->mode);
}

View File

@@ -471,7 +471,6 @@ set(GLSL_SRC
shaders/material/gpu_shader_material_vector_rotate.glsl
shaders/material/gpu_shader_material_velvet.glsl
shaders/material/gpu_shader_material_vertex_color.glsl
shaders/material/gpu_shader_material_virtual_camera.glsl
shaders/material/gpu_shader_material_volume_absorption.glsl
shaders/material/gpu_shader_material_volume_principled.glsl
shaders/material/gpu_shader_material_volume_scatter.glsl

View File

@@ -35,7 +35,6 @@ struct Material;
struct Scene;
struct bNode;
struct bNodeTree;
struct Camera;
typedef struct GPUMaterial GPUMaterial;
typedef struct GPUNode GPUNode;
@@ -83,8 +82,6 @@ typedef enum eGPUMaterialFlag {
GPU_MATFLAG_OBJECT_INFO = (1 << 10),
GPU_MATFLAG_AOV = (1 << 11),
GPU_MATFLAG_VIRTUAL_MONITOR = (1 << 12),
GPU_MATFLAG_BARYCENTRIC = (1 << 20),
/* Optimization to only add the branches of the principled shader that are necessary. */
@@ -181,9 +178,6 @@ GPUNodeLink *GPU_image_sky(GPUMaterial *mat,
const float *pixels,
float *layer,
eGPUSamplerState sampler_state);
GPUNodeLink *GPU_image_camera(GPUMaterial *mat,
struct Camera *camera,
eGPUSamplerState sampler_state);
GPUNodeLink *GPU_color_band(GPUMaterial *mat, int size, float *pixels, float *row);
/**
@@ -328,7 +322,6 @@ typedef struct GPUMaterialTexture {
bool iuser_available;
struct GPUTexture **colorband;
struct GPUTexture **sky;
struct GPUTexture **camera;
char sampler_name[32]; /* Name of sampler in GLSL. */
char tiled_mapping_name[32]; /* Name of tile mapping sampler in GLSL. */
int users;

View File

@@ -400,10 +400,6 @@ void GPUCodegen::generate_resources()
const char *name = info.name_buffer.append_sampler_name(tex->sampler_name);
info.sampler(0, ImageType::FLOAT_2D_ARRAY, name, Frequency::BATCH);
}
else if (tex->camera && tex->camera[0]) {
const char *name = info.name_buffer.append_sampler_name(tex->sampler_name);
info.sampler(slot++, ImageType::FLOAT_2D, name, Frequency::BATCH);
}
else if (tex->tiled_mapping_name[0] != '\0') {
const char *name = info.name_buffer.append_sampler_name(tex->sampler_name);
info.sampler(slot++, ImageType::FLOAT_2D_ARRAY, name, Frequency::BATCH);

View File

@@ -12,7 +12,6 @@
#include "MEM_guardedalloc.h"
#include "DNA_camera_types.h"
#include "DNA_node_types.h"
#include "BLI_ghash.h"
@@ -20,7 +19,6 @@
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "GPU_framebuffer.h"
#include "GPU_texture.h"
#include "GPU_vertex_format.h"
@@ -116,7 +114,6 @@ static void gpu_node_input_link(GPUNode *node, GPUNodeLink *link, const eGPUType
link->users++;
break;
case GPU_NODE_LINK_IMAGE:
case GPU_NODE_LINK_IMAGE_CAMERA:
case GPU_NODE_LINK_IMAGE_TILED:
case GPU_NODE_LINK_IMAGE_SKY:
case GPU_NODE_LINK_COLORBAND:
@@ -479,7 +476,6 @@ static GPUMaterialTexture *gpu_node_graph_add_texture(GPUNodeGraph *graph,
ImageUser *iuser,
struct GPUTexture **colorband,
struct GPUTexture **sky,
struct GPUTexture **camera,
GPUNodeLinkType link_type,
eGPUSamplerState sampler_state)
{
@@ -488,7 +484,7 @@ static GPUMaterialTexture *gpu_node_graph_add_texture(GPUNodeGraph *graph,
GPUMaterialTexture *tex = static_cast<GPUMaterialTexture *>(graph->textures.first);
for (; tex; tex = tex->next) {
if (tex->ima == ima && tex->colorband == colorband && tex->sky == sky &&
tex->camera == camera && tex->sampler_state == sampler_state) {
tex->sampler_state == sampler_state) {
break;
}
num_textures++;
@@ -504,7 +500,6 @@ static GPUMaterialTexture *gpu_node_graph_add_texture(GPUNodeGraph *graph,
}
tex->colorband = colorband;
tex->sky = sky;
tex->camera = camera;
tex->sampler_state = sampler_state;
BLI_snprintf(tex->sampler_name, sizeof(tex->sampler_name), "samp%d", num_textures);
if (ELEM(link_type, GPU_NODE_LINK_IMAGE_TILED, GPU_NODE_LINK_IMAGE_TILED_MAPPING)) {
@@ -636,24 +631,7 @@ GPUNodeLink *GPU_image(GPUMaterial *mat,
GPUNodeLink *link = gpu_node_link_create();
link->link_type = GPU_NODE_LINK_IMAGE;
link->texture = gpu_node_graph_add_texture(
graph, ima, iuser, nullptr, nullptr, nullptr, link->link_type, sampler_state);
return link;
}
GPUNodeLink *GPU_image_camera(GPUMaterial *mat, Camera *camera, eGPUSamplerState sampler_state)
{
GPUNodeGraph *graph = gpu_material_node_graph(mat);
GPUNodeLink *link = gpu_node_link_create();
link->link_type = GPU_NODE_LINK_IMAGE_CAMERA;
link->texture = gpu_node_graph_add_texture(graph,
nullptr,
nullptr,
nullptr,
nullptr,
&camera->runtime.offscreen_color_texture,
link->link_type,
sampler_state);
GPU_material_flag_set(mat, GPU_MATFLAG_VIRTUAL_MONITOR);
graph, ima, iuser, nullptr, nullptr, link->link_type, sampler_state);
return link;
}
@@ -670,7 +648,7 @@ GPUNodeLink *GPU_image_sky(GPUMaterial *mat,
GPUNodeLink *link = gpu_node_link_create();
link->link_type = GPU_NODE_LINK_IMAGE_SKY;
link->texture = gpu_node_graph_add_texture(
graph, nullptr, nullptr, nullptr, sky, nullptr, link->link_type, sampler_state);
graph, nullptr, nullptr, nullptr, sky, link->link_type, sampler_state);
return link;
}
@@ -683,7 +661,7 @@ GPUNodeLink *GPU_image_tiled(GPUMaterial *mat,
GPUNodeLink *link = gpu_node_link_create();
link->link_type = GPU_NODE_LINK_IMAGE_TILED;
link->texture = gpu_node_graph_add_texture(
graph, ima, iuser, nullptr, nullptr, nullptr, link->link_type, sampler_state);
graph, ima, iuser, nullptr, nullptr, link->link_type, sampler_state);
return link;
}
@@ -693,7 +671,7 @@ GPUNodeLink *GPU_image_tiled_mapping(GPUMaterial *mat, Image *ima, ImageUser *iu
GPUNodeLink *link = gpu_node_link_create();
link->link_type = GPU_NODE_LINK_IMAGE_TILED_MAPPING;
link->texture = gpu_node_graph_add_texture(
graph, ima, iuser, nullptr, nullptr, nullptr, link->link_type, GPU_SAMPLER_MAX);
graph, ima, iuser, nullptr, nullptr, link->link_type, GPU_SAMPLER_MAX);
return link;
}
@@ -706,7 +684,7 @@ GPUNodeLink *GPU_color_band(GPUMaterial *mat, int size, float *pixels, float *ro
GPUNodeLink *link = gpu_node_link_create();
link->link_type = GPU_NODE_LINK_COLORBAND;
link->texture = gpu_node_graph_add_texture(
graph, nullptr, nullptr, colorband, nullptr, nullptr, link->link_type, GPU_SAMPLER_MAX);
graph, nullptr, nullptr, colorband, nullptr, link->link_type, GPU_SAMPLER_MAX);
return link;
}

View File

@@ -50,7 +50,6 @@ typedef enum {
GPU_NODE_LINK_IMAGE_TILED,
GPU_NODE_LINK_IMAGE_TILED_MAPPING,
GPU_NODE_LINK_IMAGE_SKY,
GPU_NODE_LINK_IMAGE_CAMERA,
GPU_NODE_LINK_OUTPUT,
GPU_NODE_LINK_UNIFORM,
GPU_NODE_LINK_DIFFERENTIATE_FLOAT_FN,

View File

@@ -1,11 +0,0 @@
void node_virtual_camera_empty(vec3 co, out vec4 color, out float alpha)
{
color = vec4(0.0);
alpha = 0.0;
}
void node_virtual_camera(vec3 co, sampler2D ima, out vec4 color, out float alpha)
{
color = texture(ima, co.xy);
alpha = color.a;
}

View File

@@ -71,10 +71,6 @@ typedef struct Camera_Runtime {
float drw_depth[2];
float drw_focusmat[4][4];
float drw_normalmat[4][4];
struct GPUOffScreen *virtual_monitor_offscreen;
/* Local reference to not owning gpu texture. Used to have a reliable pointer to the texture. */
struct GPUTexture *offscreen_color_texture;
} Camera_Runtime;
typedef struct Camera {

View File

@@ -30,9 +30,7 @@ typedef struct XrSessionSettings {
char draw_flags;
/** Draw style for controller visualization. */
char controller_draw_style;
/** The eye (view) used for 3D->2D projection when simulating mouse. */
char projection_eye;
char _pad2;
char _pad2[2];
/** Clipping distance. */
float clip_start, clip_end;
@@ -42,22 +40,11 @@ typedef struct XrSessionSettings {
/** Object type settings to apply to VR view (unlike shading, not shared with window 3D-View). */
int object_type_exclude_viewport;
int object_type_exclude_select;
ListBase actionmaps; /* XrActionMap */
short act_actionmap;
short sel_actionmap;
char _pad3[2];
/** Objects to bind to headset/controller poses. */
short sel_mocap_object;
ListBase mocap_objects; /* #XrMotionCaptureObject */
} XrSessionSettings;
typedef enum eXrSessionFlag {
XR_SESSION_USE_POSITION_TRACKING = (1 << 0),
XR_SESSION_USE_ABSOLUTE_TRACKING = (1 << 1),
XR_SESSION_ENABLE_VIVE_TRACKER_EXTENSION =
(1 << 2), /* See #GHOST_kXrContextEnableViveTrackerExtension. */
} eXrSessionFlag;
typedef enum eXRSessionBasePoseType {
@@ -73,11 +60,6 @@ typedef enum eXrSessionControllerDrawStyle {
XR_CONTROLLER_DRAW_LIGHT_RAY = 3,
} eXrSessionControllerDrawStyle;
typedef enum eXrSessionEye {
XR_EYE_LEFT = 0,
XR_EYE_RIGHT = 1,
} eXrSessionEye;
/** XR action type. Enum values match those in GHOST_XrActionType enum for consistency. */
typedef enum eXrActionType {
XR_BOOLEAN_INPUT = 1,
@@ -97,8 +79,6 @@ typedef enum eXrOpFlag {
typedef enum eXrActionFlag {
/** Action depends on two sub-action paths (i.e. two-handed/bi-manual action). */
XR_ACTION_BIMANUAL = (1 << 0),
/** Whether to use controller inputs to simulate mouse inputs. */
XR_ACTION_SIMULATE_MOUSE = (1 << 1),
} eXrActionFlag;
typedef enum eXrHapticFlag {
@@ -128,15 +108,8 @@ typedef enum eXrPoseFlag {
/* Pose represents controller grip/aim. */
XR_POSE_GRIP = (1 << 0),
XR_POSE_AIM = (1 << 1),
/* Pose represents VR tracker. */
XR_POSE_TRACKER = (1 << 2),
} eXrPoseFlag;
typedef enum eXrMotionCaptureFlag {
XR_MOCAP_OBJECT_ENABLE = (1 << 0),
XR_MOCAP_OBJECT_AUTOKEY = (1 << 1),
} eXrMotionCaptureFlag;
/**
* The following user and component path lengths are dependent on OpenXR's XR_MAX_PATH_LENGTH
* (256). A user path will be combined with a component path to identify an action binding, and
@@ -168,8 +141,7 @@ typedef struct XrActionMapBinding {
/** Input threshold/region. */
float float_threshold;
short axis_flag; /* eXrAxisFlag */
short sel_component_path;
char _pad[2];
/** Pose action properties. */
float pose_location[3];
@@ -183,16 +155,6 @@ typedef struct XrUserPath {
char path[64]; /* XR_MAX_USER_PATH_LENGTH */
} XrUserPath;
typedef struct XrSimulateMouseParams {
short press_type; /* wmEvent.type */
short press_val; /* wmEvent.val */
short hold_type;
short hold_val;
short release_type;
short release_val;
short _pad[2];
} XrSimulateMouseParams;
typedef struct XrActionMapItem {
struct XrActionMapItem *next, *prev;
@@ -212,9 +174,6 @@ typedef struct XrActionMapItem {
/** RNA pointer to access properties. */
struct PointerRNA *op_properties_ptr;
/** Mouse simulation. */
XrSimulateMouseParams simulate;
short op_flag; /* eXrOpFlag */
short action_flag; /* eXrActionFlag */
short haptic_flag; /* eXrHapticFlag */
@@ -228,8 +187,8 @@ typedef struct XrActionMapItem {
float haptic_frequency;
float haptic_amplitude;
short sel_user_path;
short sel_binding;
short selbinding;
char _pad3[2];
ListBase bindings; /* XrActionMapBinding */
} XrActionMapItem;
@@ -242,30 +201,12 @@ typedef struct XrActionMap {
char name[64]; /* MAX_NAME */
ListBase items; /* XrActionMapItem */
short sel_item;
short selitem;
char _pad[6];
} XrActionMap;
/* -------------------------------------------------------------------- */
typedef struct XrMotionCaptureObject {
struct XrMotionCaptureObject *next, *prev;
/** Object to bind to a VR device. Used as struct identifier. */
Object *ob;
/** OpenXR user path, identifies the target headset/controller. */
char user_path[64]; /* XR_MAX_USER_PATH_LENGTH */
/** Location/rotation offsets. */
float location_offset[3];
float rotation_offset[3];
short flag; /* eXrMotionCaptureFlag */
char _pad[6];
} XrMotionCaptureObject;
/* -------------------------------------------------------------------- */
#ifdef __cplusplus
}
#endif

View File

@@ -5857,22 +5857,6 @@ static void def_sh_tex_coord(StructRNA *srna)
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
}
static void def_sh_virtual_monitor(StructRNA *srna)
{
PropertyRNA *prop;
prop = RNA_def_property(srna, "camera", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_pointer_sdna(prop, NULL, "id");
RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Camera_object_poll");
RNA_def_property_struct_type(prop, "Object");
RNA_def_property_ui_text(prop, "Camera", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
/* TODO: add poll function show all cameras in active scene and view layer, excluding scene
* camera. */
}
static void def_sh_vect_transform(StructRNA *srna)
{
static const EnumPropertyItem prop_vect_type_items[] = {

View File

@@ -1797,11 +1797,6 @@ void RNA_api_ui_layout(StructRNA *srna)
parm = RNA_def_pointer(func, "item", "KeyMapItem", "", "");
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
func = RNA_def_function(
srna, "template_xr_actionmap_item_properties", "uiTemplateXrActionmapItemProperties");
parm = RNA_def_pointer(func, "item", "XrActionMapItem", "", "");
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
func = RNA_def_function(srna, "template_component_menu", "uiTemplateComponentMenu");
RNA_def_function_ui_description(func, "Item. Display expanded property in a popup menu");
parm = RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take property");

View File

@@ -2836,53 +2836,6 @@ static void rna_def_keyconfig(BlenderRNA *brna)
RNA_api_keymapitem(srna);
}
# ifdef WITH_XR_OPENXR
/* Defined here instead of rna_xr.c to access event type/value enums. */
static void rna_def_xr_simulate_mouse_params(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
srna = RNA_def_struct(brna, "XrSimulateMouseParams", NULL);
RNA_def_struct_ui_text(srna,
"XR Mouse Simulation Parameters",
"Parameters for simulating mouse with VR controllers");
prop = RNA_def_property(srna, "press_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "press_type");
RNA_def_property_enum_items(prop, rna_enum_event_type_items);
RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_UI_EVENTS);
RNA_def_property_ui_text(prop, "Press Type", "Event type to simulate on VR action press");
prop = RNA_def_property(srna, "press_value", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "press_val");
RNA_def_property_enum_items(prop, rna_enum_event_value_items);
RNA_def_property_ui_text(prop, "Press Value", "Event value to simulate on VR action press");
prop = RNA_def_property(srna, "hold_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "hold_type");
RNA_def_property_enum_items(prop, rna_enum_event_type_items);
RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_UI_EVENTS);
RNA_def_property_ui_text(prop, "Hold Type", "Event type to simulate on VR action hold");
prop = RNA_def_property(srna, "hold_value", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "hold_val");
RNA_def_property_enum_items(prop, rna_enum_event_value_items);
RNA_def_property_ui_text(prop, "Hold Value", "Event value to simulate on VR action hold");
prop = RNA_def_property(srna, "release_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "release_type");
RNA_def_property_enum_items(prop, rna_enum_event_type_items);
RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_UI_EVENTS);
RNA_def_property_ui_text(prop, "Release Type", "Event type to simulate on VR action release");
prop = RNA_def_property(srna, "release_value", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "release_val");
RNA_def_property_enum_items(prop, rna_enum_event_value_items);
RNA_def_property_ui_text(prop, "Release Value", "Event value to simulate on VR action release");
}
# endif
void RNA_def_wm(BlenderRNA *brna)
{
rna_def_operator(brna);
@@ -2900,9 +2853,6 @@ void RNA_def_wm(BlenderRNA *brna)
rna_def_windowmanager(brna);
rna_def_keyconfig_prefs(brna);
rna_def_keyconfig(brna);
# ifdef WITH_XR_OPENXR
rna_def_xr_simulate_mouse_params(brna);
# endif
}
#endif /* RNA_RUNTIME */

File diff suppressed because it is too large Load Diff

View File

@@ -15,8 +15,6 @@ extern "C" {
extern struct bNodeTreeType *ntreeType_Shader;
void register_node_type_sh_virtual_camera(void);
void register_node_type_sh_custom_group(bNodeType *ntype);
struct bNodeTreeExec *ntreeShaderBeginExecTree(struct bNodeTree *ntree);

View File

@@ -123,7 +123,6 @@ DefNode(ShaderNode, SH_NODE_CURVE_FLOAT, def_float_curve, "CUR
DefNode(ShaderNode, SH_NODE_COMBINE_COLOR, def_sh_combsep_color, "COMBINE_COLOR", CombineColor, "Combine Color", "Create a color from individual components using multiple models")
DefNode(ShaderNode, SH_NODE_SEPARATE_COLOR, def_sh_combsep_color, "SEPARATE_COLOR", SeparateColor, "Separate Color", "Split a color into its individual components using multiple models")
DefNode(ShaderNode, SH_NODE_MIX, def_sh_mix, "MIX", Mix, "Mix", "Mix values by a factor")
DefNode(ShaderNode, SH_NODE_VIRTUAL_MONITOR, def_sh_virtual_monitor, "VIRTUAL_MONITOR", VirtualMonitor, "Virtual Monitor", "Use the feed from a virtual camera (has to be in the same scene and view layer)")
DefNode(CompositorNode, CMP_NODE_VIEWER, def_cmp_viewer, "VIEWER", Viewer, "Viewer", "" )
DefNode(CompositorNode, CMP_NODE_RGB, 0, "RGB", RGB, "RGB", "" )

View File

@@ -113,7 +113,6 @@ set(SRC
nodes/node_shader_vector_rotate.cc
nodes/node_shader_vector_transform.cc
nodes/node_shader_vertex_color.cc
nodes/node_shader_virtual_monitor.cc
nodes/node_shader_volume_absorption.cc
nodes/node_shader_volume_info.cc
nodes/node_shader_volume_principled.cc

View File

@@ -103,7 +103,6 @@ void register_shader_nodes()
register_node_type_sh_vector_displacement();
register_node_type_sh_vector_rotate();
register_node_type_sh_vertex_color();
register_node_type_sh_virtual_camera();
register_node_type_sh_volume_absorption();
register_node_type_sh_volume_info();
register_node_type_sh_volume_principled();

View File

@@ -102,7 +102,6 @@ void register_node_type_sh_vect_transform();
void register_node_type_sh_vector_displacement();
void register_node_type_sh_vector_rotate();
void register_node_type_sh_vertex_color();
void register_node_type_sh_virtual_camera();
void register_node_type_sh_volume_absorption();
void register_node_type_sh_volume_info();
void register_node_type_sh_volume_principled();

View File

@@ -1,52 +0,0 @@
/* SPDX-License-Identifier: GPL-2.0-or-later
* Copyright 2005 Blender Foundation. All rights reserved. */
#include "node_shader_util.hh"
#include "DNA_camera_types.h"
#include "DEG_depsgraph_query.h"
namespace blender::nodes::node_shader_virtual_monitor_cc {
static void sh_node_virtual_monitor_declare(NodeDeclarationBuilder &b)
{
b.add_input<decl::Vector>(N_("Vector")).implicit_field(implicit_field_inputs::position);
b.add_output<decl::Color>(N_("Color")).no_muted_links();
b.add_output<decl::Float>(N_("Alpha")).no_muted_links();
}
static int node_shader_gpu_virtual_monitor(GPUMaterial *mat,
bNode *node,
bNodeExecData * /*execdata*/,
GPUNodeStack *in,
GPUNodeStack *out)
{
Object *object = (Object *)node->id;
if (object == nullptr || object->type != OB_CAMERA) {
return GPU_stack_link(mat, node, "node_virtual_camera_empty", in, out);
}
Object *orig_object = DEG_get_original_object(object);
Camera *cam = static_cast<Camera *>(orig_object->data);
node_shader_gpu_default_tex_coord(mat, node, &in[0].link);
return GPU_stack_link(
mat, node, "node_virtual_camera", in, out, GPU_image_camera(mat, cam, GPU_SAMPLER_DEFAULT));
}
} // namespace blender::nodes::node_shader_virtual_monitor_cc
void register_node_type_sh_virtual_camera()
{
namespace file_ns = blender::nodes::node_shader_virtual_monitor_cc;
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_VIRTUAL_MONITOR, "Virtual Monitor", NODE_CLASS_INPUT);
ntype.declare = file_ns::sh_node_virtual_monitor_declare;
ntype.gpu_fn = file_ns::node_shader_gpu_virtual_monitor;
nodeRegisterType(&ntype);
}

View File

@@ -396,7 +396,6 @@ static PyObject *pygpu_offscreen_draw_view3d(BPyGPUOffScreen *self, PyObject *ar
"",
do_color_management,
true,
false,
self->ofs,
self->viewport);

View File

@@ -188,7 +188,6 @@ if(WITH_XR_OPENXR)
xr/intern/wm_xr_action.c
xr/intern/wm_xr_actionmap.c
xr/intern/wm_xr_draw.c
xr/intern/wm_xr_mocap.c
xr/intern/wm_xr_operators.c
xr/intern/wm_xr_session.c

View File

@@ -1701,12 +1701,6 @@ bool WM_xr_session_state_controller_aim_location_get(const wmXrData *xr,
bool WM_xr_session_state_controller_aim_rotation_get(const wmXrData *xr,
unsigned int subaction_idx,
float r_rotation[4]);
bool WM_xr_session_state_tracker_location_get(const wmXrData *xr,
const char *subaction_path,
float r_location[3]);
bool WM_xr_session_state_tracker_rotation_get(const wmXrData *xr,
const char *subaction_path,
float r_rotation[4]);
bool WM_xr_session_state_nav_location_get(const wmXrData *xr, float r_location[3]);
void WM_xr_session_state_nav_location_set(wmXrData *xr, const float location[3]);
bool WM_xr_session_state_nav_rotation_get(const wmXrData *xr, float r_rotation[4]);
@@ -1731,7 +1725,6 @@ bool WM_xr_action_create(wmXrData *xr,
const ListBase *user_paths,
struct wmOperatorType *ot,
struct IDProperty *op_properties,
const XrSimulateMouseParams *simulate,
const char *haptic_name,
const int64_t *haptic_duration,
const float *haptic_frequency,
@@ -1763,12 +1756,6 @@ bool WM_xr_controller_pose_actions_set(wmXrData *xr,
const char *action_set_name,
const char *grip_action_name,
const char *aim_action_name);
bool WM_xr_tracker_pose_action_add(wmXrData *xr,
const char *action_set_name,
const char *tracker_action_name);
bool WM_xr_tracker_pose_action_remove(wmXrData *xr,
const char *action_set_name,
const char *tracker_action_name);
/**
* XR action functions to be called post-XR session start.
@@ -1792,17 +1779,23 @@ void WM_xr_haptic_action_stop(wmXrData *xr,
/* wm_xr_actionmap.c */
XrActionMap *WM_xr_actionmap_new(XrSessionSettings *settings,
XrActionMap *WM_xr_actionmap_new(struct wmXrRuntimeData *runtime,
const char *name,
bool replace_existing);
/**
* Ensure unique name among all action maps.
*/
void WM_xr_actionmap_ensure_unique(XrSessionSettings *settings, XrActionMap *actionmap);
XrActionMap *WM_xr_actionmap_add_copy(XrSessionSettings *settings, XrActionMap *am_src);
bool WM_xr_actionmap_remove(XrSessionSettings *settings, XrActionMap *actionmap);
XrActionMap *WM_xr_actionmap_find(XrSessionSettings *settings, const char *name);
void WM_xr_actionmaps_free(XrSessionSettings *settings);
void WM_xr_actionmap_ensure_unique(struct wmXrRuntimeData *runtime, XrActionMap *actionmap);
XrActionMap *WM_xr_actionmap_add_copy(struct wmXrRuntimeData *runtime, XrActionMap *am_src);
bool WM_xr_actionmap_remove(struct wmXrRuntimeData *runtime, XrActionMap *actionmap);
XrActionMap *WM_xr_actionmap_find(struct wmXrRuntimeData *runtime, const char *name);
void WM_xr_actionmap_clear(XrActionMap *actionmap);
void WM_xr_actionmaps_clear(struct wmXrRuntimeData *runtime);
ListBase *WM_xr_actionmaps_get(struct wmXrRuntimeData *runtime);
short WM_xr_actionmap_active_index_get(const struct wmXrRuntimeData *runtime);
void WM_xr_actionmap_active_index_set(struct wmXrRuntimeData *runtime, short idx);
short WM_xr_actionmap_selected_index_get(const struct wmXrRuntimeData *runtime);
void WM_xr_actionmap_selected_index_set(struct wmXrRuntimeData *runtime, short idx);
XrActionMapItem *WM_xr_actionmap_item_new(XrActionMap *actionmap,
const char *name,
@@ -1831,18 +1824,6 @@ XrActionMapBinding *WM_xr_actionmap_binding_add_copy(XrActionMapItem *ami,
XrActionMapBinding *amb_src);
bool WM_xr_actionmap_binding_remove(XrActionMapItem *ami, XrActionMapBinding *amb);
XrActionMapBinding *WM_xr_actionmap_binding_find(XrActionMapItem *ami, const char *name);
/* wm_xr_mocap.c */
XrMotionCaptureObject *WM_xr_mocap_object_new(XrSessionSettings *settings, Object *ob);
void WM_xr_mocap_object_ensure_unique(XrSessionSettings *settings,
XrMotionCaptureObject *mocap_ob);
void WM_xr_mocap_object_remove(XrSessionSettings *settings, XrMotionCaptureObject *mocap_ob);
XrMotionCaptureObject *WM_xr_mocap_object_find(const XrSessionSettings *settings,
const Object *ob);
bool WM_xr_session_state_mocap_pose_get(const wmXrData *xr, XrMotionCaptureObject *mocap_ob);
void WM_xr_session_state_mocap_pose_set(wmXrData *xr, const XrMotionCaptureObject *mocap_ob);
#endif /* WITH_XR_OPENXR */
#ifdef __cplusplus

View File

@@ -841,11 +841,6 @@ typedef struct wmXrActionData {
/** Whether bimanual interaction is occurring. */
bool bimanual;
/** Whether the action is simulating mouse inputs. */
bool simulate_mouse;
/** Type and value for simulated mouse event. */
short simulate_type;
short simulate_val;
} wmXrActionData;
#endif

View File

@@ -936,16 +936,11 @@ void wm_gizmomap_handler_context_op(bContext *C, wmEventHandler_Op *handler)
bScreen *screen = CTX_wm_screen(C);
if (screen) {
ScrArea *area = NULL;
ScrArea *area;
if ((handler->context.area->flag & AREA_FLAG_OFFSCREEN) != 0) {
area = handler->context.area;
}
else {
for (area = screen->areabase.first; area; area = area->next) {
if (area == handler->context.area) {
break;
}
for (area = screen->areabase.first; area; area = area->next) {
if (area == handler->context.area) {
break;
}
}
if (area == NULL) {

View File

@@ -98,33 +98,6 @@ static void window_manager_foreach_id(ID *id, LibraryForeachIDData *data)
static void write_wm_xr_data(BlendWriter *writer, wmXrData *xr_data)
{
BKE_screen_view3d_shading_blend_write(writer, &xr_data->session_settings.shading);
LISTBASE_FOREACH (XrActionMap *, am, &xr_data->session_settings.actionmaps) {
BLO_write_struct(writer, XrActionMap, am);
LISTBASE_FOREACH (XrActionMapItem *, ami, &am->items) {
BLO_write_struct(writer, XrActionMapItem, ami);
if (ami->op[0] && ami->op_properties) {
IDP_BlendWrite(writer, ami->op_properties);
}
LISTBASE_FOREACH (XrUserPath *, user_path, &ami->user_paths) {
BLO_write_struct(writer, XrUserPath, user_path);
}
LISTBASE_FOREACH (XrActionMapBinding *, amb, &ami->bindings) {
BLO_write_struct(writer, XrActionMapBinding, amb);
LISTBASE_FOREACH (XrComponentPath *, component_path, &amb->component_paths) {
BLO_write_struct(writer, XrComponentPath, component_path);
}
}
}
}
LISTBASE_FOREACH (XrMotionCaptureObject *, mocap_ob, &xr_data->session_settings.mocap_objects) {
BLO_write_struct(writer, XrMotionCaptureObject, mocap_ob);
}
}
static void window_manager_blend_write(BlendWriter *writer, ID *id, const void *id_address)
@@ -153,36 +126,6 @@ static void window_manager_blend_write(BlendWriter *writer, ID *id, const void *
static void direct_link_wm_xr_data(BlendDataReader *reader, wmXrData *xr_data)
{
BKE_screen_view3d_shading_blend_read_data(reader, &xr_data->session_settings.shading);
BLO_read_list(reader, &xr_data->session_settings.actionmaps);
LISTBASE_FOREACH (XrActionMap *, am, &xr_data->session_settings.actionmaps) {
BLO_read_list(reader, &am->items);
LISTBASE_FOREACH (XrActionMapItem *, ami, &am->items) {
if (ami->op[0] && ami->op_properties) {
BLO_read_data_address(reader, &ami->op_properties);
IDP_BlendDataRead(reader, &ami->op_properties);
ami->op_properties_ptr = MEM_callocN(sizeof(PointerRNA), "wmOpItemPtr");
WM_operator_properties_create(ami->op_properties_ptr, ami->op);
ami->op_properties_ptr->data = ami->op_properties;
}
else {
ami->op_properties = NULL;
ami->op_properties_ptr = NULL;
}
BLO_read_list(reader, &ami->user_paths);
BLO_read_list(reader, &ami->bindings);
LISTBASE_FOREACH (XrActionMapBinding *, amb, &ami->bindings) {
BLO_read_list(reader, &amb->component_paths);
}
}
}
BLO_read_list(reader, &xr_data->session_settings.mocap_objects);
}
static void window_manager_blend_read_data(BlendDataReader *reader, ID *id)
@@ -277,10 +220,6 @@ static void window_manager_blend_read_data(BlendDataReader *reader, ID *id)
static void lib_link_wm_xr_data(BlendLibReader *reader, ID *parent_id, wmXrData *xr_data)
{
BLO_read_id_address(reader, parent_id->lib, &xr_data->session_settings.base_pose_object);
LISTBASE_FOREACH (XrMotionCaptureObject *, mocap_ob, &xr_data->session_settings.mocap_objects) {
BLO_read_id_address(reader, parent_id->lib, &mocap_ob->ob);
}
}
static void lib_link_workspace_instance_hook(BlendLibReader *reader,

View File

@@ -143,21 +143,6 @@ wmEvent *wm_event_add(wmWindow *win, const wmEvent *event_to_add)
return wm_event_add_ex(win, event_to_add, nullptr);
}
static void wm_event_simulate_eventstate(wmWindow *win, wmEvent *event)
{
/* Logic for setting previous value is documented on the #wmEvent struct,
* see #wm_event_add_ghostevent for the implementation of logic this follows. */
copy_v2_v2_int(win->eventstate->xy, event->xy);
if (event->type == MOUSEMOVE) {
copy_v2_v2_int(win->eventstate->prev_xy, win->eventstate->xy);
copy_v2_v2_int(event->prev_xy, win->eventstate->xy);
}
else if (ISKEYBOARD_OR_BUTTON(event->type) && ELEM(event->val, KM_PRESS, KM_RELEASE)) {
wm_event_state_update_and_click_set_ex(event, win->eventstate, ISKEYBOARD(event->type), false);
}
}
wmEvent *WM_event_add_simulate(wmWindow *win, const wmEvent *event_to_add)
{
if ((G.f & G_FLAG_EVENT_SIMULATE) == 0) {
@@ -166,8 +151,17 @@ wmEvent *WM_event_add_simulate(wmWindow *win, const wmEvent *event_to_add)
}
wmEvent *event = wm_event_add(win, event_to_add);
wm_event_simulate_eventstate(win, event);
/* Logic for setting previous value is documented on the #wmEvent struct,
* see #wm_event_add_ghostevent for the implementation of logic this follows. */
copy_v2_v2_int(win->eventstate->xy, event->xy);
if (event->type == MOUSEMOVE) {
copy_v2_v2_int(win->eventstate->prev_xy, win->eventstate->xy);
copy_v2_v2_int(event->prev_xy, win->eventstate->xy);
}
else if (ISKEYBOARD_OR_BUTTON(event->type)) {
wm_event_state_update_and_click_set_ex(event, win->eventstate, ISKEYBOARD(event->type), false);
}
return event;
}
@@ -2023,15 +2017,10 @@ static void wm_handler_op_context_get_if_valid(bContext *C,
else {
ScrArea *area = nullptr;
if ((handler->context.area->flag & AREA_FLAG_OFFSCREEN) != 0) {
area = handler->context.area;
}
else {
ED_screen_areas_iter (win, screen, area_iter) {
if (area_iter == handler->context.area) {
area = area_iter;
break;
}
ED_screen_areas_iter (win, screen, area_iter) {
if (area_iter == handler->context.area) {
area = area_iter;
break;
}
}
@@ -3739,22 +3728,13 @@ static void wm_event_handle_xrevent(bContext *C,
}
BLI_assert(WM_region_use_viewport(area, region)); /* For operators using GPU-based selection. */
/* Check for simulated mouse event. */
wmXrActionData *actiondata = static_cast<wmXrActionData *>(event->customdata);
const bool simulate_event = (actiondata->simulate_mouse &&
(actiondata->simulate_type != EVENT_NONE));
if (simulate_event) {
event->type = actiondata->simulate_type;
event->val = actiondata->simulate_val;
wm_event_simulate_eventstate(win, event);
}
CTX_wm_area_set(C, area);
CTX_wm_region_set(C, region);
int action = wm_handlers_do(C, event, &win->modalhandlers);
if ((action & WM_HANDLER_BREAK) == 0) {
wmXrActionData *actiondata = static_cast<wmXrActionData *>(event->customdata);
if (actiondata->ot->modal && event->val == KM_RELEASE) {
/* Don't execute modal operators on release. */
}
@@ -5752,7 +5732,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, void
}
#ifdef WITH_XR_OPENXR
void wm_event_add_xrevent(wmWindow *win, wmXrActionData *actiondata, short val, int mval[2])
void wm_event_add_xrevent(wmWindow *win, wmXrActionData *actiondata, short val)
{
BLI_assert(ELEM(val, KM_PRESS, KM_RELEASE));
@@ -5764,11 +5744,6 @@ void wm_event_add_xrevent(wmWindow *win, wmXrActionData *actiondata, short val,
event.customdata = actiondata;
event.customdata_free = true;
if (mval) {
copy_v2_v2_int(event.xy, mval);
copy_v2_v2_int(event.mval, mval);
}
wm_event_add(win, &event);
}
#endif /* WITH_XR_OPENXR */

View File

@@ -203,12 +203,6 @@ static void wm_window_match_init(bContext *C, ListBase *wmlist)
WM_msgbus_destroy(wm->message_bus);
wm->message_bus = NULL;
}
#ifdef WITH_XR_OPENXR
/* Free XR action maps and motion capture objects. */
WM_xr_actionmaps_free(&wm->xr.session_settings);
BLI_freelistN(&wm->xr.session_settings.mocap_objects);
#endif
}
BLI_listbase_clear(&G_MAIN->wm);

View File

@@ -1517,7 +1517,7 @@ void wm_window_process_events(const bContext *C)
#ifdef WITH_XR_OPENXR
/* XR events don't use the regular window queues. So here we don't only trigger
* processing/dispatching but also handling. */
has_event |= wm_xr_events_handle(C);
has_event |= wm_xr_events_handle(CTX_wm_manager(C));
#endif
GPU_render_end();

View File

@@ -145,10 +145,7 @@ void wm_event_do_handlers(bContext *C);
*/
void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, void *customdata);
#ifdef WITH_XR_OPENXR
void wm_event_add_xrevent(wmWindow *win,
struct wmXrActionData *actiondata,
short val,
int mval[2]);
void wm_event_add_xrevent(wmWindow *win, struct wmXrActionData *actiondata, short val);
#endif
void wm_event_do_depsgraph(bContext *C, bool is_after_open_file);

View File

@@ -8,9 +8,6 @@
* representation of the OpenXR runtime connection within the application.
*/
#include "BLI_listbase.h"
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_idprop.h"
#include "BKE_main.h"
@@ -90,9 +87,6 @@ bool wm_xr_init(wmWindowManager *wm)
create_info.context_flag |= GHOST_kXrContextGpuNVIDIA;
}
#endif
if ((wm->xr.session_settings.flag & XR_SESSION_ENABLE_VIVE_TRACKER_EXTENSION) != 0) {
create_info.context_flag |= GHOST_kXrContextEnableViveTrackerExtension;
}
if (!(context = GHOST_XrContextCreate(&create_info))) {
return false;
@@ -123,20 +117,16 @@ void wm_xr_exit(wmWindowManager *wm)
IDP_FreeProperty(wm->xr.session_settings.shading.prop);
wm->xr.session_settings.shading.prop = NULL;
}
WM_xr_actionmaps_free(&wm->xr.session_settings);
BLI_freelistN(&wm->xr.session_settings.mocap_objects);
}
bool wm_xr_events_handle(const bContext *C)
bool wm_xr_events_handle(wmWindowManager *wm)
{
wmWindowManager *wm = CTX_wm_manager(C);
if (wm->xr.runtime && wm->xr.runtime->context) {
GHOST_XrEventsHandle(wm->xr.runtime->context);
/* Process OpenXR action events. */
if (WM_xr_session_is_ready(&wm->xr)) {
wm_xr_session_actions_update(C);
wm_xr_session_actions_update(wm);
}
/* wm_window_process_events() uses the return value to determine if it can put the main thread
@@ -178,6 +168,7 @@ void wm_xr_runtime_data_free(wmXrRuntimeData **runtime)
(*runtime)->area = NULL;
}
wm_xr_session_data_free(&(*runtime)->session_state);
WM_xr_actionmaps_clear(*runtime);
GHOST_XrContextDestroy(context);
}

View File

@@ -43,7 +43,6 @@ static void action_set_destroy(void *val)
MEM_SAFE_FREE(action_set->name);
BLI_freelistN(&action_set->tracker_actions);
BLI_freelistN(&action_set->active_modal_actions);
BLI_freelistN(&action_set->active_haptic_actions);
@@ -60,7 +59,6 @@ static wmXrAction *action_create(const char *action_name,
const ListBase *user_paths,
wmOperatorType *ot,
IDProperty *op_properties,
const XrSimulateMouseParams *simulate,
const char *haptic_name,
const int64_t *haptic_duration,
const float *haptic_frequency,
@@ -120,11 +118,6 @@ static wmXrAction *action_create(const char *action_name,
action->ot = ot;
action->op_properties = op_properties;
if (simulate) {
BLI_assert(is_button_action);
memcpy(&action->simulate, simulate, sizeof(action->simulate));
}
if (haptic_name) {
BLI_assert(is_button_action);
action->haptic_name = MEM_mallocN(strlen(haptic_name) + 1, "XrAction_HapticName");
@@ -207,11 +200,6 @@ void WM_xr_action_set_destroy(wmXrData *xr, const char *action_set_name)
action_set->controller_grip_action = action_set->controller_aim_action = NULL;
}
if (!BLI_listbase_is_empty(&action_set->tracker_actions)) {
wm_xr_session_tracker_data_clear(session_state);
BLI_freelistN(&action_set->tracker_actions);
}
BLI_freelistN(&action_set->active_modal_actions);
BLI_freelistN(&action_set->active_haptic_actions);
@@ -228,7 +216,6 @@ bool WM_xr_action_create(wmXrData *xr,
const ListBase *user_paths,
wmOperatorType *ot,
IDProperty *op_properties,
const XrSimulateMouseParams *simulate,
const char *haptic_name,
const int64_t *haptic_duration,
const float *haptic_frequency,
@@ -246,7 +233,6 @@ bool WM_xr_action_create(wmXrData *xr,
user_paths,
ot,
op_properties,
simulate,
haptic_name,
haptic_duration,
haptic_frequency,
@@ -323,14 +309,6 @@ void WM_xr_action_destroy(wmXrData *xr, const char *action_set_name, const char
action_set->controller_grip_action = action_set->controller_aim_action = NULL;
}
LISTBASE_FOREACH (LinkData *, ld, &action_set->tracker_actions) {
wmXrAction *tracker_action = ld->data;
if (STREQ(tracker_action->name, action_name)) {
WM_xr_tracker_pose_action_remove(xr, action_set_name, action_name);
break;
}
}
LISTBASE_FOREACH (LinkData *, ld, &action_set->active_modal_actions) {
wmXrAction *active_modal_action = ld->data;
if (STREQ(active_modal_action->name, action_name)) {
@@ -438,7 +416,6 @@ bool WM_xr_active_action_set_set(wmXrData *xr, const char *action_set_name, bool
xr->runtime->session_state.active_action_set = action_set;
/* Update controller/tracker data. */
if (action_set->controller_grip_action && action_set->controller_aim_action) {
wm_xr_session_controller_data_populate(
action_set->controller_grip_action, action_set->controller_aim_action, xr);
@@ -447,13 +424,6 @@ bool WM_xr_active_action_set_set(wmXrData *xr, const char *action_set_name, bool
wm_xr_session_controller_data_clear(&xr->runtime->session_state);
}
if (!BLI_listbase_is_empty(&action_set->tracker_actions)) {
wm_xr_session_tracker_data_populate(&action_set->tracker_actions, xr);
}
else {
wm_xr_session_tracker_data_clear(&xr->runtime->session_state);
}
return true;
}
@@ -499,66 +469,6 @@ bool WM_xr_controller_pose_actions_set(wmXrData *xr,
return true;
}
bool WM_xr_tracker_pose_action_add(wmXrData *xr,
const char *action_set_name,
const char *tracker_action_name)
{
wmXrActionSet *action_set = action_set_find(xr, action_set_name);
if (!action_set) {
return false;
}
wmXrAction *tracker_action = action_find(xr, action_set_name, tracker_action_name);
if (!tracker_action) {
return false;
}
LinkData *ld = MEM_callocN(sizeof(*ld), __func__);
ld->data = tracker_action;
BLI_addtail(&action_set->tracker_actions, ld);
if (action_set == xr->runtime->session_state.active_action_set) {
wm_xr_session_tracker_data_populate(&action_set->tracker_actions, xr);
}
return true;
}
bool WM_xr_tracker_pose_action_remove(wmXrData *xr,
const char *action_set_name,
const char *tracker_action_name)
{
wmXrActionSet *action_set = action_set_find(xr, action_set_name);
if (!action_set) {
return false;
}
wmXrAction *tracker_action = action_find(xr, action_set_name, tracker_action_name);
if (!tracker_action) {
return false;
}
{
LinkData *ld = BLI_findptr(
&action_set->tracker_actions, tracker_action, offsetof(LinkData, data));
if (!ld) {
return false;
}
BLI_freelinkN(&action_set->tracker_actions, ld);
}
if (action_set == xr->runtime->session_state.active_action_set) {
if (BLI_listbase_is_empty(&action_set->tracker_actions)) {
wm_xr_session_tracker_data_clear(&xr->runtime->session_state);
}
else {
wm_xr_session_tracker_data_populate(&action_set->tracker_actions, xr);
}
}
return true;
}
bool WM_xr_action_state_get(const wmXrData *xr,
const char *action_set_name,
const char *action_name,

View File

@@ -127,7 +127,6 @@ XrActionMapBinding *WM_xr_actionmap_binding_add_copy(XrActionMapItem *ami,
static void wm_xr_actionmap_binding_clear(XrActionMapBinding *amb)
{
BLI_freelistN(&amb->component_paths);
amb->sel_component_path = 0;
}
bool WM_xr_actionmap_binding_remove(XrActionMapItem *ami, XrActionMapBinding *amb)
@@ -138,9 +137,9 @@ bool WM_xr_actionmap_binding_remove(XrActionMapItem *ami, XrActionMapBinding *am
wm_xr_actionmap_binding_clear(amb);
BLI_freelinkN(&ami->bindings, amb);
if (idx <= ami->sel_binding) {
if (--ami->sel_binding < 0) {
ami->sel_binding = 0;
if (idx <= ami->selbinding) {
if (--ami->selbinding < 0) {
ami->selbinding = 0;
}
}
@@ -193,12 +192,11 @@ static void wm_xr_actionmap_item_clear(XrActionMapItem *ami)
wm_xr_actionmap_binding_clear(amb);
}
BLI_freelistN(&ami->bindings);
ami->sel_binding = 0;
BLI_freelistN(&ami->user_paths);
ami->sel_user_path = 0;
ami->selbinding = 0;
wm_xr_actionmap_item_properties_free(ami);
BLI_freelistN(&ami->user_paths);
}
void WM_xr_actionmap_item_properties_update_ot(XrActionMapItem *ami)
@@ -315,12 +313,6 @@ static XrActionMapItem *wm_xr_actionmap_item_copy(XrActionMapItem *ami_src)
BLI_addtail(&ami_dst->bindings, amb_new);
}
BLI_listbase_clear(&ami_dst->user_paths);
LISTBASE_FOREACH (XrUserPath *, path, &ami_src->user_paths) {
XrUserPath *path_new = MEM_dupallocN(path);
BLI_addtail(&ami_dst->user_paths, path_new);
}
if (ami_dst->op_properties) {
ami_dst->op_properties_ptr = MEM_callocN(sizeof(PointerRNA), "wmOpItemPtr");
WM_operator_properties_create(ami_dst->op_properties_ptr, ami_dst->op);
@@ -332,6 +324,12 @@ static XrActionMapItem *wm_xr_actionmap_item_copy(XrActionMapItem *ami_src)
ami_dst->op_properties_ptr = NULL;
}
BLI_listbase_clear(&ami_dst->user_paths);
LISTBASE_FOREACH (XrUserPath *, path, &ami_src->user_paths) {
XrUserPath *path_new = MEM_dupallocN(path);
BLI_addtail(&ami_dst->user_paths, path_new);
}
return ami_dst;
}
@@ -354,9 +352,9 @@ bool WM_xr_actionmap_item_remove(XrActionMap *actionmap, XrActionMapItem *ami)
wm_xr_actionmap_item_clear(ami);
BLI_freelinkN(&actionmap->items, ami);
if (idx <= actionmap->sel_item) {
if (--actionmap->sel_item < 0) {
actionmap->sel_item = 0;
if (idx <= actionmap->selitem) {
if (--actionmap->selitem < 0) {
actionmap->selitem = 0;
}
}
@@ -384,49 +382,39 @@ XrActionMapItem *WM_xr_actionmap_item_find(XrActionMap *actionmap, const char *n
* List of XR action map items.
* \{ */
static void wm_xr_actionmap_clear(XrActionMap *actionmap)
XrActionMap *WM_xr_actionmap_new(wmXrRuntimeData *runtime, const char *name, bool replace_existing)
{
LISTBASE_FOREACH (XrActionMapItem *, ami, &actionmap->items) {
wm_xr_actionmap_item_clear(ami);
}
BLI_freelistN(&actionmap->items);
actionmap->sel_item = 0;
}
XrActionMap *WM_xr_actionmap_new(XrSessionSettings *settings,
const char *name,
bool replace_existing)
{
XrActionMap *am_prev = WM_xr_actionmap_find(settings, name);
XrActionMap *am_prev = WM_xr_actionmap_find(runtime, name);
if (am_prev && replace_existing) {
wm_xr_actionmap_clear(am_prev);
WM_xr_actionmap_clear(am_prev);
return am_prev;
}
XrActionMap *am = MEM_callocN(sizeof(struct XrActionMap), __func__);
BLI_strncpy(am->name, name, MAX_NAME);
if (am_prev) {
WM_xr_actionmap_ensure_unique(settings, am);
WM_xr_actionmap_ensure_unique(runtime, am);
}
BLI_addtail(&settings->actionmaps, am);
BLI_addtail(&runtime->actionmaps, am);
return am;
}
static XrActionMap *wm_xr_actionmap_find_except(XrSessionSettings *settings,
static XrActionMap *wm_xr_actionmap_find_except(wmXrRuntimeData *runtime,
const char *name,
const XrActionMap *am_except)
{
LISTBASE_FOREACH (XrActionMap *, am, &settings->actionmaps) {
LISTBASE_FOREACH (XrActionMap *, am, &runtime->actionmaps) {
if (STREQLEN(name, am->name, MAX_NAME) && (am != am_except)) {
return am;
}
}
return NULL;
}
void WM_xr_actionmap_ensure_unique(XrSessionSettings *settings, XrActionMap *actionmap)
void WM_xr_actionmap_ensure_unique(wmXrRuntimeData *runtime, XrActionMap *actionmap)
{
char name[MAX_NAME];
char *suffix;
@@ -437,7 +425,7 @@ void WM_xr_actionmap_ensure_unique(XrSessionSettings *settings, XrActionMap *act
baselen = BLI_strnlen(name, MAX_NAME);
suffix = &name[baselen];
while (wm_xr_actionmap_find_except(settings, name, actionmap)) {
while (wm_xr_actionmap_find_except(runtime, name, actionmap)) {
if ((baselen + 1) + (log10(++idx) + 1) > MAX_NAME) {
/* Use default base name. */
BLI_strncpy(name, WM_XR_ACTIONMAP_STR_DEFAULT, MAX_NAME);
@@ -467,33 +455,33 @@ static XrActionMap *wm_xr_actionmap_copy(XrActionMap *am_src)
return am_dst;
}
XrActionMap *WM_xr_actionmap_add_copy(XrSessionSettings *settings, XrActionMap *am_src)
XrActionMap *WM_xr_actionmap_add_copy(wmXrRuntimeData *runtime, XrActionMap *am_src)
{
XrActionMap *am_dst = wm_xr_actionmap_copy(am_src);
WM_xr_actionmap_ensure_unique(settings, am_dst);
WM_xr_actionmap_ensure_unique(runtime, am_dst);
BLI_addtail(&settings->actionmaps, am_dst);
BLI_addtail(&runtime->actionmaps, am_dst);
return am_dst;
}
bool WM_xr_actionmap_remove(XrSessionSettings *settings, XrActionMap *actionmap)
bool WM_xr_actionmap_remove(wmXrRuntimeData *runtime, XrActionMap *actionmap)
{
int idx = BLI_findindex(&settings->actionmaps, actionmap);
int idx = BLI_findindex(&runtime->actionmaps, actionmap);
if (idx != -1) {
wm_xr_actionmap_clear(actionmap);
BLI_freelinkN(&settings->actionmaps, actionmap);
WM_xr_actionmap_clear(actionmap);
BLI_freelinkN(&runtime->actionmaps, actionmap);
if (idx <= settings->act_actionmap) {
if (--settings->act_actionmap < 0) {
settings->act_actionmap = 0;
if (idx <= runtime->actactionmap) {
if (--runtime->actactionmap < 0) {
runtime->actactionmap = 0;
}
}
if (idx <= settings->sel_actionmap) {
if (--settings->sel_actionmap < 0) {
settings->sel_actionmap = 0;
if (idx <= runtime->selactionmap) {
if (--runtime->selactionmap < 0) {
runtime->selactionmap = 0;
}
}
@@ -503,9 +491,9 @@ bool WM_xr_actionmap_remove(XrSessionSettings *settings, XrActionMap *actionmap)
return false;
}
XrActionMap *WM_xr_actionmap_find(XrSessionSettings *settings, const char *name)
XrActionMap *WM_xr_actionmap_find(wmXrRuntimeData *runtime, const char *name)
{
LISTBASE_FOREACH (XrActionMap *, am, &settings->actionmaps) {
LISTBASE_FOREACH (XrActionMap *, am, &runtime->actionmaps) {
if (STREQLEN(name, am->name, MAX_NAME)) {
return am;
}
@@ -513,13 +501,47 @@ XrActionMap *WM_xr_actionmap_find(XrSessionSettings *settings, const char *name)
return NULL;
}
void WM_xr_actionmaps_free(XrSessionSettings *settings)
void WM_xr_actionmap_clear(XrActionMap *actionmap)
{
LISTBASE_FOREACH (XrActionMap *, am, &settings->actionmaps) {
wm_xr_actionmap_clear(am);
LISTBASE_FOREACH (XrActionMapItem *, ami, &actionmap->items) {
wm_xr_actionmap_item_clear(ami);
}
BLI_freelistN(&settings->actionmaps);
settings->act_actionmap = settings->sel_actionmap = 0;
BLI_freelistN(&actionmap->items);
actionmap->selitem = 0;
}
void WM_xr_actionmaps_clear(wmXrRuntimeData *runtime)
{
LISTBASE_FOREACH (XrActionMap *, am, &runtime->actionmaps) {
WM_xr_actionmap_clear(am);
}
BLI_freelistN(&runtime->actionmaps);
runtime->actactionmap = runtime->selactionmap = 0;
}
ListBase *WM_xr_actionmaps_get(wmXrRuntimeData *runtime)
{
return &runtime->actionmaps;
}
short WM_xr_actionmap_active_index_get(const wmXrRuntimeData *runtime)
{
return runtime->actactionmap;
}
void WM_xr_actionmap_active_index_set(wmXrRuntimeData *runtime, short idx)
{
runtime->actactionmap = idx;
}
short WM_xr_actionmap_selected_index_get(const wmXrRuntimeData *runtime)
{
return runtime->selactionmap;
}
void WM_xr_actionmap_selected_index_set(wmXrRuntimeData *runtime, short idx)
{
runtime->selactionmap = idx;
}
/** \} */

View File

@@ -73,11 +73,10 @@ static void wm_xr_draw_matrices_create(const wmXrDrawData *draw_data,
const XrSessionSettings *session_settings,
const wmXrSessionState *session_state,
float r_viewmat[4][4],
float r_viewmat_base[4][4],
float r_projmat[4][4])
{
GHOST_XrPose eye_pose;
float eye_inv[4][4], base_inv[4][4], nav_inv[4][4];
float eye_inv[4][4], base_inv[4][4], nav_inv[4][4], m[4][4];
/* Calculate inverse eye matrix. */
copy_qt_qt(eye_pose.orientation_quat, draw_view->eye_pose.orientation_quat);
@@ -94,8 +93,8 @@ static void wm_xr_draw_matrices_create(const wmXrDrawData *draw_data,
/* Apply base pose and navigation. */
wm_xr_pose_scale_to_imat(&draw_data->base_pose, draw_data->base_scale, base_inv);
wm_xr_pose_scale_to_imat(&session_state->nav_pose_prev, session_state->nav_scale_prev, nav_inv);
mul_m4_m4m4(r_viewmat_base, eye_inv, base_inv);
mul_m4_m4m4(r_viewmat, r_viewmat_base, nav_inv);
mul_m4_m4m4(m, eye_inv, base_inv);
mul_m4_m4m4(r_viewmat, m, nav_inv);
perspective_m4_fov(r_projmat,
draw_view->fov.angle_left,
@@ -136,14 +135,13 @@ void wm_xr_draw_view(const GHOST_XrDrawViewInfo *draw_view, void *customdata)
const int display_flags = V3D_OFSDRAW_OVERRIDE_SCENE_SETTINGS | settings->draw_flags;
float viewmat[4][4], viewmat_base[4][4], winmat[4][4];
float viewmat[4][4], winmat[4][4];
BLI_assert(WM_xr_session_is_ready(xr_data));
wm_xr_session_draw_data_update(session_state, settings, draw_view, draw_data);
wm_xr_draw_matrices_create(
draw_data, draw_view, settings, session_state, viewmat, viewmat_base, winmat);
wm_xr_session_state_update(settings, draw_data, draw_view, viewmat, viewmat_base, session_state);
wm_xr_draw_matrices_create(draw_data, draw_view, settings, session_state, viewmat, winmat);
wm_xr_session_state_update(settings, draw_data, draw_view, session_state);
if (!wm_xr_session_surface_offscreen_ensure(surface_data, draw_view)) {
return;
@@ -229,7 +227,7 @@ static GPUBatch *wm_xr_controller_model_batch_create(GHOST_XrContextHandle xr_co
static void wm_xr_controller_model_draw(const XrSessionSettings *settings,
GHOST_XrContextHandle xr_context,
ListBase *controllers)
wmXrSessionState *state)
{
GHOST_XrControllerModelData model_data;
@@ -248,7 +246,7 @@ static void wm_xr_controller_model_draw(const XrSessionSettings *settings,
GPU_depth_test(GPU_DEPTH_NONE);
GPU_blend(GPU_BLEND_ALPHA);
LISTBASE_FOREACH (wmXrController *, controller, controllers) {
LISTBASE_FOREACH (wmXrController *, controller, &state->controllers) {
GPUBatch *model = controller->model;
if (!model) {
model = controller->model = wm_xr_controller_model_batch_create(xr_context,
@@ -290,7 +288,7 @@ static void wm_xr_controller_model_draw(const XrSessionSettings *settings,
}
}
static void wm_xr_controller_aim_draw(const XrSessionSettings *settings, ListBase *controllers)
static void wm_xr_controller_aim_draw(const XrSessionSettings *settings, wmXrSessionState *state)
{
bool draw_ray;
switch (settings->controller_draw_style) {
@@ -323,9 +321,9 @@ static void wm_xr_controller_aim_draw(const XrSessionSettings *settings, ListBas
GPU_depth_test(GPU_DEPTH_LESS_EQUAL);
GPU_blend(GPU_BLEND_ALPHA);
immBegin(GPU_PRIM_LINES, (uint)BLI_listbase_count(controllers) * 2);
immBegin(GPU_PRIM_LINES, (uint)BLI_listbase_count(&state->controllers) * 2);
LISTBASE_FOREACH (wmXrController *, controller, controllers) {
LISTBASE_FOREACH (wmXrController *, controller, &state->controllers) {
const float(*mat)[4] = controller->aim_mat;
madd_v3_v3v3fl(ray, mat[3], mat[2], -scale);
@@ -347,9 +345,9 @@ static void wm_xr_controller_aim_draw(const XrSessionSettings *settings, ListBas
GPU_depth_test(GPU_DEPTH_NONE);
GPU_blend(GPU_BLEND_NONE);
immBegin(GPU_PRIM_LINES, (uint)BLI_listbase_count(controllers) * 6);
immBegin(GPU_PRIM_LINES, (uint)BLI_listbase_count(&state->controllers) * 6);
LISTBASE_FOREACH (wmXrController *, controller, controllers) {
LISTBASE_FOREACH (wmXrController *, controller, &state->controllers) {
const float(*mat)[4] = controller->aim_mat;
madd_v3_v3v3fl(x_axis, mat[3], mat[0], scale);
madd_v3_v3v3fl(y_axis, mat[3], mat[1], scale);
@@ -382,19 +380,8 @@ void wm_xr_draw_controllers(const bContext *UNUSED(C), ARegion *UNUSED(region),
wmXrData *xr = customdata;
const XrSessionSettings *settings = &xr->session_settings;
GHOST_XrContextHandle xr_context = xr->runtime->context;
ListBase *controllers = &xr->runtime->session_state.controllers;
wmXrSessionState *state = &xr->runtime->session_state;
wm_xr_controller_model_draw(settings, xr_context, controllers);
wm_xr_controller_aim_draw(settings, controllers);
}
void wm_xr_draw_trackers(const bContext *UNUSED(C), ARegion *UNUSED(region), void *customdata)
{
wmXrData *xr = customdata;
const XrSessionSettings *settings = &xr->session_settings;
GHOST_XrContextHandle xr_context = xr->runtime->context;
ListBase *trackers = &xr->runtime->session_state.trackers;
wm_xr_controller_model_draw(settings, xr_context, trackers);
wm_xr_controller_aim_draw(settings, trackers);
wm_xr_controller_model_draw(settings, xr_context, state);
wm_xr_controller_aim_draw(settings, state);
}

View File

@@ -21,6 +21,7 @@ typedef struct wmXrSessionState {
float viewer_viewmat[4][4];
/** The last known viewer matrix, without navigation applied. */
float viewer_mat_base[4][4];
float focal_len;
/** Copy of XrSessionSettings.base_pose_ data to detect changes that need
* resetting to base pose. */
@@ -49,12 +50,8 @@ typedef struct wmXrSessionState {
float nav_scale_prev;
bool is_navigation_dirty;
/** Last known eye data. */
ListBase eyes; /* #wmXrEye */
/** Last known controller data. */
ListBase controllers; /* #wmXrController */
/** Last known tracker data. */
ListBase trackers; /* #wmXrController */
/** The currently active action set that will be updated on calls to
* #wm_xr_session_actions_update(). If NULL, all action sets will be treated as active and
@@ -62,10 +59,6 @@ typedef struct wmXrSessionState {
struct wmXrActionSet *active_action_set;
/* Name of the action set (if any) to activate before the next actions sync. */
char active_action_set_next[64]; /* MAX_NAME */
/* Original poses for motion capture objects. Used to restore object transforms on session end.
*/
ListBase mocap_orig_poses; /* #wmXrMotionCapturePose */
} wmXrSessionState;
typedef struct wmXrRuntimeData {
@@ -81,6 +74,10 @@ typedef struct wmXrRuntimeData {
/** Although this struct is internal, RNA gets a handle to this for state information queries. */
wmXrSessionState session_state;
wmXrSessionExitFn exit_fn;
ListBase actionmaps; /* #XrActionMap */
short actactionmap;
short selactionmap;
} wmXrRuntimeData;
typedef struct wmXrViewportPair {
@@ -97,8 +94,6 @@ typedef struct {
struct ARegionType *controller_art;
/** Controller draw callback handle. */
void *controller_draw_handle;
/** Tracker draw callback handle. */
void *tracker_draw_handle;
} wmXrSurfaceData;
typedef struct wmXrDrawData {
@@ -119,14 +114,6 @@ typedef struct wmXrDrawData {
float eye_position_ofs[3]; /* Local/view space. */
} wmXrDrawData;
typedef struct wmXrEye {
struct wmXrEye *next, *prev;
float focal_len;
float viewmat[4][4];
/** Viewmat without navigation applied. */
float viewmat_base[4][4];
} wmXrEye;
typedef struct wmXrController {
struct wmXrController *next, *prev;
/** OpenXR user path identifier. */
@@ -166,9 +153,6 @@ typedef struct wmXrAction {
struct wmOperatorType *ot;
IDProperty *op_properties;
/** Mouse simulation. */
XrSimulateMouseParams simulate;
/** Haptics. */
char *haptic_name;
int64_t haptic_duration;
@@ -194,26 +178,20 @@ typedef struct wmXrActionSet {
/** XR pose actions that determine the controller grip/aim transforms. */
wmXrAction *controller_grip_action;
wmXrAction *controller_aim_action;
/** XR pose actions that determine tracker transforms. */
ListBase tracker_actions; /* #LinkData */
/** Currently active modal actions. */
ListBase active_modal_actions; /* #LinkData */
ListBase active_modal_actions;
/** Currently active haptic actions. */
ListBase active_haptic_actions; /* wmXrHapticAction */
ListBase active_haptic_actions;
} wmXrActionSet;
typedef struct wmXrMotionCapturePose {
struct wmXrMotionCapturePose *next, *prev;
const Object *ob;
GHOST_XrPose pose;
} wmXrMotionCapturePose;
/* wm_xr.c */
wmXrRuntimeData *wm_xr_runtime_data_create(void);
void wm_xr_runtime_data_free(wmXrRuntimeData **runtime);
/* wm_xr_session.c */
void wm_xr_session_data_free(wmXrSessionState *state);
wmWindow *wm_xr_session_root_window_or_fallback_get(const wmWindowManager *wm,
const wmXrRuntimeData *runtime_data);
@@ -229,8 +207,6 @@ void wm_xr_session_draw_data_update(wmXrSessionState *state,
void wm_xr_session_state_update(const XrSessionSettings *settings,
const wmXrDrawData *draw_data,
const GHOST_XrDrawViewInfo *draw_view,
const float viewmat[4][4],
const float viewmat_base[4][4],
wmXrSessionState *state);
bool wm_xr_session_surface_offscreen_ensure(wmXrSurfaceData *surface_data,
const GHOST_XrDrawViewInfo *draw_view);
@@ -238,15 +214,14 @@ void *wm_xr_session_gpu_binding_context_create(void);
void wm_xr_session_gpu_binding_context_destroy(GHOST_ContextHandle context);
void wm_xr_session_actions_init(wmXrData *xr);
void wm_xr_session_actions_update(const struct bContext *C);
void wm_xr_session_actions_update(wmWindowManager *wm);
void wm_xr_session_controller_data_populate(const wmXrAction *grip_action,
const wmXrAction *aim_action,
wmXrData *xr);
void wm_xr_session_controller_data_clear(wmXrSessionState *state);
void wm_xr_session_tracker_data_populate(const ListBase *tracker_actions, wmXrData *xr);
void wm_xr_session_tracker_data_clear(wmXrSessionState *state);
/* wm_xr_draw.c */
void wm_xr_pose_to_mat(const GHOST_XrPose *pose, float r_mat[4][4]);
void wm_xr_pose_scale_to_mat(const GHOST_XrPose *pose, float scale, float r_mat[4][4]);
void wm_xr_pose_to_imat(const GHOST_XrPose *pose, float r_imat[4][4]);
@@ -259,23 +234,3 @@ void wm_xr_pose_scale_to_imat(const GHOST_XrPose *pose, float scale, float r_ima
*/
void wm_xr_draw_view(const GHOST_XrDrawViewInfo *draw_view, void *customdata);
void wm_xr_draw_controllers(const struct bContext *C, struct ARegion *region, void *customdata);
void wm_xr_draw_trackers(const struct bContext *C, struct ARegion *region, void *customdata);
/* wm_xr_mocap.c */
void wm_xr_mocap_orig_poses_store(const XrSessionSettings *settings, wmXrSessionState *state);
void wm_xr_mocap_orig_poses_restore(const wmXrSessionState *state, XrSessionSettings *settings);
void wm_xr_mocap_object_autokey(struct bContext *C,
struct Scene *scene,
struct ViewLayer *view_layer,
wmWindow *win,
Object *ob,
bool notify);
void wm_xr_mocap_objects_update(const char *user_path,
const GHOST_XrPose *pose,
struct bContext *C,
XrSessionSettings *settings,
struct Scene *scene,
struct ViewLayer *view_layer,
wmWindow *win,
struct bScreen *screen_anim,
bool *notify);

View File

@@ -1,272 +0,0 @@
/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/** \file
* \ingroup wm
*
* \name Window-Manager XR Motion Capture
*
* API for XR motion capture objects.
*/
#include "BKE_context.h"
#include "BKE_layer.h"
#include "BLI_listbase.h"
#include "BLI_math.h"
#include "DEG_depsgraph.h"
#include "DNA_object_types.h"
#include "ED_keyframing.h"
#include "ED_object.h"
#include "ED_screen.h"
#include "ED_transform.h"
#include "GHOST_C-api.h"
#include "MEM_guardedalloc.h"
#include "WM_api.h"
#include "wm_xr_intern.h"
/* -------------------------------------------------------------------- */
/** \name XR Motion Capture Objects
*
* List of XR motion capture objects. Stored in session settings and can be written to files.
* \{ */
XrMotionCaptureObject *WM_xr_mocap_object_new(XrSessionSettings *settings, Object *ob)
{
XrMotionCaptureObject *mocap_ob = WM_xr_mocap_object_find(settings, ob);
if (!mocap_ob) {
mocap_ob = MEM_callocN(sizeof(XrMotionCaptureObject), __func__);
mocap_ob->ob = ob;
BLI_addtail(&settings->mocap_objects, mocap_ob);
}
return mocap_ob;
}
void WM_xr_mocap_object_ensure_unique(XrSessionSettings *settings, XrMotionCaptureObject *mocap_ob)
{
LISTBASE_FOREACH (XrMotionCaptureObject *, mocap_ob_other, &settings->mocap_objects) {
if ((mocap_ob_other != mocap_ob) && (mocap_ob_other->ob == mocap_ob->ob)) {
mocap_ob->ob = NULL;
return;
}
}
}
void WM_xr_mocap_object_remove(XrSessionSettings *settings, XrMotionCaptureObject *mocap_ob)
{
int idx = BLI_findindex(&settings->mocap_objects, mocap_ob);
if (idx != -1) {
BLI_freelinkN(&settings->mocap_objects, mocap_ob);
if (idx <= settings->sel_mocap_object) {
if (--settings->sel_mocap_object < 0) {
settings->sel_mocap_object = 0;
}
}
}
}
XrMotionCaptureObject *WM_xr_mocap_object_find(const XrSessionSettings *settings, const Object *ob)
{
return ob ? BLI_findptr(&settings->mocap_objects, ob, offsetof(XrMotionCaptureObject, ob)) :
NULL;
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Motion Capture Runtime
*
* Runtime functions for motion capture object poses and autokeying.
* \{ */
static void wm_xr_mocap_object_pose_get(const XrMotionCaptureObject *mocap_ob, GHOST_XrPose *pose)
{
BLI_assert(mocap_ob->ob);
copy_v3_v3(pose->position, mocap_ob->ob->loc);
eul_to_quat(pose->orientation_quat, mocap_ob->ob->rot);
}
static void wm_xr_mocap_object_pose_set(const GHOST_XrPose *pose,
XrMotionCaptureObject *mocap_ob,
bool apply_offset)
{
BLI_assert(mocap_ob->ob);
if (apply_offset) {
/* Convert offsets to pose (device) space. */
float loc_ofs[3], rot_ofs[4];
copy_v3_v3(loc_ofs, mocap_ob->location_offset);
mul_qt_v3(pose->orientation_quat, loc_ofs);
eul_to_quat(rot_ofs, mocap_ob->rotation_offset);
normalize_qt(rot_ofs);
invert_qt_normalized(rot_ofs);
mul_qt_qtqt(rot_ofs, pose->orientation_quat, rot_ofs);
normalize_qt(rot_ofs);
add_v3_v3v3(mocap_ob->ob->loc, pose->position, loc_ofs);
quat_to_eul(mocap_ob->ob->rot, rot_ofs);
}
else {
copy_v3_v3(mocap_ob->ob->loc, pose->position);
quat_to_eul(mocap_ob->ob->rot, pose->orientation_quat);
}
DEG_id_tag_update(&mocap_ob->ob->id, ID_RECALC_TRANSFORM);
}
void wm_xr_mocap_orig_poses_store(const XrSessionSettings *settings, wmXrSessionState *state)
{
ListBase *mocap_orig_poses = &state->mocap_orig_poses;
LISTBASE_FOREACH (XrMotionCaptureObject *, mocap_ob, &settings->mocap_objects) {
wmXrMotionCapturePose *mocap_pose = MEM_callocN(sizeof(wmXrMotionCapturePose), __func__);
mocap_pose->ob = mocap_ob->ob;
if (mocap_ob->ob) {
wm_xr_mocap_object_pose_get(mocap_ob, &mocap_pose->pose);
}
BLI_addtail(mocap_orig_poses, mocap_pose);
}
}
void wm_xr_mocap_orig_poses_restore(const wmXrSessionState *state, XrSessionSettings *settings)
{
ListBase *mocap_objects = &settings->mocap_objects;
LISTBASE_FOREACH (wmXrMotionCapturePose *, mocap_pose, &state->mocap_orig_poses) {
XrMotionCaptureObject *mocap_ob = BLI_findptr(
mocap_objects, mocap_pose->ob, offsetof(XrMotionCaptureObject, ob));
if (mocap_ob && mocap_ob->ob) {
wm_xr_mocap_object_pose_set(&mocap_pose->pose, mocap_ob, false);
}
}
}
void wm_xr_mocap_object_autokey(
bContext *C, Scene *scene, ViewLayer *view_layer, wmWindow *win, Object *ob, bool notify)
{
/* Poll functions in keyingsets_utils.py require an active window and object. */
wmWindow *win_prev = win ? CTX_wm_window(C) : NULL;
if (win) {
CTX_wm_window_set(C, win);
}
Object *obact = CTX_data_active_object(C);
if (!obact) {
Base *base = BKE_view_layer_base_find(view_layer, ob);
if (base) {
ED_object_base_select(base, BA_SELECT);
ED_object_base_activate(C, base);
}
}
bScreen *screen = CTX_wm_screen(C);
if (screen && screen->animtimer && (IS_AUTOKEY_FLAG(scene, INSERTAVAIL) == 0) &&
((scene->toolsettings->autokey_flag & ANIMRECORD_FLAG_WITHNLA) != 0)) {
ED_transform_animrecord_check_state(scene, screen->animtimer, &ob->id);
}
ED_transform_autokeyframe_object(C, scene, view_layer, ob, TFM_TRANSLATION);
if (IS_AUTOKEY_FLAG(scene, INSERTNEEDED)) {
ED_transform_autokeyframe_object(C, scene, view_layer, ob, TFM_ROTATION);
}
if (ED_transform_motionpath_need_update_object(scene, ob)) {
ListBase lb = {NULL, NULL};
BLI_addtail(&lb, BLI_genericNodeN(ob));
ED_objects_recalculate_paths(C, scene, OBJECT_PATH_CALC_RANGE_CURRENT_FRAME, &lb);
BLI_freelistN(&lb);
}
if (notify) {
WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, NULL);
WM_main_add_notifier(NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
}
if (win) {
CTX_wm_window_set(C, win_prev);
}
}
void wm_xr_mocap_objects_update(const char *user_path,
const GHOST_XrPose *pose,
bContext *C,
XrSessionSettings *settings,
Scene *scene,
ViewLayer *view_layer,
wmWindow *win,
bScreen *screen_anim,
bool *notify)
{
LISTBASE_FOREACH (XrMotionCaptureObject *, mocap_ob, &settings->mocap_objects) {
if (mocap_ob->ob && ((mocap_ob->flag & XR_MOCAP_OBJECT_ENABLE) != 0) &&
STREQ(mocap_ob->user_path, user_path)) {
wm_xr_mocap_object_pose_set(pose, mocap_ob, true);
if (((mocap_ob->flag & XR_MOCAP_OBJECT_AUTOKEY) != 0) && screen_anim &&
autokeyframe_cfra_can_key(scene, &mocap_ob->ob->id)) {
wm_xr_mocap_object_autokey(C, scene, view_layer, win, mocap_ob->ob, *notify);
*notify = false;
}
}
}
}
bool WM_xr_session_state_mocap_pose_get(const wmXrData *xr, XrMotionCaptureObject *mocap_ob)
{
if (!WM_xr_session_exists(xr)) {
return false;
}
if (mocap_ob->ob) {
wmXrMotionCapturePose *mocap_pose = BLI_findptr(&xr->runtime->session_state.mocap_orig_poses,
mocap_ob->ob,
offsetof(wmXrMotionCapturePose, ob));
if (!mocap_pose) {
return false;
}
wm_xr_mocap_object_pose_set(&mocap_pose->pose, mocap_ob, false);
}
return true;
}
void WM_xr_session_state_mocap_pose_set(wmXrData *xr, const XrMotionCaptureObject *mocap_ob)
{
if (WM_xr_session_exists(xr) && mocap_ob->ob) {
wmXrMotionCapturePose *mocap_pose = BLI_findptr(&xr->runtime->session_state.mocap_orig_poses,
mocap_ob->ob,
offsetof(wmXrMotionCapturePose, ob));
if (mocap_pose) {
wm_xr_mocap_object_pose_get(mocap_ob, &mocap_pose->pose);
}
}
}
/** \} */

File diff suppressed because it is too large Load Diff

View File

@@ -25,7 +25,6 @@
#include "ED_screen.h"
#include "ED_space_api.h"
#include "ED_view3d.h"
#include "GHOST_C-api.h"
@@ -44,9 +43,6 @@
#include "wm_window.h"
#include "wm_xr_intern.h"
/* OpenXR user path identifying the headset. Used for motion capture objects. */
#define XR_HEADSET_PATH "/user/head"
static wmSurface *g_xr_surface = NULL;
static CLG_LogRef LOG = {"wm.xr"};
@@ -71,28 +67,24 @@ static void wm_xr_session_create_cb(void)
settings->base_scale = 1.0f;
}
state->prev_base_scale = settings->base_scale;
/* Store motion capture object poses. */
wm_xr_mocap_orig_poses_store(settings, state);
}
static void wm_xr_session_controller_data_free(ListBase *controllers)
static void wm_xr_session_controller_data_free(wmXrSessionState *state)
{
ListBase *lb = &state->controllers;
wmXrController *c;
while ((c = BLI_pophead(controllers))) {
while ((c = BLI_pophead(lb))) {
if (c->model) {
GPU_batch_discard(c->model);
}
BLI_freelinkN(controllers, c);
BLI_freelinkN(lb, c);
}
}
void wm_xr_session_data_free(wmXrSessionState *state)
{
BLI_freelistN(&state->eyes);
wm_xr_session_controller_data_free(&state->controllers);
wm_xr_session_controller_data_free(&state->trackers);
BLI_freelistN(&state->mocap_orig_poses);
wm_xr_session_controller_data_free(state);
}
static void wm_xr_session_exit_cb(void *customdata)
@@ -104,9 +96,6 @@ static void wm_xr_session_exit_cb(void *customdata)
xr_data->runtime->session_state.is_started = false;
/* Restore motion capture object poses. */
wm_xr_mocap_orig_poses_restore(&xr_data->runtime->session_state, &xr_data->session_settings);
if (xr_data->runtime->exit_fn) {
xr_data->runtime->exit_fn(xr_data);
}
@@ -346,23 +335,11 @@ void wm_xr_session_draw_data_update(wmXrSessionState *state,
void wm_xr_session_state_update(const XrSessionSettings *settings,
const wmXrDrawData *draw_data,
const GHOST_XrDrawViewInfo *draw_view,
const float viewmat[4][4],
const float viewmat_base[4][4],
wmXrSessionState *state)
{
GHOST_XrPose viewer_pose;
float viewer_mat[4][4], base_mat[4][4], nav_mat[4][4];
wmXrEye *eye = NULL;
if (draw_view->view_idx >= BLI_listbase_count(&state->eyes)) {
eye = MEM_callocN(sizeof(*eye), __func__);
BLI_addtail(&state->eyes, eye);
}
else {
eye = BLI_findlink(&state->eyes, draw_view->view_idx);
}
BLI_assert(eye);
/* Calculate viewer matrix. */
copy_qt_qt(viewer_pose.orientation_quat, draw_view->local_pose.orientation_quat);
if ((settings->flag & XR_SESSION_USE_POSITION_TRACKING) == 0) {
@@ -388,11 +365,9 @@ void wm_xr_session_state_update(const XrSessionSettings *settings,
&state->viewer_pose, draw_data->base_scale * state->nav_scale_prev, state->viewer_viewmat);
/* No idea why, but multiplying by two seems to make it match the VR view more. */
eye->focal_len = 2.0f *
fov_to_focallength(draw_view->fov.angle_right - draw_view->fov.angle_left,
DEFAULT_SENSOR_WIDTH);
copy_m4_m4(eye->viewmat, viewmat);
copy_m4_m4(eye->viewmat_base, viewmat_base);
state->focal_len = 2.0f *
fov_to_focallength(draw_view->fov.angle_right - draw_view->fov.angle_left,
DEFAULT_SENSOR_WIDTH);
copy_v3_v3(state->prev_eye_position_ofs, draw_data->eye_position_ofs);
memcpy(&state->prev_base_pose, &draw_data->base_pose, sizeof(state->prev_base_pose));
@@ -451,16 +426,7 @@ bool WM_xr_session_state_viewer_pose_matrix_info_get(const wmXrData *xr,
}
copy_m4_m4(r_viewmat, xr->runtime->session_state.viewer_viewmat);
/* Since viewer (eye centroid) does not have a focal length, just take it from projection eye. */
const wmXrEye *eye = BLI_findlink(&xr->runtime->session_state.eyes,
xr->session_settings.projection_eye);
if (!eye) {
/* Fall back to first XR view. */
eye = xr->runtime->session_state.eyes.first;
BLI_assert(eye);
}
*r_focal_len = eye->focal_len;
*r_focal_len = xr->runtime->session_state.focal_len;
return true;
}
@@ -533,48 +499,6 @@ bool WM_xr_session_state_controller_aim_rotation_get(const wmXrData *xr,
return true;
}
bool WM_xr_session_state_tracker_location_get(const wmXrData *xr,
const char *subaction_path,
float r_location[3])
{
if (!WM_xr_session_is_ready(xr) || !xr->runtime->session_state.is_view_data_set) {
zero_v3(r_location);
return false;
}
const wmXrController *tracker = BLI_findstring(&xr->runtime->session_state.trackers,
subaction_path,
offsetof(wmXrController, subaction_path));
if (!tracker) {
zero_v3(r_location);
return false;
}
copy_v3_v3(r_location, tracker->grip_pose.position);
return true;
}
bool WM_xr_session_state_tracker_rotation_get(const wmXrData *xr,
const char *subaction_path,
float r_rotation[4])
{
if (!WM_xr_session_is_ready(xr) || !xr->runtime->session_state.is_view_data_set) {
unit_qt(r_rotation);
return false;
}
const wmXrController *tracker = BLI_findstring(&xr->runtime->session_state.trackers,
subaction_path,
offsetof(wmXrController, subaction_path));
if (!tracker) {
unit_qt(r_rotation);
return false;
}
copy_qt_qt(r_rotation, tracker->grip_pose.orientation_quat);
return true;
}
bool WM_xr_session_state_nav_location_get(const wmXrData *xr, float r_location[3])
{
if (!WM_xr_session_is_ready(xr) || !xr->runtime->session_state.is_view_data_set) {
@@ -682,79 +606,15 @@ static void wm_xr_session_controller_pose_calc(const GHOST_XrPose *raw_pose,
mat4_to_loc_quat(r_pose->position, r_pose->orientation_quat, r_mat);
}
static void wm_xr_session_controller_data_update(const wmXrAction *grip_action,
static void wm_xr_session_controller_data_update(const XrSessionSettings *settings,
const wmXrAction *grip_action,
const wmXrAction *aim_action,
unsigned int subaction_idx,
const float view_ofs[3],
const float base_mat[4][4],
const float nav_mat[4][4],
bContext *C,
XrSessionSettings *settings,
GHOST_XrContextHandle xr_context,
Scene *scene,
ViewLayer *view_layer,
wmWindow *win,
bScreen *screen_anim,
bool *notify,
wmXrController *controller)
{
wm_xr_session_controller_pose_calc(&((GHOST_XrPose *)grip_action->states)[subaction_idx],
view_ofs,
base_mat,
nav_mat,
&controller->grip_pose,
controller->grip_mat,
controller->grip_mat_base);
wm_xr_session_controller_pose_calc(&((GHOST_XrPose *)aim_action->states)[subaction_idx],
view_ofs,
base_mat,
nav_mat,
&controller->aim_pose,
controller->aim_mat,
controller->aim_mat_base);
/* Update motion capture objects. */
wm_xr_mocap_objects_update(controller->subaction_path,
&controller->grip_pose,
C,
settings,
scene,
view_layer,
win,
screen_anim,
notify);
/* Update controller model. */
if (!controller->model) {
/* Notify GHOST to load/continue loading the controller model data. This can be called more
* than once since the model may not be available from the runtime yet. The batch itself will
* be created in wm_xr_draw_controllers(). */
GHOST_XrLoadControllerModel(xr_context, controller->subaction_path);
}
else {
GHOST_XrUpdateControllerModelComponents(xr_context, controller->subaction_path);
}
}
static void wm_xr_session_controller_and_tracker_data_update(const wmXrAction *grip_action,
const wmXrAction *aim_action,
const ListBase *tracker_actions,
bContext *C,
XrSessionSettings *settings,
GHOST_XrContextHandle xr_context,
wmXrSessionState *state,
wmWindow *win)
wmXrSessionState *state)
{
BLI_assert(grip_action->count_subaction_paths == aim_action->count_subaction_paths);
BLI_assert(grip_action->count_subaction_paths == BLI_listbase_count(&state->controllers));
BLI_assert(BLI_listbase_count(tracker_actions) <= BLI_listbase_count(&state->trackers));
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
wmWindowManager *wm = CTX_wm_manager(C);
bScreen *screen_anim = ED_screen_animation_playing(wm);
bool notify = true;
wmXrController *tracker = state->trackers.first;
uint subaction_idx = 0;
float view_ofs[3], base_mat[4][4], nav_mat[4][4];
@@ -771,47 +631,30 @@ static void wm_xr_session_controller_and_tracker_data_update(const wmXrAction *g
wm_xr_pose_scale_to_mat(&state->prev_base_pose, state->prev_base_scale, base_mat);
wm_xr_pose_scale_to_mat(&state->nav_pose, state->nav_scale, nav_mat);
/* Update controllers. */
LISTBASE_FOREACH_INDEX (wmXrController *, controller, &state->controllers, subaction_idx) {
wm_xr_session_controller_data_update(grip_action,
aim_action,
subaction_idx,
view_ofs,
base_mat,
nav_mat,
C,
settings,
xr_context,
scene,
view_layer,
win,
screen_anim,
&notify,
controller);
}
wm_xr_session_controller_pose_calc(&((GHOST_XrPose *)grip_action->states)[subaction_idx],
view_ofs,
base_mat,
nav_mat,
&controller->grip_pose,
controller->grip_mat,
controller->grip_mat_base);
wm_xr_session_controller_pose_calc(&((GHOST_XrPose *)aim_action->states)[subaction_idx],
view_ofs,
base_mat,
nav_mat,
&controller->aim_pose,
controller->aim_mat,
controller->aim_mat_base);
/* Update trackers. */
LISTBASE_FOREACH (LinkData *, ld, tracker_actions) {
const wmXrAction *tracker_action = ld->data;
for (subaction_idx = 0; subaction_idx < tracker_action->count_subaction_paths;
++subaction_idx) {
wm_xr_session_controller_data_update(tracker_action,
tracker_action,
subaction_idx,
view_ofs,
base_mat,
nav_mat,
C,
settings,
xr_context,
scene,
view_layer,
win,
screen_anim,
&notify,
tracker);
tracker = tracker->next;
if (!controller->model) {
/* Notify GHOST to load/continue loading the controller model data. This can be called more
* than once since the model may not be available from the runtime yet. The batch itself will
* be created in wm_xr_draw_controllers(). */
GHOST_XrLoadControllerModel(xr_context, controller->subaction_path);
}
else {
GHOST_XrUpdateControllerModelComponents(xr_context, controller->subaction_path);
}
}
}
@@ -979,8 +822,7 @@ static void wm_xr_session_action_states_interpret(wmXrData *xr,
int64_t time_now,
bool modal,
bool haptic,
short *r_val,
bool *r_press_start)
short *r_val)
{
const char *haptic_subaction_path = ((action->haptic_flag & XR_HAPTIC_MATCHUSERPATHS) != 0) ?
action->subaction_paths[subaction_idx] :
@@ -1042,7 +884,6 @@ static void wm_xr_session_action_states_interpret(wmXrData *xr,
if (!prev) {
if (modal || (action->op_flag == XR_OP_PRESS)) {
*r_val = KM_PRESS;
*r_press_start = true;
}
if (haptic && (action->haptic_flag & (XR_HAPTIC_PRESS | XR_HAPTIC_REPEAT)) != 0) {
/* Apply haptics. */
@@ -1060,7 +901,6 @@ static void wm_xr_session_action_states_interpret(wmXrData *xr,
}
else if (modal) {
*r_val = KM_PRESS;
*r_press_start = false;
}
if (modal && !action->active_modal_path) {
/* Set active modal path. */
@@ -1088,7 +928,6 @@ static void wm_xr_session_action_states_interpret(wmXrData *xr,
else if (prev) {
if (modal || (action->op_flag == XR_OP_RELEASE)) {
*r_val = KM_RELEASE;
*r_press_start = false;
if (modal && (action->subaction_paths[subaction_idx] == action->active_modal_path)) {
/* Unset active modal path. */
action->active_modal_path = NULL;
@@ -1181,9 +1020,7 @@ static wmXrActionData *wm_xr_session_event_create(const char *action_set_name,
const GHOST_XrPose *controller_aim_pose_other,
uint subaction_idx,
uint subaction_idx_other,
bool bimanual,
short val,
bool press_start)
bool bimanual)
{
wmXrActionData *data = MEM_callocN(sizeof(wmXrActionData), __func__);
strcpy(data->action_set, action_set_name);
@@ -1242,56 +1079,10 @@ static wmXrActionData *wm_xr_session_event_create(const char *action_set_name,
data->op_properties = action->op_properties;
data->bimanual = bimanual;
data->simulate_mouse = (((action->action_flag & XR_ACTION_SIMULATE_MOUSE) != 0) &&
controller_aim_pose);
if (data->simulate_mouse) {
switch (val) {
case KM_PRESS:
if (press_start) {
data->simulate_type = action->simulate.press_type;
data->simulate_val = action->simulate.press_val;
}
else {
data->simulate_type = action->simulate.hold_type;
data->simulate_val = action->simulate.hold_val;
}
break;
case KM_RELEASE:
data->simulate_type = action->simulate.release_type;
data->simulate_val = action->simulate.release_val;
break;
default:
BLI_assert_unreachable();
break;
}
}
return data;
}
/**
* Convert 3D controller coordinates to 2D mouse (pixel) coordinates.
*/
static void map_to_pixel(
const float co[3], const float persmat[4][4], int winx, int winy, int r_co[2])
{
float vec[3];
mul_v3_project_m4_v3(vec, persmat, co);
r_co[0] = (int)(((float)winx / 2.0f) * (1.0f + vec[0]));
r_co[1] = (int)(((float)winy / 2.0f) * (1.0f + vec[1]));
}
static void wm_xr_session_event_mval_calc(const wmXrRuntimeData *runtime,
const GHOST_XrPose *controller_aim_pose,
int r_mval[2])
{
const ARegion *region = BKE_area_find_region_type(runtime->area, RGN_TYPE_WINDOW);
BLI_assert(region);
const RegionView3D *rv3d = region->regiondata;
BLI_assert(rv3d);
map_to_pixel(controller_aim_pose->position, rv3d->persmat, region->winx, region->winy, r_mval);
}
/* Dispatch events to window queues. */
static void wm_xr_session_events_dispatch(wmXrData *xr,
GHOST_XrContextHandle xr_context,
@@ -1300,16 +1091,19 @@ static void wm_xr_session_events_dispatch(wmXrData *xr,
wmWindow *win)
{
const char *action_set_name = action_set->name;
const uint count = GHOST_XrGetActionCount(xr_context, action_set_name);
if (count < 1) {
return;
}
const int64_t time_now = (int64_t)(PIL_check_seconds_timer() * 1000);
ListBase *active_modal_actions = &action_set->active_modal_actions;
ListBase *active_haptic_actions = &action_set->active_haptic_actions;
wmXrAction **actions = MEM_calloc_arrayN(count, sizeof(*actions), __func__);
GHOST_XrGetActionCustomdataArray(xr_context, action_set_name, (void **)actions);
/* Check haptic action timers. */
@@ -1317,148 +1111,62 @@ static void wm_xr_session_events_dispatch(wmXrData *xr,
for (uint action_idx = 0; action_idx < count; ++action_idx) {
wmXrAction *action = actions[action_idx];
if (!action || !action->ot) {
continue;
}
if (action && action->ot) {
const bool modal = action->ot->modal;
const bool haptic = (GHOST_XrGetActionCustomdata(
xr_context, action_set_name, action->haptic_name) != NULL);
const bool modal = action->ot->modal;
const bool haptic = (GHOST_XrGetActionCustomdata(
xr_context, action_set_name, action->haptic_name) != NULL);
for (uint subaction_idx = 0; subaction_idx < action->count_subaction_paths;
++subaction_idx) {
short val = KM_NOTHING;
for (uint subaction_idx = 0; subaction_idx < action->count_subaction_paths; ++subaction_idx) {
short val = KM_NOTHING;
bool press_start = false;
/* Interpret action states (update modal/haptic action lists, apply haptics, etc). */
wm_xr_session_action_states_interpret(xr,
action_set_name,
action,
subaction_idx,
active_modal_actions,
active_haptic_actions,
time_now,
modal,
haptic,
&val);
/* Interpret action states (update modal/haptic action lists, apply haptics, etc). */
wm_xr_session_action_states_interpret(xr,
action_set_name,
action,
subaction_idx,
active_modal_actions,
active_haptic_actions,
time_now,
modal,
haptic,
&val,
&press_start);
if (val == KM_NOTHING) {
continue;
}
if (modal) {
const bool is_active_modal_action = wm_xr_session_modal_action_test(
active_modal_actions, action, NULL);
if (!is_active_modal_action) {
continue;
}
const bool is_active_modal_subaction = (!action->active_modal_path ||
(action->subaction_paths[subaction_idx] ==
action->active_modal_path));
if (!is_active_modal_subaction) {
continue;
if ((val != KM_NOTHING) &&
(!modal || (is_active_modal_action && is_active_modal_subaction))) {
const GHOST_XrPose *aim_pose = wm_xr_session_controller_aim_pose_find(
session_state, action->subaction_paths[subaction_idx]);
const GHOST_XrPose *aim_pose_other = NULL;
uint subaction_idx_other = 0;
/* Test for bimanual interaction. */
const bool bimanual = wm_xr_session_action_test_bimanual(
session_state, action, subaction_idx, &subaction_idx_other, &aim_pose_other);
wmXrActionData *actiondata = wm_xr_session_event_create(action_set_name,
action,
aim_pose,
aim_pose_other,
subaction_idx,
subaction_idx_other,
bimanual);
wm_event_add_xrevent(win, actiondata, val);
}
}
const GHOST_XrPose *aim_pose = wm_xr_session_controller_aim_pose_find(
session_state, action->subaction_paths[subaction_idx]);
const GHOST_XrPose *aim_pose_other = NULL;
unsigned int subaction_idx_other = 0;
int mval[2];
/* Test for bimanual interaction. */
const bool bimanual = wm_xr_session_action_test_bimanual(
session_state, action, subaction_idx, &subaction_idx_other, &aim_pose_other);
wmXrActionData *actiondata = wm_xr_session_event_create(action_set_name,
action,
aim_pose,
aim_pose_other,
subaction_idx,
subaction_idx_other,
bimanual,
val,
press_start);
/* Calculate simulated mouse coordinates. */
if (actiondata->simulate_mouse) {
wm_xr_session_event_mval_calc(xr->runtime, aim_pose, mval);
}
wm_event_add_xrevent(win, actiondata, val, actiondata->simulate_mouse ? mval : NULL);
}
}
MEM_freeN(actions);
}
static bool wm_xr_session_area_ensure(const XrSessionSettings *settings,
const wmXrSessionState *state,
const wmXrSurfaceData *surface_data,
wmWindowManager *wm,
Scene *scene,
Depsgraph *depsgraph,
wmWindow *win)
void wm_xr_session_actions_update(wmWindowManager *wm)
{
if (settings->projection_eye >= BLI_listbase_count(&state->eyes) ||
settings->projection_eye >= BLI_listbase_count(&surface_data->viewports)) {
return false;
}
const wmXrEye *eye = BLI_findlink(&state->eyes, settings->projection_eye);
BLI_assert(eye);
const wmXrViewportPair *vp = BLI_findlink(&surface_data->viewports, settings->projection_eye);
BLI_assert(vp && vp->offscreen);
const int width = GPU_offscreen_width(vp->offscreen);
const int height = GPU_offscreen_height(vp->offscreen);
wmXrRuntimeData *runtime = wm->xr.runtime;
wmWindow *win_prev = wm->windrawable;
/* Ensure an XR area exists for events. */
if (!runtime->area) {
runtime->area = ED_area_offscreen_create(win, SPACE_VIEW3D);
}
ARegion *region = BKE_area_find_region_type(runtime->area, RGN_TYPE_WINDOW);
BLI_assert(region);
View3D *v3d = (View3D *)runtime->area->spacedata.first;
BLI_assert(v3d);
RegionView3D *rv3d = region->regiondata;
BLI_assert(rv3d);
/* Ensure region dimensions and view params match the XR (projection eye) view.*/
runtime->area->winx = width;
runtime->area->winy = height;
region->winx = width;
region->winy = height;
region->winrct.xmin = 0;
region->winrct.xmax = width - 1;
region->winrct.ymin = 0;
region->winrct.ymax = height - 1;
v3d->clip_start = settings->clip_start;
v3d->clip_end = settings->clip_end;
v3d->object_type_exclude_viewport = settings->object_type_exclude_viewport;
v3d->object_type_exclude_select = settings->object_type_exclude_select;
rv3d->persp = RV3D_PERSP;
wm_window_make_drawable(wm, win);
ED_view3d_update_viewmat(depsgraph, scene, v3d, region, eye->viewmat, NULL, NULL, true);
if (win_prev) {
wm_window_make_drawable(wm, win_prev);
}
else {
wm_window_clear_drawable(wm);
}
return true;
}
void wm_xr_session_actions_update(const bContext *C)
{
wmWindowManager *wm = CTX_wm_manager(C);
wmXrData *xr = &wm->xr;
if (!xr->runtime) {
return;
@@ -1467,7 +1175,6 @@ void wm_xr_session_actions_update(const bContext *C)
XrSessionSettings *settings = &xr->session_settings;
GHOST_XrContextHandle xr_context = xr->runtime->context;
wmXrSessionState *state = &xr->runtime->session_state;
wmWindow *win = wm_xr_session_root_window_or_fallback_get(wm, xr->runtime);
if (state->is_navigation_dirty) {
memcpy(&state->nav_pose_prev, &state->nav_pose, sizeof(state->nav_pose_prev));
@@ -1482,11 +1189,6 @@ void wm_xr_session_actions_update(const bContext *C)
mat4_to_loc_quat(state->viewer_pose.position, state->viewer_pose.orientation_quat, viewer_mat);
wm_xr_pose_scale_to_imat(
&state->viewer_pose, settings->base_scale * state->nav_scale, state->viewer_viewmat);
wm_xr_pose_scale_to_imat(&state->nav_pose, state->nav_scale, m);
LISTBASE_FOREACH (wmXrEye *, eye, &state->eyes) {
mul_m4_m4m4(eye->viewmat, eye->viewmat_base, m);
}
}
/* Set active action set if requested previously. */
@@ -1496,23 +1198,6 @@ void wm_xr_session_actions_update(const bContext *C)
}
wmXrActionSet *active_action_set = state->active_action_set;
/* Update headset motion capture objects. */
{
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
bScreen *screen_anim = ED_screen_animation_playing(wm);
bool notify = true;
wm_xr_mocap_objects_update(XR_HEADSET_PATH,
&state->viewer_pose,
(bContext *)C,
settings,
scene,
view_layer,
win,
screen_anim,
&notify);
}
const bool synced = GHOST_XrSyncActions(xr_context,
active_action_set ? active_action_set->name : NULL);
if (!synced) {
@@ -1521,27 +1206,28 @@ void wm_xr_session_actions_update(const bContext *C)
/* Only update controller data and dispatch events for active action set. */
if (active_action_set) {
if ((active_action_set->controller_grip_action && active_action_set->controller_aim_action) ||
!BLI_listbase_is_empty(&active_action_set->tracker_actions)) {
wm_xr_session_controller_and_tracker_data_update(active_action_set->controller_grip_action,
active_action_set->controller_aim_action,
&active_action_set->tracker_actions,
(bContext *)C,
settings,
xr_context,
state,
win);
wmWindow *win = wm_xr_session_root_window_or_fallback_get(wm, xr->runtime);
if (active_action_set->controller_grip_action && active_action_set->controller_aim_action) {
wm_xr_session_controller_data_update(settings,
active_action_set->controller_grip_action,
active_action_set->controller_aim_action,
xr_context,
state);
}
if (win && g_xr_surface) {
Scene *scene;
Depsgraph *depsgraph;
wm_xr_session_scene_and_depsgraph_get(wm, &scene, &depsgraph);
if (wm_xr_session_area_ensure(
settings, state, g_xr_surface->customdata, wm, scene, depsgraph, win)) {
wm_xr_session_events_dispatch(xr, xr_context, active_action_set, state, win);
if (win) {
/* Ensure an XR area exists for events. */
if (!xr->runtime->area) {
xr->runtime->area = ED_area_offscreen_create(win, SPACE_VIEW3D);
}
/* Set XR area object type flags for operators. */
View3D *v3d = xr->runtime->area->spacedata.first;
v3d->object_type_exclude_viewport = settings->object_type_exclude_viewport;
v3d->object_type_exclude_select = settings->object_type_exclude_select;
wm_xr_session_events_dispatch(xr, xr_context, active_action_set, state, win);
}
}
}
@@ -1554,13 +1240,15 @@ void wm_xr_session_controller_data_populate(const wmXrAction *grip_action,
wmXrSessionState *state = &xr->runtime->session_state;
ListBase *controllers = &state->controllers;
BLI_assert(grip_action->count_subaction_paths == aim_action->count_subaction_paths);
const uint count = grip_action->count_subaction_paths;
wm_xr_session_controller_data_free(controllers);
wm_xr_session_controller_data_free(state);
for (uint i = 0; i < count; ++i) {
wmXrController *controller = MEM_callocN(sizeof(*controller), __func__);
BLI_assert(STREQ(grip_action->subaction_paths[i], aim_action->subaction_paths[i]));
strcpy(controller->subaction_path, grip_action->subaction_paths[i]);
@@ -1581,7 +1269,7 @@ void wm_xr_session_controller_data_populate(const wmXrAction *grip_action,
void wm_xr_session_controller_data_clear(wmXrSessionState *state)
{
wm_xr_session_controller_data_free(&state->controllers);
wm_xr_session_controller_data_free(state);
/* Deactivate draw callback. */
if (g_xr_surface) {
@@ -1595,53 +1283,6 @@ void wm_xr_session_controller_data_clear(wmXrSessionState *state)
}
}
void wm_xr_session_tracker_data_populate(const ListBase *tracker_actions, wmXrData *xr)
{
wmXrSessionState *state = &xr->runtime->session_state;
ListBase *trackers = &state->trackers;
wm_xr_session_controller_data_free(trackers);
LISTBASE_FOREACH (const LinkData *, ld, tracker_actions) {
const wmXrAction *tracker_action = ld->data;
for (unsigned int subaction_idx = 0; subaction_idx < tracker_action->count_subaction_paths;
++subaction_idx) {
wmXrController *tracker = MEM_callocN(sizeof(*tracker), __func__);
strcpy(tracker->subaction_path, tracker_action->subaction_paths[subaction_idx]);
BLI_addtail(trackers, tracker);
}
}
/* Activate draw callback. */
if (g_xr_surface) {
wmXrSurfaceData *surface_data = g_xr_surface->customdata;
if (surface_data && !surface_data->tracker_draw_handle) {
if (surface_data->controller_art) {
surface_data->tracker_draw_handle = ED_region_draw_cb_activate(
surface_data->controller_art, wm_xr_draw_trackers, xr, REGION_DRAW_POST_VIEW);
}
}
}
}
void wm_xr_session_tracker_data_clear(wmXrSessionState *state)
{
wm_xr_session_controller_data_free(&state->trackers);
/* Deactivate draw callback. */
if (g_xr_surface) {
wmXrSurfaceData *surface_data = g_xr_surface->customdata;
if (surface_data && surface_data->tracker_draw_handle) {
if (surface_data->controller_art) {
ED_region_draw_cb_exit(surface_data->controller_art, surface_data->tracker_draw_handle);
}
surface_data->tracker_draw_handle = NULL;
}
}
}
/** \} */ /* XR-Session Actions */
/* -------------------------------------------------------------------- */

View File

@@ -6,7 +6,6 @@
#pragma once
struct bContext;
struct wmWindowManager;
struct wmXrData;
@@ -17,7 +16,7 @@ typedef void (*wmXrSessionExitFn)(const wmXrData *xr_data);
bool wm_xr_init(wmWindowManager *wm);
void wm_xr_exit(wmWindowManager *wm);
void wm_xr_session_toggle(wmWindowManager *wm, wmWindow *win, wmXrSessionExitFn session_exit_fn);
bool wm_xr_events_handle(const struct bContext *C);
bool wm_xr_events_handle(wmWindowManager *wm);
/* wm_xr_operators.c */