-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstarInstanceTable.cpp
More file actions
33 lines (28 loc) · 992 Bytes
/
starInstanceTable.cpp
File metadata and controls
33 lines (28 loc) · 992 Bytes
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
#include "starInstanceTable.h"
#include <QFile>
StarInstanceTable::StarInstanceTable() {
this->data_manager = DataManager::getInstance();
m_dirty = true;
}
QByteArray StarInstanceTable::getInstanceBuffer(int *instanceCount) {
if (m_dirty) {
for (int i = 0; i < data_manager->m_stars.length(); i++) {
dVector3D pos = data_manager->m_star_positions[i];
float scale = data_manager->m_stars[i].scale;
auto entry = calculateTableEntry(
{(float)pos.x, (float)pos.y, (float)pos.z},
{1, 1, 1},
{1, 1, 1},
QColor(255, 255, 255),
{(float)pos.x, (float)pos.y, (float)pos.z, scale}
);
m_instanceData.append((char*)&entry, sizeof(entry));
}
m_instanceCount = data_manager->m_stars.length();
m_dirty = false;
}
if (instanceCount) {
*instanceCount = m_instanceCount;
}
return m_instanceData;
}