Operand ambiguity occurs when referencing built-in Vector types via arithmetic and comparison operators
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 42/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
調査の方向性
まず、VectorX と floatX の型定義、および既存の変換と演算子の実装を見つけます。Input.mousePosition と float3 の例を再現し、関連する算術式と比較式が曖昧さなく解決され、意図した Unity.Mathematics の結果型を生成することを確認します。
索引モデルが issue の本文から書いたものです。
説明
Given the following code snip:
static float3 lastMouseSpinViewPos;
var delta = Input.mousePosition - lastMouseSpinViewPos;
The following compiler error occurs:
Operator '-' is ambiguous on operands of type 'Vector3' and 'float3'
The reason is that the compiler doesn't know if it should implicitly convert the first operand to float3, or implicitly convert the second operand to Vector3.
Expected Behavior
My expectation is that Unity.Mathematics types should assume priority in this case: the first operand is converted to float3 and the result type is a float3. I'm not sure if there's a valid case for expecting behavior favoring Vector3, and if there were, it could be achieved by using explicit (Vector3) cast or type definition. Seeking a legacy Vector3 result is an edge case and is well-suited to be delegated to an explicit cast condition.
Cause of Problem
Input.mousePositionis a unity built-in property or field, so its type isVector3- There are no explicit arithmetic operator implementations for
VectorXtypes andfloatXtypes.
Proposed solution
For the sake of streamlining interoperability with Unity built-in class Vector types, I think it makes sense to provide explicit implementations of arithmetic and comparison operators, like so:
public static float3 operator +(Vector3 l, float3 r) { return (float3)l + r; }
public static float3 operator -(Vector3 l, float3 r) { return (float3)l - r; }
public static float3 operator +(float3 l, Vector3 r) { return l + (float3)r; }
public static float3 operator -(float3 l, Vector3 r) { return l - (float3)r; }
Workaround
Add explicit typecast in all situations, like so:
static float3 lastMouseSpinViewPos;
var delta = (float3)Input.mousePosition - lastMouseSpinViewPos;
- 主要言語
- C#
- スター
- 1.4k
- フォーク
- 159
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Unity-Technologies/Unity.Mathematics のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 55/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
Unity-Technologies/Unity.Mathematics#245 · コメント 3 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 42/100
Unity-Technologies/Unity.Mathematics#243 · リアクション 6 件 ·
Unity-Technologies/Unity.Mathematics の issue をすべて見る
似ている issue
-
area:jobads-cv BE mvp P2
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
klasolsson81/jobbliggaren#2099 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
Esri/calcite-dotnet-toolkit#30 · リアクション 1 件 ·
-
kind:docs simplification size:S status:todo
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
elsa-workflows/elsa-foundation#2604 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
ProwlEngine/Prowl#413 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
VideoViewer: rotated (portrait phone) videos shown sideways when system decimal separator is a commaオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100