This commit is contained in:
atlv 2025-07-16 19:05:28 -04:00 committed by GitHub
commit c3bc59b3fe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 1 additions and 3530 deletions

View File

@ -118,7 +118,6 @@ These are generally BSD-like, but exact details vary by crate:
If the README of a crate contains a 'License' header (or similar), the additional copyright notices and license terms applicable to that crate will be listed.
The above licensing requirement still applies to contributions to those crates, and sections of those crates will carry those license terms.
The [license](https://doc.rust-lang.org/cargo/reference/manifest.html#the-license-and-license-file-fields) field of each crate will also reflect this.
For example, [`bevy_mikktspace`](./crates/bevy_mikktspace/README.md#license-agreement) has code under the Zlib license (as well as a copyright notice when choosing the MIT license).
The [assets](assets) included in this repository (for our [examples](./examples/README.md)) typically fall under different open licenses.
These will not be included in your game (unless copied in by you), and they are not distributed in the published bevy crates.

View File

@ -16,7 +16,7 @@ bevy_math = { path = "../bevy_math", version = "0.17.0-dev" }
bevy_reflect = { path = "../bevy_reflect", version = "0.17.0-dev" }
bevy_ecs = { path = "../bevy_ecs", version = "0.17.0-dev" }
bevy_transform = { path = "../bevy_transform", version = "0.17.0-dev" }
bevy_mikktspace = { path = "../bevy_mikktspace", version = "0.17.0-dev" }
bevy_mikktspace = { git = "https://github.com/bevyengine/bevy_mikktspace.git", rev = "5c3b737e3e983ee586b2825457574474c6f9eb8e", version = "0.17.0-dev" }
bevy_derive = { path = "../bevy_derive", version = "0.17.0-dev" }
bevy_platform = { path = "../bevy_platform", version = "0.17.0-dev", default-features = false, features = [
"std",

View File

@ -1,36 +0,0 @@
[package]
name = "bevy_mikktspace"
version = "0.17.0-dev"
edition = "2024"
authors = [
"Benjamin Wasty <benny.wasty@gmail.com>",
"David Harvey-Macaulay <alteous@outlook.com>",
"Layl Bongers <LaylConway@users.noreply.github.com>",
]
description = "Mikkelsen tangent space algorithm"
documentation = "https://docs.rs/bevy"
homepage = "https://bevy.org"
repository = "https://github.com/bevyengine/bevy"
license = "Zlib AND (MIT OR Apache-2.0)"
keywords = ["bevy", "3D", "graphics", "algorithm", "tangent"]
rust-version = "1.85.0"
[features]
default = ["std"]
std = ["glam/std"]
libm = ["glam/libm", "dep:libm"]
[dependencies]
glam = { version = "0.29.3", default-features = false }
libm = { version = "0.2", default-features = false, optional = true }
[[example]]
name = "generate"
[lints]
workspace = true
[package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
all-features = true

View File

@ -1,176 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS

View File

@ -1,26 +0,0 @@
Copyright (c) 2017 The mikktspace Library Developers
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

View File

@ -1,41 +0,0 @@
# Bevy Mikktspace
[![License](https://img.shields.io/badge/license-MIT%2FApache%2FZlib-blue.svg)](https://github.com/bevyengine/bevy#license)
[![Crates.io](https://img.shields.io/crates/v/bevy.svg)](https://crates.io/crates/bevy_mikktspace)
[![Downloads](https://img.shields.io/crates/d/bevy_mikktspace.svg)](https://crates.io/crates/bevy_mikktspace)
[![Docs](https://docs.rs/bevy_mikktspace/badge.svg)](https://docs.rs/bevy_mikktspace/latest/bevy_mikktspace/)
[![Discord](https://img.shields.io/discord/691052431525675048.svg?label=&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://discord.gg/bevy)
This is a fork of [https://github.com/gltf-rs/mikktspace](https://github.com/gltf-rs/mikktspace), which in turn is a port of the Mikkelsen Tangent Space Algorithm reference implementation to Rust. It has been forked for use in the bevy game engine to be able to update math crate dependencies in lock-step with bevy releases. It is vendored in the bevy repository itself as [crates/bevy_mikktspace](https://github.com/bevyengine/bevy/tree/main/crates/bevy_mikktspace).
Port of the [Mikkelsen Tangent Space Algorithm](https://archive.blender.org/wiki/2015/index.php/Dev:Shading/Tangent_Space_Normal_Maps/) reference implementation.
Requires at least Rust 1.76.0.
## Examples
### generate
Demonstrates generating tangents for a cube with 4 triangular faces per side.
```sh
cargo run --example generate
```
## License agreement
Licensed under either of
* Apache License, Version 2.0
([LICENSE-APACHE](LICENSE-APACHE) or [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0))
* MIT license
([LICENSE-MIT](LICENSE-MIT) or [http://opensource.org/licenses/MIT](http://opensource.org/licenses/MIT))
at your option. AND parts of the code are licensed under:
* Zlib license
[https://opensource.org/licenses/Zlib](https://opensource.org/licenses/Zlib)
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
dual licensed as above, without any additional terms or conditions.

View File

@ -1,114 +0,0 @@
v 0.5 -0.5 0.5
v 0.5 -0.5 -0.5
v 0.5 0.5 -0.5
v 0.5 0.5 0.5
v 0.5 0 0
v -0.5 0.5 0.5
v -0.5 0.5 -0.5
v -0.5 -0.5 -0.5
v -0.5 -0.5 0.5
v -0.5 0 0
v 0.5 0.5 0.5
v 0.5 0.5 -0.5
v -0.5 0.5 -0.5
v -0.5 0.5 0.5
v 0 0.5 0
v -0.5 -0.5 0.5
v -0.5 -0.5 -0.5
v 0.5 -0.5 -0.5
v 0.5 -0.5 0.5
v 0 -0.5 0
v -0.5 0.5 0.5
v -0.5 -0.5 0.5
v 0.5 -0.5 0.5
v 0.5 0.5 0.5
v 0 0 0.5
v 0.5 0.5 -0.5
v 0.5 -0.5 -0.5
v -0.5 -0.5 -0.5
v -0.5 0.5 -0.5
v 0 0 -0.5
vn 0.57735026 -0.57735026 0.57735026
vn 0.57735026 -0.57735026 -0.57735026
vn 0.57735026 0.57735026 -0.57735026
vn 0.57735026 0.57735026 0.57735026
vn 1 0 0
vn -0.57735026 0.57735026 0.57735026
vn -0.57735026 0.57735026 -0.57735026
vn -0.57735026 -0.57735026 -0.57735026
vn -0.57735026 -0.57735026 0.57735026
vn -1 0 0
vn 0.57735026 0.57735026 0.57735026
vn 0.57735026 0.57735026 -0.57735026
vn -0.57735026 0.57735026 -0.57735026
vn -0.57735026 0.57735026 0.57735026
vn 0 1 0
vn -0.57735026 -0.57735026 0.57735026
vn -0.57735026 -0.57735026 -0.57735026
vn 0.57735026 -0.57735026 -0.57735026
vn 0.57735026 -0.57735026 0.57735026
vn 0 -1 0
vn -0.57735026 0.57735026 0.57735026
vn -0.57735026 -0.57735026 0.57735026
vn 0.57735026 -0.57735026 0.57735026
vn 0.57735026 0.57735026 0.57735026
vn 0 0 1
vn 0.57735026 0.57735026 -0.57735026
vn 0.57735026 -0.57735026 -0.57735026
vn -0.57735026 -0.57735026 -0.57735026
vn -0.57735026 0.57735026 -0.57735026
vn 0 0 -1
vt 0 0
vt 0 1
vt 1 1
vt 1 0
vt 0.5 0.5
vt 1 0
vt 1 1
vt 0 1
vt 0 0
vt 0.5 0.5
vt 0 0
vt 0 1
vt 0 1
vt 0 0
vt 0 0.5
vt 0 0
vt 0 1
vt 0 1
vt 0 0
vt 0 0.5
vt 0 0
vt 0 1
vt 1 1
vt 1 0
vt 0.5 0.5
vt 1 0
vt 1 1
vt 0 1
vt 0 0
vt 0.5 0.5
f 1/1/1 2/2/2 5/5/5
f 2/2/2 3/3/3 5/5/5
f 3/3/3 4/4/4 5/5/5
f 4/4/4 1/1/1 5/5/5
f 6/6/6 7/7/7 10/10/10
f 7/7/7 8/8/8 10/10/10
f 8/8/8 9/9/9 10/10/10
f 9/9/9 6/6/6 10/10/10
f 11/11/11 12/12/12 15/15/15
f 12/12/12 13/13/13 15/15/15
f 13/13/13 14/14/14 15/15/15
f 14/14/14 11/11/11 15/15/15
f 16/16/16 17/17/17 20/20/20
f 17/17/17 18/18/18 20/20/20
f 18/18/18 19/19/19 20/20/20
f 19/19/19 16/16/16 20/20/20
f 21/21/21 22/22/22 25/25/25
f 22/22/22 23/23/23 25/25/25
f 23/23/23 24/24/24 25/25/25
f 24/24/24 21/21/21 25/25/25
f 26/26/26 27/27/27 30/30/30
f 27/27/27 28/28/28 30/30/30
f 28/28/28 29/29/29 30/30/30
f 29/29/29 26/26/26 30/30/30

View File

@ -1,266 +0,0 @@
//! This example demonstrates how to generate a mesh.
#![allow(
clippy::bool_assert_comparison,
clippy::useless_conversion,
reason = "Crate auto-generated with many non-idiomatic decisions. See #7372 for details."
)]
#![expect(clippy::print_stdout, reason = "Allowed in examples.")]
use glam::{Vec2, Vec3};
type Face = [u32; 3];
#[derive(Debug)]
struct Vertex {
position: Vec3,
normal: Vec3,
tex_coord: Vec2,
}
struct Mesh {
faces: Vec<Face>,
vertices: Vec<Vertex>,
}
fn vertex(mesh: &Mesh, face: usize, vert: usize) -> &Vertex {
let vs: &[u32; 3] = &mesh.faces[face];
&mesh.vertices[vs[vert] as usize]
}
impl bevy_mikktspace::Geometry for Mesh {
fn num_faces(&self) -> usize {
self.faces.len()
}
fn num_vertices_of_face(&self, _face: usize) -> usize {
3
}
fn position(&self, face: usize, vert: usize) -> [f32; 3] {
vertex(self, face, vert).position.into()
}
fn normal(&self, face: usize, vert: usize) -> [f32; 3] {
vertex(self, face, vert).normal.into()
}
fn tex_coord(&self, face: usize, vert: usize) -> [f32; 2] {
vertex(self, face, vert).tex_coord.into()
}
fn set_tangent_encoded(&mut self, tangent: [f32; 4], face: usize, vert: usize) {
println!(
"{face}-{vert}: v: {v:?}, vn: {vn:?}, vt: {vt:?}, vx: {vx:?}",
face = face,
vert = vert,
v = vertex(self, face, vert).position,
vn = vertex(self, face, vert).normal,
vt = vertex(self, face, vert).tex_coord,
vx = tangent,
);
}
}
fn make_cube() -> Mesh {
struct ControlPoint {
uv: [f32; 2],
dir: [f32; 3],
}
let mut faces = Vec::new();
let mut ctl_pts = Vec::new();
let mut vertices = Vec::new();
// +x plane
{
let base = ctl_pts.len() as u32;
faces.push([base, base + 1, base + 4]);
faces.push([base + 1, base + 2, base + 4]);
faces.push([base + 2, base + 3, base + 4]);
faces.push([base + 3, base, base + 4]);
ctl_pts.push(ControlPoint {
uv: [0.0, 0.0],
dir: [1.0, -1.0, 1.0],
});
ctl_pts.push(ControlPoint {
uv: [0.0, 1.0],
dir: [1.0, -1.0, -1.0],
});
ctl_pts.push(ControlPoint {
uv: [1.0, 1.0],
dir: [1.0, 1.0, -1.0],
});
ctl_pts.push(ControlPoint {
uv: [1.0, 0.0],
dir: [1.0, 1.0, 1.0],
});
ctl_pts.push(ControlPoint {
uv: [0.5, 0.5],
dir: [1.0, 0.0, 0.0],
});
}
// -x plane
{
let base = ctl_pts.len() as u32;
faces.push([base, base + 1, base + 4]);
faces.push([base + 1, base + 2, base + 4]);
faces.push([base + 2, base + 3, base + 4]);
faces.push([base + 3, base, base + 4]);
ctl_pts.push(ControlPoint {
uv: [1.0, 0.0],
dir: [-1.0, 1.0, 1.0],
});
ctl_pts.push(ControlPoint {
uv: [1.0, 1.0],
dir: [-1.0, 1.0, -1.0],
});
ctl_pts.push(ControlPoint {
uv: [0.0, 1.0],
dir: [-1.0, -1.0, -1.0],
});
ctl_pts.push(ControlPoint {
uv: [0.0, 0.0],
dir: [-1.0, -1.0, 1.0],
});
ctl_pts.push(ControlPoint {
uv: [0.5, 0.5],
dir: [-1.0, 0.0, 0.0],
});
}
// +y plane
{
let base = ctl_pts.len() as u32;
faces.push([base, base + 1, base + 4]);
faces.push([base + 1, base + 2, base + 4]);
faces.push([base + 2, base + 3, base + 4]);
faces.push([base + 3, base, base + 4]);
ctl_pts.push(ControlPoint {
uv: [0.0, 0.0],
dir: [1.0, 1.0, 1.0],
});
ctl_pts.push(ControlPoint {
uv: [0.0, 1.0],
dir: [1.0, 1.0, -1.0],
});
ctl_pts.push(ControlPoint {
uv: [0.0, 1.0],
dir: [-1.0, 1.0, -1.0],
});
ctl_pts.push(ControlPoint {
uv: [0.0, 0.0],
dir: [-1.0, 1.0, 1.0],
});
ctl_pts.push(ControlPoint {
uv: [0.0, 0.5],
dir: [0.0, 1.0, 0.0],
});
}
// -y plane
{
let base = ctl_pts.len() as u32;
faces.push([base, base + 1, base + 4]);
faces.push([base + 1, base + 2, base + 4]);
faces.push([base + 2, base + 3, base + 4]);
faces.push([base + 3, base, base + 4]);
ctl_pts.push(ControlPoint {
uv: [0.0, 0.0],
dir: [-1.0, -1.0, 1.0],
});
ctl_pts.push(ControlPoint {
uv: [0.0, 1.0],
dir: [-1.0, -1.0, -1.0],
});
ctl_pts.push(ControlPoint {
uv: [0.0, 1.0],
dir: [1.0, -1.0, -1.0],
});
ctl_pts.push(ControlPoint {
uv: [0.0, 0.0],
dir: [1.0, -1.0, 1.0],
});
ctl_pts.push(ControlPoint {
uv: [0.0, 0.5],
dir: [0.0, -1.0, 0.0],
});
}
// +z plane
{
let base = ctl_pts.len() as u32;
faces.push([base, base + 1, base + 4]);
faces.push([base + 1, base + 2, base + 4]);
faces.push([base + 2, base + 3, base + 4]);
faces.push([base + 3, base, base + 4]);
ctl_pts.push(ControlPoint {
uv: [0.0, 0.0],
dir: [-1.0, 1.0, 1.0],
});
ctl_pts.push(ControlPoint {
uv: [0.0, 1.0],
dir: [-1.0, -1.0, 1.0],
});
ctl_pts.push(ControlPoint {
uv: [1.0, 1.0],
dir: [1.0, -1.0, 1.0],
});
ctl_pts.push(ControlPoint {
uv: [1.0, 0.0],
dir: [1.0, 1.0, 1.0],
});
ctl_pts.push(ControlPoint {
uv: [0.5, 0.5],
dir: [0.0, 0.0, 1.0],
});
}
// -z plane
{
let base = ctl_pts.len() as u32;
faces.push([base, base + 1, base + 4]);
faces.push([base + 1, base + 2, base + 4]);
faces.push([base + 2, base + 3, base + 4]);
faces.push([base + 3, base, base + 4]);
ctl_pts.push(ControlPoint {
uv: [1.0, 0.0],
dir: [1.0, 1.0, -1.0],
});
ctl_pts.push(ControlPoint {
uv: [1.0, 1.0],
dir: [1.0, -1.0, -1.0],
});
ctl_pts.push(ControlPoint {
uv: [0.0, 1.0],
dir: [-1.0, -1.0, -1.0],
});
ctl_pts.push(ControlPoint {
uv: [0.0, 0.0],
dir: [-1.0, 1.0, -1.0],
});
ctl_pts.push(ControlPoint {
uv: [0.5, 0.5],
dir: [0.0, 0.0, -1.0],
});
}
for pt in ctl_pts {
let p: Vec3 = pt.dir.into();
let n: Vec3 = p.normalize();
let t: Vec2 = pt.uv.into();
vertices.push(Vertex {
position: (p / 2.0).into(),
normal: n.into(),
tex_coord: t.into(),
});
}
Mesh { faces, vertices }
}
fn main() {
let mut cube = make_cube();
let ret = bevy_mikktspace::generate_tangents(&mut cube);
assert_eq!(true, ret);
}

File diff suppressed because it is too large Load Diff

View File

@ -1,111 +0,0 @@
#![allow(
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
reason = "Much of the code here is still code that's been transpiled from C; we want to save 'fixing' this crate until after it's ported to safe rust."
)]
#![allow(
unsafe_op_in_unsafe_fn,
clippy::all,
clippy::undocumented_unsafe_blocks,
clippy::ptr_cast_constness
)]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![doc(
html_logo_url = "https://bevy.org/assets/icon.png",
html_favicon_url = "https://bevy.org/assets/icon.png"
)]
#![no_std]
//! An implementation of [Mikkelsen's algorithm] for tangent space generation.
//!
//! [Mikkelsen's algorithm]: http://www.mikktspace.com
#[cfg(feature = "std")]
extern crate std;
extern crate alloc;
use glam::{Vec2, Vec3};
mod generated;
/// The interface by which mikktspace interacts with your geometry.
pub trait Geometry {
/// Returns the number of faces.
fn num_faces(&self) -> usize;
/// Returns the number of vertices of a face.
fn num_vertices_of_face(&self, face: usize) -> usize;
/// Returns the position of a vertex.
fn position(&self, face: usize, vert: usize) -> [f32; 3];
/// Returns the normal of a vertex.
fn normal(&self, face: usize, vert: usize) -> [f32; 3];
/// Returns the texture coordinate of a vertex.
fn tex_coord(&self, face: usize, vert: usize) -> [f32; 2];
/// Sets the generated tangent for a vertex.
/// Leave this function unimplemented if you are implementing
/// `set_tangent_encoded`.
fn set_tangent(
&mut self,
tangent: [f32; 3],
_bi_tangent: [f32; 3],
_f_mag_s: f32,
_f_mag_t: f32,
bi_tangent_preserves_orientation: bool,
face: usize,
vert: usize,
) {
let sign = if bi_tangent_preserves_orientation {
1.0
} else {
-1.0
};
self.set_tangent_encoded([tangent[0], tangent[1], tangent[2], sign], face, vert);
}
/// Sets the generated tangent for a vertex with its bi-tangent encoded as the 'W' (4th)
/// component in the tangent. The 'W' component marks if the bi-tangent is flipped. This
/// is called by the default implementation of `set_tangent`; therefore, this function will
/// not be called by the crate unless `set_tangent` is unimplemented.
fn set_tangent_encoded(&mut self, _tangent: [f32; 4], _face: usize, _vert: usize) {}
}
/// Generates tangents for the input geometry.
///
/// # Errors
///
/// Returns `false` if the geometry is unsuitable for tangent generation including,
/// but not limited to, lack of vertices.
#[allow(unsafe_code)]
pub fn generate_tangents<I: Geometry>(geometry: &mut I) -> bool {
unsafe { generated::genTangSpace(geometry, 180.0) }
}
fn get_position<I: Geometry>(geometry: &mut I, index: usize) -> Vec3 {
let (face, vert) = index_to_face_vert(index);
geometry.position(face, vert).into()
}
fn get_tex_coord<I: Geometry>(geometry: &mut I, index: usize) -> Vec3 {
let (face, vert) = index_to_face_vert(index);
let tex_coord: Vec2 = geometry.tex_coord(face, vert).into();
let val = tex_coord.extend(1.0);
val
}
fn get_normal<I: Geometry>(geometry: &mut I, index: usize) -> Vec3 {
let (face, vert) = index_to_face_vert(index);
geometry.normal(face, vert).into()
}
fn index_to_face_vert(index: usize) -> (usize, usize) {
(index >> 2, index & 0x3)
}
fn face_vert_to_index(face: usize, vert: usize) -> usize {
face << 2 | vert & 0x3
}

View File

@ -1,887 +0,0 @@
#![expect(missing_docs, reason = "Not all docs are written yet, see #3492.")]
#![expect(
clippy::bool_assert_comparison,
clippy::semicolon_if_nothing_returned,
clippy::useless_conversion,
reason = "Crate auto-generated with many non-idiomatic decisions. See #7372 for details."
)]
use bevy_mikktspace::{generate_tangents, Geometry};
use glam::{Vec2, Vec3};
pub type Face = [u32; 3];
#[derive(Debug)]
struct Vertex {
position: Vec3,
normal: Vec3,
tex_coord: Vec2,
}
#[derive(Debug, PartialEq)]
struct Result {
tangent: [f32; 3],
bi_tangent: [f32; 3],
mag_s: f32,
mag_t: f32,
bi_tangent_preserves_orientation: bool,
face: usize,
vert: usize,
}
impl Result {
fn new(
tangent: [f32; 3],
bi_tangent: [f32; 3],
mag_s: f32,
mag_t: f32,
bi_tangent_preserves_orientation: bool,
face: usize,
vert: usize,
) -> Self {
Self {
tangent,
bi_tangent,
mag_s,
mag_t,
bi_tangent_preserves_orientation,
face,
vert,
}
}
}
struct Mesh {
faces: Vec<Face>,
vertices: Vec<Vertex>,
}
struct Context {
mesh: Mesh,
results: Vec<Result>,
}
fn vertex(mesh: &Mesh, face: usize, vert: usize) -> &Vertex {
let vs: &[u32; 3] = &mesh.faces[face];
&mesh.vertices[vs[vert] as usize]
}
impl Geometry for Context {
fn num_faces(&self) -> usize {
self.mesh.faces.len()
}
fn num_vertices_of_face(&self, _face: usize) -> usize {
3
}
fn position(&self, face: usize, vert: usize) -> [f32; 3] {
vertex(&self.mesh, face, vert).position.into()
}
fn normal(&self, face: usize, vert: usize) -> [f32; 3] {
vertex(&self.mesh, face, vert).normal.into()
}
fn tex_coord(&self, face: usize, vert: usize) -> [f32; 2] {
vertex(&self.mesh, face, vert).tex_coord.into()
}
fn set_tangent(
&mut self,
tangent: [f32; 3],
bi_tangent: [f32; 3],
mag_s: f32,
mag_t: f32,
bi_tangent_preserves_orientation: bool,
face: usize,
vert: usize,
) {
self.results.push(Result {
tangent,
bi_tangent,
mag_s,
mag_t,
bi_tangent_preserves_orientation,
face,
vert,
})
}
}
struct ControlPoint {
uv: [f32; 2],
dir: [f32; 3],
}
impl ControlPoint {
fn new(uv: [f32; 2], dir: [f32; 3]) -> Self {
Self { uv, dir }
}
}
fn make_cube() -> Mesh {
let mut faces = Vec::new();
let mut ctl_pts = Vec::new();
let mut vertices = Vec::new();
// +x plane
{
let base = ctl_pts.len() as u32;
faces.push([base, base + 1, base + 4]);
faces.push([base + 1, base + 2, base + 4]);
faces.push([base + 2, base + 3, base + 4]);
faces.push([base + 3, base, base + 4]);
ctl_pts.push(ControlPoint::new([0.0, 0.0], [1.0, -1.0, 1.0]));
ctl_pts.push(ControlPoint::new([0.0, 1.0], [1.0, -1.0, -1.0]));
ctl_pts.push(ControlPoint::new([1.0, 1.0], [1.0, 1.0, -1.0]));
ctl_pts.push(ControlPoint::new([1.0, 0.0], [1.0, 1.0, 1.0]));
ctl_pts.push(ControlPoint::new([0.5, 0.5], [1.0, 0.0, 0.0]));
}
// -x plane
{
let base = ctl_pts.len() as u32;
faces.push([base, base + 1, base + 4]);
faces.push([base + 1, base + 2, base + 4]);
faces.push([base + 2, base + 3, base + 4]);
faces.push([base + 3, base, base + 4]);
ctl_pts.push(ControlPoint::new([1.0, 0.0], [-1.0, 1.0, 1.0]));
ctl_pts.push(ControlPoint::new([1.0, 1.0], [-1.0, 1.0, -1.0]));
ctl_pts.push(ControlPoint::new([0.0, 1.0], [-1.0, -1.0, -1.0]));
ctl_pts.push(ControlPoint::new([0.0, 0.0], [-1.0, -1.0, 1.0]));
ctl_pts.push(ControlPoint::new([0.5, 0.5], [-1.0, 0.0, 0.0]));
}
// +y plane
{
let base = ctl_pts.len() as u32;
faces.push([base, base + 1, base + 4]);
faces.push([base + 1, base + 2, base + 4]);
faces.push([base + 2, base + 3, base + 4]);
faces.push([base + 3, base, base + 4]);
ctl_pts.push(ControlPoint::new([0.0, 0.0], [1.0, 1.0, 1.0]));
ctl_pts.push(ControlPoint::new([0.0, 1.0], [1.0, 1.0, -1.0]));
ctl_pts.push(ControlPoint::new([0.0, 1.0], [-1.0, 1.0, -1.0]));
ctl_pts.push(ControlPoint::new([0.0, 0.0], [-1.0, 1.0, 1.0]));
ctl_pts.push(ControlPoint::new([0.0, 0.5], [0.0, 1.0, 0.0]));
}
// -y plane
{
let base = ctl_pts.len() as u32;
faces.push([base, base + 1, base + 4]);
faces.push([base + 1, base + 2, base + 4]);
faces.push([base + 2, base + 3, base + 4]);
faces.push([base + 3, base, base + 4]);
ctl_pts.push(ControlPoint::new([0.0, 0.0], [-1.0, -1.0, 1.0]));
ctl_pts.push(ControlPoint::new([0.0, 1.0], [-1.0, -1.0, -1.0]));
ctl_pts.push(ControlPoint::new([0.0, 1.0], [1.0, -1.0, -1.0]));
ctl_pts.push(ControlPoint::new([0.0, 0.0], [1.0, -1.0, 1.0]));
ctl_pts.push(ControlPoint::new([0.0, 0.5], [0.0, -1.0, 0.0]));
}
// +z plane
{
let base = ctl_pts.len() as u32;
faces.push([base, base + 1, base + 4]);
faces.push([base + 1, base + 2, base + 4]);
faces.push([base + 2, base + 3, base + 4]);
faces.push([base + 3, base, base + 4]);
ctl_pts.push(ControlPoint::new([0.0, 0.0], [-1.0, 1.0, 1.0]));
ctl_pts.push(ControlPoint::new([0.0, 1.0], [-1.0, -1.0, 1.0]));
ctl_pts.push(ControlPoint::new([1.0, 1.0], [1.0, -1.0, 1.0]));
ctl_pts.push(ControlPoint::new([1.0, 0.0], [1.0, 1.0, 1.0]));
ctl_pts.push(ControlPoint::new([0.5, 0.5], [0.0, 0.0, 1.0]));
}
// -z plane
{
let base = ctl_pts.len() as u32;
faces.push([base, base + 1, base + 4]);
faces.push([base + 1, base + 2, base + 4]);
faces.push([base + 2, base + 3, base + 4]);
faces.push([base + 3, base, base + 4]);
ctl_pts.push(ControlPoint::new([1.0, 0.0], [1.0, 1.0, -1.0]));
ctl_pts.push(ControlPoint::new([1.0, 1.0], [1.0, -1.0, -1.0]));
ctl_pts.push(ControlPoint::new([0.0, 1.0], [-1.0, -1.0, -1.0]));
ctl_pts.push(ControlPoint::new([0.0, 0.0], [-1.0, 1.0, -1.0]));
ctl_pts.push(ControlPoint::new([0.5, 0.5], [0.0, 0.0, -1.0]));
}
for pt in ctl_pts {
let p: Vec3 = pt.dir.into();
let n: Vec3 = p.normalize();
let t: Vec2 = pt.uv.into();
vertices.push(Vertex {
position: (p / 2.0).into(),
normal: n.into(),
tex_coord: t.into(),
});
}
Mesh { faces, vertices }
}
#[test]
fn cube_tangents_should_equal_reference_values() {
let mut context = Context {
mesh: make_cube(),
results: Vec::new(),
};
let ret = generate_tangents(&mut context);
assert_eq!(true, ret);
let expected_results: Vec<Result> = vec![
Result::new(
[0.40824825, 0.81649655, 0.40824825],
[0.40824825, -0.40824825, -0.81649655],
1.00000000,
1.00000000,
false,
0,
0,
),
Result::new(
[0.40824825, 0.81649655, -0.40824825],
[-0.40824825, 0.40824825, -0.81649655],
1.00000000,
1.00000000,
false,
0,
1,
),
Result::new(
[0.00000000, 1.00000000, 0.00000000],
[0.00000000, 0.00000000, -1.00000000],
1.00000000,
1.00000000,
false,
0,
2,
),
Result::new(
[0.40824825, 0.81649655, -0.40824825],
[-0.40824825, 0.40824825, -0.81649655],
1.00000000,
1.00000000,
false,
1,
0,
),
Result::new(
[-0.40824825, 0.81649655, 0.40824825],
[-0.40824825, -0.40824825, -0.81649655],
1.00000000,
1.00000000,
false,
1,
1,
),
Result::new(
[0.00000000, 1.00000000, 0.00000000],
[0.00000000, 0.00000000, -1.00000000],
1.00000000,
1.00000000,
false,
1,
2,
),
Result::new(
[-0.40824825, 0.81649655, 0.40824825],
[-0.40824825, -0.40824825, -0.81649655],
1.00000000,
1.00000000,
false,
2,
0,
),
Result::new(
[-0.40824825, 0.81649655, -0.40824825],
[0.40824825, 0.40824825, -0.81649655],
1.00000000,
1.00000000,
false,
2,
1,
),
Result::new(
[0.00000000, 1.00000000, 0.00000000],
[0.00000000, 0.00000000, -1.00000000],
1.00000000,
1.00000000,
false,
2,
2,
),
Result::new(
[-0.40824825, 0.81649655, -0.40824825],
[0.40824825, 0.40824825, -0.81649655],
1.00000000,
1.00000000,
false,
3,
0,
),
Result::new(
[0.40824825, 0.81649655, 0.40824825],
[0.40824825, -0.40824825, -0.81649655],
1.00000000,
1.00000000,
false,
3,
1,
),
Result::new(
[0.00000000, 1.00000000, 0.00000000],
[0.00000000, 0.00000000, -1.00000000],
1.00000000,
1.00000000,
false,
3,
2,
),
Result::new(
[0.40824825, 0.81649655, -0.40824825],
[-0.40824825, 0.40824825, -0.81649655],
1.00000000,
1.00000000,
true,
4,
0,
),
Result::new(
[0.40824825, 0.81649655, 0.40824825],
[0.40824825, -0.40824825, -0.81649655],
1.00000000,
1.00000000,
true,
4,
1,
),
Result::new(
[0.00000000, 1.00000000, 0.00000000],
[0.00000000, 0.00000000, -1.00000000],
1.00000000,
1.00000000,
true,
4,
2,
),
Result::new(
[0.40824825, 0.81649655, 0.40824825],
[0.40824825, -0.40824825, -0.81649655],
1.00000000,
1.00000000,
true,
5,
0,
),
Result::new(
[-0.40824825, 0.81649655, -0.40824825],
[0.40824825, 0.40824825, -0.81649655],
1.00000000,
1.00000000,
true,
5,
1,
),
Result::new(
[0.00000000, 1.00000000, 0.00000000],
[0.00000000, 0.00000000, -1.00000000],
1.00000000,
1.00000000,
true,
5,
2,
),
Result::new(
[-0.40824825, 0.81649655, -0.40824825],
[0.40824825, 0.40824825, -0.81649655],
1.00000000,
1.00000000,
true,
6,
0,
),
Result::new(
[-0.40824825, 0.81649655, 0.40824825],
[-0.40824825, -0.40824825, -0.81649655],
1.00000000,
1.00000000,
true,
6,
1,
),
Result::new(
[0.00000000, 1.00000000, 0.00000000],
[0.00000000, 0.00000000, -1.00000000],
1.00000000,
1.00000000,
true,
6,
2,
),
Result::new(
[-0.40824825, 0.81649655, 0.40824825],
[-0.40824825, -0.40824825, -0.81649655],
1.00000000,
1.00000000,
true,
7,
0,
),
Result::new(
[0.40824825, 0.81649655, -0.40824825],
[-0.40824825, 0.40824825, -0.81649655],
1.00000000,
1.00000000,
true,
7,
1,
),
Result::new(
[0.00000000, 1.00000000, 0.00000000],
[0.00000000, 0.00000000, -1.00000000],
1.00000000,
1.00000000,
true,
7,
2,
),
Result::new(
[1.00000000, 0.00000000, 0.00000000],
[0.00000000, 1.00000000, 0.00000000],
1.00000000,
1.00000000,
false,
8,
0,
),
Result::new(
[1.00000000, 0.00000000, 0.00000000],
[0.00000000, 1.00000000, 0.00000000],
1.00000000,
1.00000000,
false,
8,
1,
),
Result::new(
[1.00000000, 0.00000000, 0.00000000],
[0.00000000, 1.00000000, 0.00000000],
1.00000000,
1.00000000,
false,
8,
2,
),
Result::new(
[1.00000000, 0.00000000, 0.00000000],
[0.00000000, 1.00000000, 0.00000000],
1.00000000,
1.00000000,
false,
9,
0,
),
Result::new(
[1.00000000, 0.00000000, 0.00000000],
[0.00000000, 1.00000000, 0.00000000],
1.00000000,
1.00000000,
false,
9,
1,
),
Result::new(
[1.00000000, 0.00000000, 0.00000000],
[0.00000000, 1.00000000, 0.00000000],
1.00000000,
1.00000000,
false,
9,
2,
),
Result::new(
[1.00000000, 0.00000000, 0.00000000],
[0.00000000, 1.00000000, 0.00000000],
1.00000000,
1.00000000,
false,
10,
0,
),
Result::new(
[1.00000000, 0.00000000, 0.00000000],
[0.00000000, 1.00000000, 0.00000000],
1.00000000,
1.00000000,
false,
10,
1,
),
Result::new(
[1.00000000, 0.00000000, 0.00000000],
[0.00000000, 1.00000000, 0.00000000],
1.00000000,
1.00000000,
false,
10,
2,
),
Result::new(
[1.00000000, 0.00000000, 0.00000000],
[0.00000000, 1.00000000, 0.00000000],
1.00000000,
1.00000000,
false,
11,
0,
),
Result::new(
[1.00000000, 0.00000000, 0.00000000],
[0.00000000, 1.00000000, 0.00000000],
1.00000000,
1.00000000,
false,
11,
1,
),
Result::new(
[1.00000000, 0.00000000, 0.00000000],
[0.00000000, 1.00000000, 0.00000000],
1.00000000,
1.00000000,
false,
11,
2,
),
Result::new(
[-0.40824825, 0.81649655, 0.40824825],
[-0.40824825, -0.40824825, -0.81649655],
1.00000000,
1.00000000,
true,
12,
0,
),
Result::new(
[-0.40824825, 0.81649655, -0.40824825],
[0.40824825, 0.40824825, -0.81649655],
1.00000000,
1.00000000,
true,
12,
1,
),
Result::new(
[1.00000000, 0.00000000, 0.00000000],
[0.00000000, 1.00000000, 0.00000000],
1.00000000,
1.00000000,
false,
12,
2,
),
Result::new(
[1.00000000, 0.00000000, 0.00000000],
[0.00000000, 1.00000000, 0.00000000],
1.00000000,
1.00000000,
false,
13,
0,
),
Result::new(
[0.40824825, 0.81649655, -0.40824825],
[-0.40824825, 0.40824825, -0.81649655],
1.00000000,
1.00000000,
false,
13,
1,
),
Result::new(
[1.00000000, 0.00000000, 0.00000000],
[0.00000000, 1.00000000, 0.00000000],
1.00000000,
1.00000000,
false,
13,
2,
),
Result::new(
[0.40824825, 0.81649655, -0.40824825],
[-0.40824825, 0.40824825, -0.81649655],
1.00000000,
1.00000000,
false,
14,
0,
),
Result::new(
[0.40824825, 0.81649655, 0.40824825],
[0.40824825, -0.40824825, -0.81649655],
1.00000000,
1.00000000,
false,
14,
1,
),
Result::new(
[1.00000000, 0.00000000, 0.00000000],
[0.00000000, 1.00000000, 0.00000000],
1.00000000,
1.00000000,
false,
14,
2,
),
Result::new(
[0.40824825, 0.81649655, 0.40824825],
[0.40824825, -0.40824825, -0.81649655],
1.00000000,
1.00000000,
false,
15,
0,
),
Result::new(
[1.00000000, 0.00000000, 0.00000000],
[0.00000000, 1.00000000, 0.00000000],
1.00000000,
1.00000000,
false,
15,
1,
),
Result::new(
[1.00000000, 0.00000000, 0.00000000],
[0.00000000, 1.00000000, 0.00000000],
1.00000000,
1.00000000,
false,
15,
2,
),
Result::new(
[0.81649655, 0.40824825, 0.40824825],
[-0.40824825, -0.81649655, 0.40824825],
1.00000000,
1.00000000,
false,
16,
0,
),
Result::new(
[0.81649655, -0.40824825, 0.40824825],
[0.40824825, -0.81649655, -0.40824825],
1.00000000,
1.00000000,
false,
16,
1,
),
Result::new(
[1.00000000, 0.00000000, 0.00000000],
[0.00000000, -1.00000000, 0.00000000],
1.00000000,
1.00000000,
false,
16,
2,
),
Result::new(
[0.81649655, -0.40824825, 0.40824825],
[0.40824825, -0.81649655, -0.40824825],
1.00000000,
1.00000000,
false,
17,
0,
),
Result::new(
[0.81649655, 0.40824825, -0.40824825],
[-0.40824825, -0.81649655, -0.40824825],
1.00000000,
1.00000000,
false,
17,
1,
),
Result::new(
[1.00000000, 0.00000000, 0.00000000],
[0.00000000, -1.00000000, 0.00000000],
1.00000000,
1.00000000,
false,
17,
2,
),
Result::new(
[0.81649655, 0.40824825, -0.40824825],
[-0.40824825, -0.81649655, -0.40824825],
1.00000000,
1.00000000,
false,
18,
0,
),
Result::new(
[0.81649655, -0.40824825, -0.40824825],
[0.40824825, -0.81649655, 0.40824825],
1.00000000,
1.00000000,
false,
18,
1,
),
Result::new(
[1.00000000, 0.00000000, 0.00000000],
[0.00000000, -1.00000000, 0.00000000],
1.00000000,
1.00000000,
false,
18,
2,
),
Result::new(
[0.81649655, -0.40824825, -0.40824825],
[0.40824825, -0.81649655, 0.40824825],
1.00000000,
1.00000000,
false,
19,
0,
),
Result::new(
[0.81649655, 0.40824825, 0.40824825],
[-0.40824825, -0.81649655, 0.40824825],
1.00000000,
1.00000000,
false,
19,
1,
),
Result::new(
[1.00000000, 0.00000000, 0.00000000],
[0.00000000, -1.00000000, 0.00000000],
1.00000000,
1.00000000,
false,
19,
2,
),
Result::new(
[0.81649655, -0.40824825, 0.40824825],
[0.40824825, -0.81649655, -0.40824825],
1.00000000,
1.00000000,
true,
20,
0,
),
Result::new(
[0.81649655, 0.40824825, 0.40824825],
[-0.40824825, -0.81649655, 0.40824825],
1.00000000,
1.00000000,
true,
20,
1,
),
Result::new(
[1.00000000, 0.00000000, 0.00000000],
[0.00000000, -1.00000000, 0.00000000],
1.00000000,
1.00000000,
true,
20,
2,
),
Result::new(
[0.81649655, 0.40824825, 0.40824825],
[-0.40824825, -0.81649655, 0.40824825],
1.00000000,
1.00000000,
true,
21,
0,
),
Result::new(
[0.81649655, -0.40824825, -0.40824825],
[0.40824825, -0.81649655, 0.40824825],
1.00000000,
1.00000000,
true,
21,
1,
),
Result::new(
[1.00000000, 0.00000000, 0.00000000],
[0.00000000, -1.00000000, 0.00000000],
1.00000000,
1.00000000,
true,
21,
2,
),
Result::new(
[0.81649655, -0.40824825, -0.40824825],
[0.40824825, -0.81649655, 0.40824825],
1.00000000,
1.00000000,
true,
22,
0,
),
Result::new(
[0.81649655, 0.40824825, -0.40824825],
[-0.40824825, -0.81649655, -0.40824825],
1.00000000,
1.00000000,
true,
22,
1,
),
Result::new(
[1.00000000, 0.00000000, 0.00000000],
[0.00000000, -1.00000000, 0.00000000],
1.00000000,
1.00000000,
true,
22,
2,
),
Result::new(
[0.81649655, 0.40824825, -0.40824825],
[-0.40824825, -0.81649655, -0.40824825],
1.00000000,
1.00000000,
true,
23,
0,
),
Result::new(
[0.81649655, -0.40824825, 0.40824825],
[0.40824825, -0.81649655, -0.40824825],
1.00000000,
1.00000000,
true,
23,
1,
),
Result::new(
[1.00000000, 0.00000000, 0.00000000],
[0.00000000, -1.00000000, 0.00000000],
1.00000000,
1.00000000,
true,
23,
2,
),
];
assert_eq!(expected_results, context.results);
}