Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[FR] math.all + math.any for multi dimensional boolean

未关闭
#225 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
38/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
csharp

调研方向

该 issue 未指定文件或测试;请在 Unity.Mathematics 源码中搜索现有的 math.all 和 math.any 向量重载,并检查矩阵类型如何公开其列。为列出的 bool2x2 到 bool4x4 情况添加相应支持,然后验证示例多维布尔表达式能够编译,并按轴产生所要求的结果。

由索引模型根据 Issue 内容生成。

描述

        public static bool2 all(bool2x2 m) { return new bool2(all(m.c0),all(m.c1)); }
        public static bool2 all(bool3x2 m) { return new bool2(all(m.c0),all(m.c1)); }
        public static bool2 all(bool4x2 m) { return new bool2(all(m.c0),all(m.c1)); }

        public static bool2 any(bool2x2 m) { return new bool2(any(m.c0),any(m.c1)); }
        public static bool2 any(bool3x2 m) { return new bool2(any(m.c0),any(m.c1)); }
        public static bool2 any(bool4x2 m) { return new bool2(any(m.c0),any(m.c1)); }
        
        public static bool3 all(bool2x3 m) { return new bool3(all(m.c0),all(m.c1),all(m.c2)); }
        public static bool3 all(bool3x3 m) { return new bool3(all(m.c0),all(m.c1),all(m.c2)); }
        public static bool3 all(bool4x3 m) { return new bool3(all(m.c0),all(m.c1),all(m.c2)); }

        public static bool3 any(bool2x3 m) { return new bool3(any(m.c0),any(m.c1),any(m.c2)); }
        public static bool3 any(bool3x3 m) { return new bool3(any(m.c0),any(m.c1),any(m.c2)); }
        public static bool3 any(bool4x3 m) { return new bool3(any(m.c0),any(m.c1),any(m.c2)); }
        
        public static bool4 all(bool2x4 m) { return new bool4(all(m.c0),all(m.c1),all(m.c2),all(m.c3)); }
        public static bool4 all(bool3x4 m) { return new bool4(all(m.c0),all(m.c1),all(m.c2),all(m.c3)); }
        public static bool4 all(bool4x4 m) { return new bool4(all(m.c0),all(m.c1),all(m.c2),all(m.c3)); }

        public static bool4 any(bool2x4 m) { return new bool4(any(m.c0),any(m.c1),any(m.c2),any(m.c3)); }
        public static bool4 any(bool3x4 m) { return new bool4(any(m.c0),any(m.c1),any(m.c2),any(m.c3)); }
        public static bool4 any(bool4x4 m) { return new bool4(any(m.c0),any(m.c1),any(m.c2),any(m.c3)); }

Sample use case

int[] vertexTriangles; // index buffer of mesh
var rightEdge = new int3(0,1,4); // index of vertex on the right of uv rectangle
var topEdge = new int3(1,3,4); // index of vertex on the top of uv rectangle
var rightTop = new int3x2(new int3(0,1,4),new int3(1,3,4));

foreach(int index in vertexTriangles)
{
    bool3x2 checkRightTop = index % 6 == rightTop;
    bool2 isRightTop = math.any(checkRightTop); // check that vertexIndex is which corner of UV space
    // isRightTop.x is left or right
    // isRightTop.y is bottom or top
    var v = math.select(rightTopValue,leftBottomValue,isRightTop); // select leftTop/rightTop/leftBottom/rightBottom
}
主要语言
C#
星标
1.4k
派生
159
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Unity-Technologies/Unity.Mathematics 的其他 Issue

查看 Unity-Technologies/Unity.Mathematics 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。