mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 14:03:55 +02:00
copy and paste working
This commit is contained in:
parent
0b7f4b21f4
commit
cf3ff53e2c
4 changed files with 30 additions and 20 deletions
|
@ -2397,7 +2397,7 @@ void Application::deleteVoxelUnderCursor() {
|
|||
|
||||
for (int i = 0; i < 5000; i++) {
|
||||
voxelInjector->addSample(10000 * sin((i * 2 * PIE) / (500 * sin((i + 1) / 500.0)))); //FM 3 resonant pulse
|
||||
// voxelInjector->addSample(20000 * sin((i) /((4 / _mouseVoxel.s) * sin((i)/(20 * _mouseVoxel.s / .001))))); //FM 2 comb filter
|
||||
//voxelInjector->addSample(20000 * sin((i) /((4 / _mouseVoxel.s) * sin((i)/(20 * _mouseVoxel.s / .001))))); //FM 2 comb filter
|
||||
}
|
||||
|
||||
AudioInjectionManager::threadInjector(voxelInjector);
|
||||
|
|
|
@ -170,22 +170,21 @@ OctalCodeComparison compareOctalCodes(unsigned char* codeA, unsigned char* codeB
|
|||
|
||||
|
||||
char getOctalCodeSectionValue(unsigned char* octalCode, int section) {
|
||||
int startAtByte = 1 + (3 * section / 8);
|
||||
char startIndexInByte = (3 * section) % 8;
|
||||
int startAtByte = 1 + (BITS_IN_OCTAL * section / BITS_IN_BYTE);
|
||||
char startIndexInByte = (BITS_IN_OCTAL * section) % BITS_IN_BYTE;
|
||||
unsigned char* startByte = octalCode + startAtByte;
|
||||
|
||||
return sectionValue(startByte, startIndexInByte);
|
||||
}
|
||||
|
||||
void setOctalCodeSectionValue(unsigned char* octalCode, int section, char sectionValue) {
|
||||
unsigned char* byteAt = octalCode + 1 + (3 * section / 8);
|
||||
char bitInByte = (3 * section) % 8;
|
||||
char shiftBy = 8 - bitInByte - 3;
|
||||
int byteForSection = (BITS_IN_OCTAL * section / BITS_IN_BYTE);
|
||||
unsigned char* byteAt = octalCode + 1 + byteForSection;
|
||||
char bitInByte = (BITS_IN_OCTAL * section) % BITS_IN_BYTE;
|
||||
char shiftBy = BITS_IN_BYTE - bitInByte - BITS_IN_OCTAL;
|
||||
const unsigned char UNSHIFTED_MASK = 0x07;
|
||||
unsigned char shiftedMask;
|
||||
unsigned char shiftedValue;
|
||||
|
||||
|
||||
if (shiftBy >=0) {
|
||||
shiftedMask = UNSHIFTED_MASK << shiftBy;
|
||||
shiftedValue = sectionValue << shiftBy;
|
||||
|
@ -193,15 +192,24 @@ void setOctalCodeSectionValue(unsigned char* octalCode, int section, char sectio
|
|||
shiftedMask = UNSHIFTED_MASK >> -shiftBy;
|
||||
shiftedValue = sectionValue >> -shiftBy;
|
||||
}
|
||||
|
||||
unsigned char oldValue = *byteAt & ~shiftedMask;
|
||||
unsigned char newValue = oldValue | shiftedValue;
|
||||
*byteAt = newValue;
|
||||
if (bitInByte >= 6) {
|
||||
shiftBy = bitInByte + 1;
|
||||
|
||||
// If the requested section is partially in the byte, then we
|
||||
// need to also set the portion of the section value in the next byte
|
||||
// there's only two cases where this happens, if the bit in byte is
|
||||
// 6, then it means that 1 extra bit lives in the next byte. If the
|
||||
// bit in this byte is 7 then 2 extra bits live in the next byte.
|
||||
const int FIRST_PARTIAL_BIT = 6;
|
||||
if (bitInByte >= FIRST_PARTIAL_BIT) {
|
||||
int bitsInFirstByte = BITS_IN_BYTE - bitInByte;
|
||||
int bitsInSecondByte = BITS_IN_OCTAL - bitsInFirstByte;
|
||||
shiftBy = BITS_IN_BYTE - bitsInSecondByte;
|
||||
|
||||
shiftedMask = UNSHIFTED_MASK << shiftBy;
|
||||
shiftedValue = sectionValue << shiftBy;
|
||||
|
||||
|
||||
oldValue = byteAt[1] & ~shiftedMask;
|
||||
newValue = oldValue | shiftedValue;
|
||||
byteAt[1] = newValue;
|
||||
|
@ -228,8 +236,7 @@ unsigned char* rebaseOctalCode(unsigned char* originalOctalCode, unsigned char*
|
|||
int oldCodeLength = numberOfThreeBitSectionsInCode(originalOctalCode);
|
||||
int newParentCodeLength = numberOfThreeBitSectionsInCode(newParentOctalCode);
|
||||
int newCodeLength = newParentCodeLength + oldCodeLength;
|
||||
const int COLOR_SPACE = 3;
|
||||
int bufferLength = newCodeLength + (includeColorSpace ? COLOR_SPACE : 0);
|
||||
int bufferLength = newCodeLength + (includeColorSpace ? SIZE_OF_COLOR_DATA : 0);
|
||||
unsigned char* newCode = new unsigned char[bufferLength];
|
||||
*newCode = newCodeLength; // set the length byte
|
||||
|
||||
|
|
|
@ -11,6 +11,14 @@
|
|||
|
||||
#include <string.h>
|
||||
|
||||
const int BITS_IN_BYTE = 8;
|
||||
const int BITS_IN_OCTAL = 3;
|
||||
const int NUMBER_OF_COLORS = 3; // RGB!
|
||||
const int SIZE_OF_COLOR_DATA = NUMBER_OF_COLORS * sizeof(unsigned char); // size in bytes
|
||||
const int RED_INDEX = 0;
|
||||
const int GREEN_INDEX = 1;
|
||||
const int BLUE_INDEX = 2;
|
||||
|
||||
void printOctalCode(unsigned char * octalCode);
|
||||
int bytesRequiredForCodeLength(unsigned char threeBitCodes);
|
||||
bool isDirectParentOfChild(unsigned char *parentOctalCode, unsigned char * childOctalCode);
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#define __hifi_VoxelConstants_h__
|
||||
|
||||
#include <limits.h>
|
||||
#include <OctalCode.h>
|
||||
|
||||
const int TREE_SCALE = 128;
|
||||
|
||||
|
@ -23,12 +24,6 @@ const int MAX_VOXELS_PER_SYSTEM = 200000;
|
|||
const int VERTICES_PER_VOXEL = 24;
|
||||
const int VERTEX_POINTS_PER_VOXEL = 3 * VERTICES_PER_VOXEL;
|
||||
const int INDICES_PER_VOXEL = 3 * 12;
|
||||
|
||||
const int NUMBER_OF_COLORS = 3; // RGB!
|
||||
const int SIZE_OF_COLOR_DATA = NUMBER_OF_COLORS * sizeof(unsigned char); // size in bytes
|
||||
const int RED_INDEX = 0;
|
||||
const int GREEN_INDEX = 1;
|
||||
const int BLUE_INDEX = 2;
|
||||
const int COLOR_VALUES_PER_VOXEL = NUMBER_OF_COLORS * VERTICES_PER_VOXEL;
|
||||
|
||||
typedef unsigned long int glBufferIndex;
|
||||
|
|
Loading…
Reference in a new issue