mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 07:53:10 +02:00
get client working in refactored mode
This commit is contained in:
parent
4e18eaa6c5
commit
188d52c06e
6 changed files with 47 additions and 38 deletions
|
@ -128,8 +128,6 @@ void VoxelSystem::elementDeleted(OctreeElement* element) {
|
|||
|
||||
void VoxelSystem::setDisableFastVoxelPipeline(bool disableFastVoxelPipeline) {
|
||||
_useFastVoxelPipeline = !disableFastVoxelPipeline;
|
||||
printf("setDisableFastVoxelPipeline() disableFastVoxelPipeline=%s _useFastVoxelPipeline=%s\n",
|
||||
debug::valueOf(disableFastVoxelPipeline), debug::valueOf(_useFastVoxelPipeline));
|
||||
setupNewVoxelsForDrawing();
|
||||
}
|
||||
|
||||
|
@ -565,7 +563,6 @@ bool VoxelSystem::readFromSchematicFile(const char* filename) {
|
|||
}
|
||||
|
||||
int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) {
|
||||
|
||||
unsigned char command = *sourceBuffer;
|
||||
int numBytesPacketHeader = numBytesForPacketHeader(sourceBuffer);
|
||||
switch(command) {
|
||||
|
@ -645,6 +642,8 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) {
|
|||
}
|
||||
|
||||
void VoxelSystem::setupNewVoxelsForDrawing() {
|
||||
|
||||
|
||||
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
|
||||
"setupNewVoxelsForDrawing()");
|
||||
|
||||
|
@ -709,7 +708,6 @@ void VoxelSystem::setupNewVoxelsForDrawing() {
|
|||
}
|
||||
|
||||
void VoxelSystem::setupNewVoxelsForDrawingSingleNode(bool allowBailEarly) {
|
||||
|
||||
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
|
||||
"setupNewVoxelsForDrawingSingleNode() xxxxx");
|
||||
|
||||
|
@ -849,7 +847,6 @@ void VoxelSystem::cleanupRemovedVoxels() {
|
|||
|
||||
void VoxelSystem::copyWrittenDataToReadArraysFullVBOs() {
|
||||
copyWrittenDataSegmentToReadArrays(0, _voxelsInWriteArrays - 1);
|
||||
|
||||
_voxelsInReadArrays = _voxelsInWriteArrays;
|
||||
|
||||
// clear our dirty flags
|
||||
|
@ -1945,7 +1942,6 @@ void VoxelSystem::hideOutOfView(bool forceFullFrustum) {
|
|||
}
|
||||
|
||||
if (!forceFullFrustum && _culledOnce && args.lastViewFrustum.isVerySimilar(args.thisViewFrustum)) {
|
||||
//printf("view frustum hasn't changed BAIL!!!\n");
|
||||
_inhideOutOfView = false;
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -214,13 +214,9 @@ int Octree::readNodeData(OctreeElement* destinationNode, const unsigned char* no
|
|||
bytesRead += childNodeAt->readElementDataFromBuffer(nodeData + bytesRead, bytesLeftToRead, args);
|
||||
childNodeAt->setSourceUUID(args.sourceUUID);
|
||||
|
||||
// if we had a local version of the node already, it's possible that we have it in the VBO but
|
||||
// if we had a local version of the node already, it's possible that we have it already but
|
||||
// with the same color data, so this won't count as a change. To address this we check the following
|
||||
|
||||
// XXXBHG - Do something here...
|
||||
if (!childNodeAt->isDirty()
|
||||
/**&& !childNodeAt->isKnownBufferIndex() && childNodeAt->getShouldRender() **/
|
||||
) {
|
||||
if (!childNodeAt->isDirty() && childNodeAt->getShouldRender() && !childNodeAt->isRendered()) {
|
||||
childNodeAt->setDirtyBit(); // force dirty!
|
||||
}
|
||||
|
||||
|
@ -447,7 +443,6 @@ void Octree::deleteOctalCodeFromTreeRecursion(OctreeElement* node, void* extraDa
|
|||
}
|
||||
|
||||
void Octree::eraseAllOctreeElements() {
|
||||
// XXXBHG Hack attack - is there a better way to erase the voxel tree?
|
||||
delete _rootNode; // this will recurse and delete all children
|
||||
_rootNode = createNewElement();
|
||||
_isDirty = true;
|
||||
|
@ -560,9 +555,7 @@ bool findRayIntersectionOp(OctreeElement* node, void* extraData) {
|
|||
return true; // recurse on children
|
||||
}
|
||||
distance *= TREE_SCALE;
|
||||
// XXXBHG - we used to test node->isColored(), but that no longer exists in the octree
|
||||
// instead I switched this to isLeaf() which seems more correct.
|
||||
if (node->isLeaf() && (!args->found || distance < args->distance)) {
|
||||
if (node->hasContent() && (!args->found || distance < args->distance)) {
|
||||
args->node = node;
|
||||
args->distance = distance;
|
||||
args->face = face;
|
||||
|
@ -597,8 +590,7 @@ bool findSpherePenetrationOp(OctreeElement* node, void* extraData) {
|
|||
if (!node->isLeaf()) {
|
||||
return true; // recurse on children
|
||||
}
|
||||
// XXXBHG - used to be isColored()
|
||||
if (node->isLeaf()) {
|
||||
if (node->hasContent()) {
|
||||
glm::vec3 nodePenetration;
|
||||
if (box.findSpherePenetration(args->center, args->radius, nodePenetration)) {
|
||||
args->penetration = addPenetrations(args->penetration, nodePenetration * (float)TREE_SCALE);
|
||||
|
@ -635,8 +627,7 @@ bool findCapsulePenetrationOp(OctreeElement* node, void* extraData) {
|
|||
if (!node->isLeaf()) {
|
||||
return true; // recurse on children
|
||||
}
|
||||
// XXXBHG - used to be isColored(), may be an issue.
|
||||
if (node->isLeaf()) {
|
||||
if (node->hasContent()) {
|
||||
glm::vec3 nodePenetration;
|
||||
if (box.findCapsulePenetration(args->start, args->end, args->radius, nodePenetration)) {
|
||||
args->penetration = addPenetrations(args->penetration, nodePenetration * (float)TREE_SCALE);
|
||||
|
@ -1403,6 +1394,12 @@ void Octree::copySubTreeIntoNewTree(OctreeElement* startNode, Octree* destinatio
|
|||
}
|
||||
|
||||
// XXXBHG - what is this trying to do?
|
||||
// This code appears to be trying to set the color of the destination root
|
||||
// of a copy operation. But that shouldn't be necessary. I think this code might
|
||||
// have been a hack that Mark added when he was trying to solve the copy of a single
|
||||
// voxel bug. But this won't solve that problem, and doesn't appear to be needed for
|
||||
// a normal copy operation. I'm leaving this in for a little bit until we see if anything
|
||||
// about copy/paste is broken.
|
||||
//
|
||||
//OctreeElement* destinationStartNode;
|
||||
//if (rebaseToRoot) {
|
||||
|
|
|
@ -28,17 +28,18 @@ uint64_t OctreeElement::_externalChildrenMemoryUsage = 0;
|
|||
uint64_t OctreeElement::_voxelNodeCount = 0;
|
||||
uint64_t OctreeElement::_voxelNodeLeafCount = 0;
|
||||
|
||||
OctreeElement::OctreeElement(unsigned char * octalCode) {
|
||||
OctreeElement::OctreeElement() {
|
||||
}
|
||||
|
||||
void OctreeElement::init(unsigned char * octalCode) {
|
||||
if (!octalCode) {
|
||||
octalCode = new unsigned char[1];
|
||||
*octalCode = 0;
|
||||
}
|
||||
init(octalCode);
|
||||
_voxelNodeCount++;
|
||||
_voxelNodeLeafCount++; // all nodes start as leaf nodes
|
||||
}
|
||||
|
||||
void OctreeElement::init(unsigned char * octalCode) {
|
||||
|
||||
int octalCodeLength = bytesRequiredForCodeLength(numberOfThreeBitSectionsInCode(octalCode));
|
||||
if (octalCodeLength > sizeof(_octalCode)) {
|
||||
_octalCode.pointer = octalCode;
|
||||
|
@ -82,15 +83,10 @@ void OctreeElement::init(unsigned char * octalCode) {
|
|||
_sourceUUIDKey = 0;
|
||||
calculateAABox();
|
||||
markWithChangedTime();
|
||||
|
||||
_voxelMemoryUsage += sizeof(OctreeElement);
|
||||
}
|
||||
|
||||
OctreeElement::~OctreeElement() {
|
||||
notifyDeleteHooks();
|
||||
|
||||
_voxelMemoryUsage -= sizeof(OctreeElement);
|
||||
|
||||
_voxelNodeCount--;
|
||||
if (isLeaf()) {
|
||||
_voxelNodeLeafCount--;
|
||||
|
|
|
@ -45,11 +45,12 @@ class OctreeElement {
|
|||
|
||||
protected:
|
||||
// can only be constructed by derived implementation
|
||||
OctreeElement(unsigned char * octalCode = NULL);
|
||||
OctreeElement();
|
||||
|
||||
virtual OctreeElement* createNewElement(unsigned char * octalCode = NULL) const = 0;
|
||||
|
||||
public:
|
||||
virtual void init(unsigned char * octalCode); /// Your subclass must call init on construction.
|
||||
virtual ~OctreeElement();
|
||||
|
||||
const unsigned char* getOctalCode() const { return (_octcodePointer) ? _octalCode.pointer : &_octalCode.buffer[0]; }
|
||||
|
@ -103,6 +104,10 @@ public:
|
|||
void setShouldRender(bool shouldRender);
|
||||
bool getShouldRender() const { return _shouldRender; }
|
||||
|
||||
/// we assume that if you should be rendered, then your subclass is rendering, but this allows subclasses to
|
||||
/// implement alternate rendering strategies
|
||||
virtual bool isRendered() const { return getShouldRender(); }
|
||||
|
||||
void setSourceUUID(const QUuid& sourceID);
|
||||
QUuid getSourceUUID() const;
|
||||
uint16_t getSourceUUIDKey() const { return _sourceUUIDKey; }
|
||||
|
@ -162,7 +167,6 @@ protected:
|
|||
void checkStoreFourChildren(OctreeElement* childOne, OctreeElement* childTwo, OctreeElement* childThree, OctreeElement* childFour);
|
||||
#endif
|
||||
void calculateAABox();
|
||||
void init(unsigned char * octalCode);
|
||||
void notifyDeleteHooks();
|
||||
void notifyUpdateHooks();
|
||||
|
||||
|
|
|
@ -14,20 +14,33 @@
|
|||
#include "VoxelTreeElement.h"
|
||||
#include "VoxelTree.h"
|
||||
|
||||
VoxelTreeElement::VoxelTreeElement(unsigned char* octalCode) : OctreeElement(octalCode) {
|
||||
// probably need to do all the color init here....
|
||||
init();
|
||||
VoxelTreeElement::VoxelTreeElement(unsigned char* octalCode) : OctreeElement() {
|
||||
init(octalCode);
|
||||
};
|
||||
|
||||
OctreeElement* VoxelTreeElement::createNewElement(unsigned char* octalCode) const {
|
||||
return new VoxelTreeElement(octalCode);
|
||||
VoxelTreeElement::~VoxelTreeElement() {
|
||||
_voxelMemoryUsage -= sizeof(VoxelTreeElement);
|
||||
}
|
||||
|
||||
void VoxelTreeElement::init() {
|
||||
// This will be called primarily on addChildAt(), which means we're adding a child of our
|
||||
// own type to our own tree. This means we should initialize that child with any tree and type
|
||||
// specific settings that our children must have. One example is out VoxelSystem, which
|
||||
// we know must match ours.
|
||||
OctreeElement* VoxelTreeElement::createNewElement(unsigned char* octalCode) const {
|
||||
VoxelTreeElement* newChild = new VoxelTreeElement(octalCode);
|
||||
newChild->setVoxelSystem(getVoxelSystem()); // our child is always part of our voxel system NULL ok
|
||||
return newChild;
|
||||
}
|
||||
|
||||
void VoxelTreeElement::init(unsigned char* octalCode) {
|
||||
setVoxelSystem(NULL);
|
||||
setBufferIndex(GLBUFFER_INDEX_UNKNOWN);
|
||||
_falseColored = false; // assume true color
|
||||
_currentColor[0] = _currentColor[1] = _currentColor[2] = _currentColor[3] = 0;
|
||||
_trueColor[0] = _trueColor[1] = _trueColor[2] = _trueColor[3] = 0;
|
||||
_density = 0.0f;
|
||||
OctreeElement::init(octalCode);
|
||||
_voxelMemoryUsage += sizeof(VoxelTreeElement);
|
||||
}
|
||||
|
||||
bool VoxelTreeElement::requiresSplit() const {
|
||||
|
|
|
@ -34,7 +34,8 @@ class VoxelTreeElement : public OctreeElement {
|
|||
virtual OctreeElement* createNewElement(unsigned char* octalCode = NULL) const;
|
||||
|
||||
public:
|
||||
void init();
|
||||
virtual ~VoxelTreeElement();
|
||||
virtual void init(unsigned char * octalCode);
|
||||
|
||||
virtual bool hasContent() const { return isColored(); }
|
||||
virtual void splitChildren();
|
||||
|
@ -51,6 +52,8 @@ public:
|
|||
VoxelSystem* getVoxelSystem() const;
|
||||
void setVoxelSystem(VoxelSystem* voxelSystem);
|
||||
|
||||
virtual bool isRendered() const { return isKnownBufferIndex(); }
|
||||
|
||||
bool isColored() const { return _trueColor[3] == 1; }
|
||||
|
||||
void setFalseColor(colorPart red, colorPart green, colorPart blue);
|
||||
|
|
Loading…
Reference in a new issue