-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPoxel.h
More file actions
48 lines (38 loc) · 1.06 KB
/
Copy pathPoxel.h
File metadata and controls
48 lines (38 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#pragma once
#include "Const.h"
#include "Color.h"
#include <amp.h>
using namespace Concurrency;
class Poxel
{
public:
Color color;
bool enabled = false;
Poxel() restrict(amp, cpu) {}
Poxel(Color color) {
this->color = color;
enabled = true;
}
void setDefault() {
color = Color(UINT_MAX, UINT_MAX, UINT_MAX);
enabled = false;
}
bool CheckAndSet(array_view<Poxel, 2> poxel, unsigned int y, unsigned int x) restrict(amp,cpu) {
if (!poxel[y][x].enabled) {
Poxel* p = &poxel[y][x];
p->enabled = true;
p->color = color;
enabled = false;
return true;
}
return false;
}
void doStep(array_view<Poxel, 2> poxel, array_view<Color, 3> rgbView, index<2> idx, bool bufferSwitch) restrict(amp, cpu) {
rgbView[bufferSwitch][idx] = poxel[idx].color;
if (idx[0] > 0) { //Prevent falling out of scene
if (CheckAndSet(poxel, idx[0] - 1, idx[1])) {}
else if (!(idx[1] == 0 && hardSides) && CheckAndSet(poxel, idx[0] - 1, idx[1] - 1)) {}
else if (!(idx[1] == px - 1 && hardSides) && CheckAndSet(poxel, idx[0] - 1, idx[1] + 1)) {}
}
}
};