我的struct
文件中有metal
:
struct Vects
{
float3 position[100];
};
将用于保存缓冲区数据:
kernel void compute(texture2d<float, access::write> output [[texture(0)]],
constant float &time [[buffer(0)]],
constant mouseInput &mouse [[buffer(1)]],
constant Vects &vects [[buffer(2)]],//<--- Vects
uint2 gid [[thread_position_in_grid]]) {
...
sceneSDF(origin, vects);
...
}
其中
float sceneSDF(float3 cotu,Vects vects) {
float a;
for(int i = 1; i < 3 ; i++){
float3 u = vects[i-1].position;//<-- error!
float3 v = vects[i].position;//<-- error!
a = min(fSphere(cotu + u,0.7),fSphere(cotu + v,0.7));
}
return a;
}
我在float3 u
和float3 v
类型&#39; Vects&#39;不提供下标运算符
我该如何解决这个问题?
答案 0 :(得分:1)
我认为你的点符号和数组下标的命令在你的情况下混淆了。这些行:
float3 u = vects[i-1].position;
float3 v = vects[i].position;
应该是:
float3 u = vects.position[i-1];
float3 v = vects.position[i];
答案 1 :(得分:0)
你需要这样写:
private System.Timers.Timer timer;
public void CountDown()
{
timer = new System.Timers.Timer();
timer.Interval = 5000;
timer.Elapsed += OnTimedEvent;
if (TimerRunning == true)
{
timer.Enabled = true;
}
else
{
timer.Enabled = false;
TimerRunning = false;
}
}
public void OnTimedEvent(object sender, System.Timers.ElapsedEventArgs e)
{
// Check if really timer is okay to launch
if (CountDownRunning == true)
{
TimerRunning = true;
}
else
{
TimerRunning = false;
timer.Elapsed -= OnTimedEvent;
}
}
因为vects不是数组,所以你不能那样使用它。你的类型是v,float3,它与vects.position [i]
相同