Merge branch 'master' into GLTF2_invalid_buffer_fix
commit
d966f3394b
|
@ -508,18 +508,23 @@ inline size_t Buffer::AppendData(uint8_t *data, size_t length) {
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Buffer::Grow(size_t amount) {
|
inline void Buffer::Grow(size_t amount) {
|
||||||
if (amount <= 0) return;
|
if (amount <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Capacity is big enough
|
||||||
if (capacity >= byteLength + amount) {
|
if (capacity >= byteLength + amount) {
|
||||||
byteLength += amount;
|
byteLength += amount;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shift operation is standard way to divide integer by 2, it doesn't cast it to float back and forth, also works for odd numbers,
|
// Just allocate data which we need
|
||||||
// originally it would look like: static_cast<size_t>(capacity * 1.5f)
|
capacity = byteLength + amount;
|
||||||
capacity = std::max(capacity + (capacity >> 1), byteLength + amount);
|
|
||||||
|
|
||||||
uint8_t *b = new uint8_t[capacity];
|
uint8_t *b = new uint8_t[capacity];
|
||||||
if (mData) memcpy(b, mData.get(), byteLength);
|
if (nullptr != mData) {
|
||||||
|
memcpy(b, mData.get(), byteLength);
|
||||||
|
}
|
||||||
mData.reset(b, std::default_delete<uint8_t[]>());
|
mData.reset(b, std::default_delete<uint8_t[]>());
|
||||||
byteLength += amount;
|
byteLength += amount;
|
||||||
}
|
}
|
||||||
|
|
|
@ -245,7 +245,7 @@ void do_motion (void)
|
||||||
static int frames = 0;
|
static int frames = 0;
|
||||||
|
|
||||||
int time = glutGet(GLUT_ELAPSED_TIME);
|
int time = glutGet(GLUT_ELAPSED_TIME);
|
||||||
angle += (time-prev_time)*0.01;
|
angle += (time-prev_time)*0.01f;
|
||||||
prev_time = time;
|
prev_time = time;
|
||||||
|
|
||||||
frames += 1;
|
frames += 1;
|
||||||
|
|
Loading…
Reference in New Issue