ParameterContainerのパラメータでVector2Int実装の要望

This is a forum for requesting Arbor developers.
The items required for the request are as follows.
  • What are you trying to do with Arbor?
  • Specifically, where are you inconvenient and in trouble?
  • What should I do to improve?
Attention point:
  • We can not answer requests that do not know the detailed situation.
  • We can not answer your request for specific problems in the specification of your project.
  • We can not answer your request on Unity's specification issues.
  • We do not guarantee the implementation of your request.

ここは、Arbor開発者への要望を行うためのフォーラムです。
要望に必要な項目は以下の通りです。
  • Arborを使って何をしようとしているか。
  • 具体的にどこが不便で困っているか。
  • 改善するにはどうすればよいか。
注意点:
  • 詳しい状況がわからない要望については答えられません。
  • ユーザー様のプロジェクトの仕様上の固有の問題に対する要望については答えられません。
  • Unityの仕様上の問題に対する要望には答えられません。
  • 要望の実装を必ずお約束するものではございません。

Forum rules
The items required for the request are as follows.
  • What are you trying to do with Arbor?
  • Specifically, where are you inconvenient and in trouble?
  • What should I do to improve?
Attention point:
  • We can not answer requests that do not know the detailed situation.
  • We can not answer your request for specific problems in the specification of your project.
  • We can not answer your request on Unity's specification issues.
  • We do not guarantee the implementation of your request.

要望に必要な項目は以下の通りです。
  • Arborを使って何をしようとしているか。
  • 具体的にどこが不便で困っているか。
  • 改善するにはどうすればよいか。
注意点:
  • 詳しい状況がわからない要望については答えられません。
  • ユーザー様のプロジェクトの仕様上の固有の問題に対する要望については答えられません。
  • Unityの仕様上の問題に対する要望には答えられません。
  • 要望の実装を必ずお約束するものではございません。
ooee

ParameterContainerのパラメータでVector2Int実装の要望

Post by ooee »

いつもお世話になっています。

ParameterContainerのパラメータでVector2Intを使用したいのですが実装されていないので、
Variable型を継承したVector2IntVariableクラスを定義して使っています。

使用する分の動作としてはこれで問題ないのですが、FlexibleField<Vector2Int>から値を取得したり、
AnyParameterReferenceで値を設定するときに、恐らくstructとobject型とのキャストが入るためGC Allocが毎回発生するのが気になっています。

もし可能でしたらVector2Intのパラメータを実装していただけると助かります。
非常に細かい点でお手数をおかけしますが、ご検討のほどよろしくお願いいたします。
User avatar
caitsithware
管理人
Posts: 493
Joined: 2015/08/17 12:41

Re: ParameterContainerのパラメータでVector2Int実装の要望

Post by caitsithware »

ご要望ありがとうございます。

ParameterContainerにVector2Int追加ですね。
Vector3IntやRectIntも含め、追加する方向で検討いたします。

structからobjectへのボックス化によるGC Allocにつきましては、
現在、FlexibleField<T>に構造体を指定してパラメータ値を取得するとVariableに限らずボックス化がされる仕様となっておりますので、その点はご了承ください。
(FlexibleVector3などもFlexibleField<Vector3>を継承していますので、パラメータで実装されているかに関わらずボックス化が発生します)
今後の課題として、極力ボックス化を回避できないかもあわせて検討していきたいと思います。

現状での回避策としましては、Parameterを経由してVariableBaseを取得して直接中身を取り出すことでボックス化を回避できるかと思います。

Code: Select all

// フィールド宣言部
[SlotType(typeof(Vector2Int))]
public AnyParameterReference vector2IntParameter;

// Get/Setしたい箇所
var parameter = vector2IntParameter.parameter;
if (parameter == null || parameter.type != Parameter.Type.Variable) return;

var variable = parameter.variableBase as Vector2IntVariable;
if (variable == null) return;
var value = variable.value;
value.x += 10;
variable.value = value;
多少手間になってしまいますが、対応までの間このように対処していただくようお願いいたします。

【ボックス化に関する補足】
データフローやInvokeMethod/GetValue、List関連のスクリプトなどでもobject型を介すためボックス化が発生します。
この辺りは汎用的な組みやすさを取るかパフォーマンスを取るかのトレードオフになっておりますので、
パフォーマンスを重視しボックス化も極力回避したい場合は、なるべく自作スクリプトを作成しメンバーに直接アクセスするようお願いいたします。
ooee

Re: ParameterContainerのパラメータでVector2Int実装の要望

Post by ooee »

ご返事ありがとうございます。

>(FlexibleVector3などもFlexibleField<Vector3>を継承していますので、パラメータで実装されているかに関わらずボックス化が発生します)
FlexibleVector3がGC Allocが発生しないPrimitive型と同等の実装をしていると勝手に勘違いしていました、申し訳ございません。
教えていただいた回避策で試してみたいと思います。
補足情報もありがとうございます。
Post Reply