Files
cocos4/native/cocos/core/geometry/Spec.h
T
James Chen 024737aebc fixed #11195: Rename cc::optional, cc::any, cc::variant to ccstd::optional, ccstd::any, ccstd::variant (#11197)
* Move Any.h/Optional.h/Variant.h to base/std and rename them to lowercase.

* fixed #11195: Rename cc::optional, cc::any, cc::variant to ccstd::optional, ccstd::any, ccstd::variant

* Format code.
2022-05-24 18:47:16 +08:00

151 lines
2.9 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#pragma once
#include <cfloat>
#include <cstdint>
#include "base/std/container/vector.h"
#include "base/std/optional.h"
namespace cc {
namespace geometry {
/**
* @en
* The raycast mode.
* @zh
* 射线检测模式。
*/
enum class ERaycastMode {
/**
* @en
* Detect and record all data.
* @zh
* 检测并记录所有的数据。
*/
ALL,
/**
* @en
* Detect all, but record only the most recent data.
* @zh
* 检测所有,但只记录最近的数据。
*/
CLOSEST,
/**
* @en
* Once the test is successful, the test is stopped and the data is recorded only once.
* @zh
* 一旦检测成功就停止检测,只会记录一次数据。
*/
ANY,
};
/**
* @en
* The storage structure of the raycast results.
* @zh
* 射线检测结果的存储结构。
*/
struct IRaySubMeshResult {
/**
* @en
* The distance between the hit point and the ray.
* @zh
* 击中点和射线的距离。
*/
float distance{0.0F};
/**
* @en
* The index of the triangle vertex 0。
* @zh
* 三角形顶点0的索引。
*/
uint32_t vertexIndex0{0};
/**
* @en
* The index of the triangle vertex 1。
* @zh
* 三角形顶点1的索引
*/
uint32_t vertexIndex1{0};
/**
* @en
* The index of the triangle vertex 2。
* @zh
* 三角形顶点2的索引
*/
uint32_t vertexIndex2{0};
};
/**
* @en
* The optional param structure of the `raySubMesh`.
* @zh
* `raySubMesh`的可选参数结构。
*/
struct IRaySubMeshOptions {
/**
* @en
* The raycast mode,`ANY` by default.
* @zh
* 射线检测模式:[0, 1, 2]=>[`ALL`, `CLOSEST`, `ANY`]
*/
ERaycastMode mode;
/**
* @en
* The maximum distance of the raycast, `Infinity` by default.
* @zh
* 射线检测的最大距离,默认为`Infinity`。
*/
float distance = FLT_MAX;
/**
* @en
* An array used to store the results of a ray detection.
* @zh
* 用于存储射线检测结果的数组。
*/
ccstd::optional<ccstd::vector<IRaySubMeshResult>> result{};
/**
* @en
* Whether to detect the double-sided or not,`false` by default.
* @zh
* 是否检测双面,默认为`false`。
*/
bool doubleSided{false};
};
/**
* @en
* The optional param structure of the `rayMesh`.
* @zh
* `rayMesh`的可选参数结构。
*/
struct IRayMeshOptions : public IRaySubMeshOptions {
/**
* @en
* The index of the sub mesh.
* @zh
* 子网格的索引。
*/
ccstd::optional<ccstd::vector<uint32_t>> subIndices{};
};
/**
* @en
* The optional param structure of the `rayModel`.
* @zh
* `rayModel`的可选参数结构。
*/
using IRayModelOptions = IRayMeshOptions;
} // namespace geometry
} // namespace cc