Merge pull request #2167 from birarda/null-checks

remove some unnecessary null pointer checks
This commit is contained in:
ZappoMan 2014-03-03 12:09:42 -08:00
commit e4065f0440
23 changed files with 49 additions and 49 deletions

View file

@ -36,7 +36,7 @@ AvatarMixer::AvatarMixer(const QByteArray& packet) :
} }
void attachAvatarDataToNode(Node* newNode) { void attachAvatarDataToNode(Node* newNode) {
if (newNode->getLinkedData() == NULL) { if (!newNode->getLinkedData()) {
newNode->setLinkedData(new AvatarMixerClientData()); newNode->setLinkedData(new AvatarMixerClientData());
} }
} }

View file

@ -26,7 +26,7 @@ SimpleMovingAverage OctreeServer::_averageTreeWaitTime(10000);
SimpleMovingAverage OctreeServer::_averageNodeWaitTime(10000); SimpleMovingAverage OctreeServer::_averageNodeWaitTime(10000);
void OctreeServer::attachQueryNodeToNode(Node* newNode) { void OctreeServer::attachQueryNodeToNode(Node* newNode) {
if (newNode->getLinkedData() == NULL) { if (!newNode->getLinkedData()) {
OctreeQueryNode* newQueryNodeData = _instance->createOctreeQueryNode(); OctreeQueryNode* newQueryNodeData = _instance->createOctreeQueryNode();
newQueryNodeData->resetOctreePacket(true); // don't bump sequence newQueryNodeData->resetOctreePacket(true); // don't bump sequence
newNode->setLinkedData(newQueryNodeData); newNode->setLinkedData(newQueryNodeData);
@ -716,7 +716,7 @@ void OctreeServer::run() {
strftime(localBuffer, MAX_TIME_LENGTH, "%m/%d/%Y %X", localtm); strftime(localBuffer, MAX_TIME_LENGTH, "%m/%d/%Y %X", localtm);
// Convert now to tm struct for UTC // Convert now to tm struct for UTC
tm* gmtm = gmtime(&_started); tm* gmtm = gmtime(&_started);
if (gmtm != NULL) { if (gmtm) {
strftime(utcBuffer, MAX_TIME_LENGTH, " [%m/%d/%Y %X UTC]", gmtm); strftime(utcBuffer, MAX_TIME_LENGTH, " [%m/%d/%Y %X UTC]", gmtm);
} }
qDebug() << "Now running... started at: " << localBuffer << utcBuffer; qDebug() << "Now running... started at: " << localBuffer << utcBuffer;

View file

@ -1146,7 +1146,7 @@ void Application::dropEvent(QDropEvent *event) {
} }
SnapshotMetaData* snapshotData = Snapshot::parseSnapshotData(snapshotPath); SnapshotMetaData* snapshotData = Snapshot::parseSnapshotData(snapshotPath);
if (snapshotData != NULL) { if (snapshotData) {
if (!snapshotData->getDomain().isEmpty()) { if (!snapshotData->getDomain().isEmpty()) {
Menu::getInstance()->goToDomain(snapshotData->getDomain()); Menu::getInstance()->goToDomain(snapshotData->getDomain());
} }
@ -1940,7 +1940,7 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node
foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) {
// only send to the NodeTypes that are serverType // only send to the NodeTypes that are serverType
if (node->getActiveSocket() != NULL && node->getType() == serverType) { if (node->getActiveSocket() && node->getType() == serverType) {
totalServers++; totalServers++;
// get the server bounds for this server // get the server bounds for this server
@ -2000,7 +2000,7 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node
foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { foreach (const SharedNodePointer& node, nodeList->getNodeHash()) {
// only send to the NodeTypes that are serverType // only send to the NodeTypes that are serverType
if (node->getActiveSocket() != NULL && node->getType() == serverType) { if (node->getActiveSocket() && node->getType() == serverType) {
// get the server bounds for this server // get the server bounds for this server

View file

@ -105,13 +105,13 @@ void GlowEffect::end() {
} }
static void maybeBind(QOpenGLFramebufferObject* fbo) { static void maybeBind(QOpenGLFramebufferObject* fbo) {
if (fbo != NULL) { if (fbo) {
fbo->bind(); fbo->bind();
} }
} }
static void maybeRelease(QOpenGLFramebufferObject* fbo) { static void maybeRelease(QOpenGLFramebufferObject* fbo) {
if (fbo != NULL) { if (fbo) {
fbo->release(); fbo->release();
} }
} }

View file

@ -996,18 +996,18 @@ void Model::renderMeshes(float alpha, bool translucent) {
Texture* diffuseMap = networkPart.diffuseTexture.data(); Texture* diffuseMap = networkPart.diffuseTexture.data();
if (mesh.isEye) { if (mesh.isEye) {
if (diffuseMap != NULL) { if (diffuseMap) {
diffuseMap = (_dilatedTextures[i][j] = diffuseMap = (_dilatedTextures[i][j] =
static_cast<DilatableNetworkTexture*>(diffuseMap)->getDilatedTexture(_pupilDilation)).data(); static_cast<DilatableNetworkTexture*>(diffuseMap)->getDilatedTexture(_pupilDilation)).data();
} }
} }
glBindTexture(GL_TEXTURE_2D, diffuseMap == NULL ? glBindTexture(GL_TEXTURE_2D, !diffuseMap ?
Application::getInstance()->getTextureCache()->getWhiteTextureID() : diffuseMap->getID()); Application::getInstance()->getTextureCache()->getWhiteTextureID() : diffuseMap->getID());
if (!mesh.tangents.isEmpty()) { if (!mesh.tangents.isEmpty()) {
glActiveTexture(GL_TEXTURE1); glActiveTexture(GL_TEXTURE1);
Texture* normalMap = networkPart.normalTexture.data(); Texture* normalMap = networkPart.normalTexture.data();
glBindTexture(GL_TEXTURE_2D, normalMap == NULL ? glBindTexture(GL_TEXTURE_2D, !normalMap ?
Application::getInstance()->getTextureCache()->getBlueTextureID() : normalMap->getID()); Application::getInstance()->getTextureCache()->getBlueTextureID() : normalMap->getID());
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
} }

View file

@ -40,14 +40,14 @@ TextureCache::~TextureCache() {
foreach (GLuint id, _fileTextureIDs) { foreach (GLuint id, _fileTextureIDs) {
glDeleteTextures(1, &id); glDeleteTextures(1, &id);
} }
if (_primaryFramebufferObject != NULL) { if (_primaryFramebufferObject) {
delete _primaryFramebufferObject; delete _primaryFramebufferObject;
glDeleteTextures(1, &_primaryDepthTextureID); glDeleteTextures(1, &_primaryDepthTextureID);
} }
if (_secondaryFramebufferObject != NULL) { if (_secondaryFramebufferObject) {
delete _secondaryFramebufferObject; delete _secondaryFramebufferObject;
} }
if (_tertiaryFramebufferObject != NULL) { if (_tertiaryFramebufferObject) {
delete _tertiaryFramebufferObject; delete _tertiaryFramebufferObject;
} }
} }
@ -138,7 +138,7 @@ QSharedPointer<NetworkTexture> TextureCache::getTexture(const QUrl& url, bool no
} }
QOpenGLFramebufferObject* TextureCache::getPrimaryFramebufferObject() { QOpenGLFramebufferObject* TextureCache::getPrimaryFramebufferObject() {
if (_primaryFramebufferObject == NULL) { if (!_primaryFramebufferObject) {
_primaryFramebufferObject = createFramebufferObject(); _primaryFramebufferObject = createFramebufferObject();
glGenTextures(1, &_primaryDepthTextureID); glGenTextures(1, &_primaryDepthTextureID);
@ -164,21 +164,21 @@ GLuint TextureCache::getPrimaryDepthTextureID() {
} }
QOpenGLFramebufferObject* TextureCache::getSecondaryFramebufferObject() { QOpenGLFramebufferObject* TextureCache::getSecondaryFramebufferObject() {
if (_secondaryFramebufferObject == NULL) { if (!_secondaryFramebufferObject) {
_secondaryFramebufferObject = createFramebufferObject(); _secondaryFramebufferObject = createFramebufferObject();
} }
return _secondaryFramebufferObject; return _secondaryFramebufferObject;
} }
QOpenGLFramebufferObject* TextureCache::getTertiaryFramebufferObject() { QOpenGLFramebufferObject* TextureCache::getTertiaryFramebufferObject() {
if (_tertiaryFramebufferObject == NULL) { if (!_tertiaryFramebufferObject) {
_tertiaryFramebufferObject = createFramebufferObject(); _tertiaryFramebufferObject = createFramebufferObject();
} }
return _tertiaryFramebufferObject; return _tertiaryFramebufferObject;
} }
QOpenGLFramebufferObject* TextureCache::getShadowFramebufferObject() { QOpenGLFramebufferObject* TextureCache::getShadowFramebufferObject() {
if (_shadowFramebufferObject == NULL) { if (!_shadowFramebufferObject) {
const int SHADOW_MAP_SIZE = 2048; const int SHADOW_MAP_SIZE = 2048;
_shadowFramebufferObject = new QOpenGLFramebufferObject(SHADOW_MAP_SIZE, SHADOW_MAP_SIZE, _shadowFramebufferObject = new QOpenGLFramebufferObject(SHADOW_MAP_SIZE, SHADOW_MAP_SIZE,
QOpenGLFramebufferObject::NoAttachment, GL_TEXTURE_2D, GL_RGB); QOpenGLFramebufferObject::NoAttachment, GL_TEXTURE_2D, GL_RGB);
@ -212,16 +212,16 @@ GLuint TextureCache::getShadowDepthTextureID() {
bool TextureCache::eventFilter(QObject* watched, QEvent* event) { bool TextureCache::eventFilter(QObject* watched, QEvent* event) {
if (event->type() == QEvent::Resize) { if (event->type() == QEvent::Resize) {
QSize size = static_cast<QResizeEvent*>(event)->size(); QSize size = static_cast<QResizeEvent*>(event)->size();
if (_primaryFramebufferObject != NULL && _primaryFramebufferObject->size() != size) { if (_primaryFramebufferObject && _primaryFramebufferObject->size() != size) {
delete _primaryFramebufferObject; delete _primaryFramebufferObject;
_primaryFramebufferObject = NULL; _primaryFramebufferObject = NULL;
glDeleteTextures(1, &_primaryDepthTextureID); glDeleteTextures(1, &_primaryDepthTextureID);
} }
if (_secondaryFramebufferObject != NULL && _secondaryFramebufferObject->size() != size) { if (_secondaryFramebufferObject && _secondaryFramebufferObject->size() != size) {
delete _secondaryFramebufferObject; delete _secondaryFramebufferObject;
_secondaryFramebufferObject = NULL; _secondaryFramebufferObject = NULL;
} }
if (_tertiaryFramebufferObject != NULL && _tertiaryFramebufferObject->size() != size) { if (_tertiaryFramebufferObject && _tertiaryFramebufferObject->size() != size) {
delete _tertiaryFramebufferObject; delete _tertiaryFramebufferObject;
_tertiaryFramebufferObject = NULL; _tertiaryFramebufferObject = NULL;
} }

View file

@ -51,7 +51,7 @@ void AudioInjector::injectAudio() {
packetStream << QUuid::createUuid(); packetStream << QUuid::createUuid();
// pack the flag for loopback // pack the flag for loopback
uchar loopbackFlag = (uchar) (_options.getLoopbackAudioInterface() == NULL); uchar loopbackFlag = (uchar) (!_options.getLoopbackAudioInterface());
packetStream << loopbackFlag; packetStream << loopbackFlag;
// pack the position for injected audio // pack the position for injected audio

View file

@ -69,7 +69,7 @@ int Bitstream::registerMetaObject(const char* className, const QMetaObject* meta
getMetaObjects().insert(className, metaObject); getMetaObjects().insert(className, metaObject);
// register it as a subclass of itself and all of its superclasses // register it as a subclass of itself and all of its superclasses
for (const QMetaObject* superClass = metaObject; superClass != NULL; superClass = superClass->superClass()) { for (const QMetaObject* superClass = metaObject; superClass; superClass = superClass->superClass()) {
getMetaObjectSubClasses().insert(superClass, metaObject); getMetaObjectSubClasses().insert(superClass, metaObject);
} }
return 0; return 0;

View file

@ -784,7 +784,7 @@ void ScriptedMetavoxelGuide::setURL(const ParameterizedURL& url) {
bool MetavoxelVisitation::allInputNodesLeaves() const { bool MetavoxelVisitation::allInputNodesLeaves() const {
foreach (MetavoxelNode* node, inputNodes) { foreach (MetavoxelNode* node, inputNodes) {
if (node != NULL && !node->isLeaf()) { if (node && !node->isLeaf()) {
return false; return false;
} }
} }
@ -792,7 +792,7 @@ bool MetavoxelVisitation::allInputNodesLeaves() const {
} }
AttributeValue MetavoxelVisitation::getInheritedOutputValue(int index) const { AttributeValue MetavoxelVisitation::getInheritedOutputValue(int index) const {
for (const MetavoxelVisitation* visitation = previous; visitation != NULL; visitation = visitation->previous) { for (const MetavoxelVisitation* visitation = previous; visitation; visitation = visitation->previous) {
MetavoxelNode* node = visitation->outputNodes.at(index); MetavoxelNode* node = visitation->outputNodes.at(index);
if (node) { if (node) {
return node->getAttributeValue(visitor.getOutputs().at(index)); return node->getAttributeValue(visitor.getOutputs().at(index));

View file

@ -62,7 +62,7 @@ DelegatingItemEditorFactory::DelegatingItemEditorFactory() :
QWidget* DelegatingItemEditorFactory::createEditor(int userType, QWidget* parent) const { QWidget* DelegatingItemEditorFactory::createEditor(int userType, QWidget* parent) const {
QWidget* editor = QItemEditorFactory::createEditor(userType, parent); QWidget* editor = QItemEditorFactory::createEditor(userType, parent);
return (editor == NULL) ? _parentFactory->createEditor(userType, parent) : editor; return (!editor) ? _parentFactory->createEditor(userType, parent) : editor;
} }
QByteArray DelegatingItemEditorFactory::valuePropertyName(int userType) const { QByteArray DelegatingItemEditorFactory::valuePropertyName(int userType) const {

View file

@ -163,7 +163,7 @@ void SharedObjectEditor::updateType() {
oldObject->disconnect(this); oldObject->disconnect(this);
} }
const QMetaObject* metaObject = _type->itemData(_type->currentIndex()).value<const QMetaObject*>(); const QMetaObject* metaObject = _type->itemData(_type->currentIndex()).value<const QMetaObject*>();
if (metaObject == NULL) { if (!metaObject) {
_object.reset(); _object.reset();
return; return;
} }

View file

@ -62,7 +62,7 @@ bool JurisdictionSender::process() {
_nodesRequestingJurisdictions.pop(); _nodesRequestingJurisdictions.pop();
SharedNodePointer node = NodeList::getInstance()->nodeWithUUID(nodeUUID); SharedNodePointer node = NodeList::getInstance()->nodeWithUUID(nodeUUID);
if (node && node->getActiveSocket() != NULL) { if (node && node->getActiveSocket()) {
_packetSender.queuePacketForSending(node, QByteArray(reinterpret_cast<char *>(bufferOut), sizeOut)); _packetSender.queuePacketForSending(node, QByteArray(reinterpret_cast<char *>(bufferOut), sizeOut));
nodeCount++; nodeCount++;
} }

View file

@ -150,7 +150,7 @@ void Octree::recurseNodeWithOperationDistanceSorted(OctreeElement* node, Recurse
OctreeElement* Octree::nodeForOctalCode(OctreeElement* ancestorNode, OctreeElement* Octree::nodeForOctalCode(OctreeElement* ancestorNode,
const unsigned char* needleCode, OctreeElement** parentOfFoundNode) const { const unsigned char* needleCode, OctreeElement** parentOfFoundNode) const {
// special case for NULL octcode // special case for NULL octcode
if (needleCode == NULL) { if (!needleCode) {
return _rootNode; return _rootNode;
} }
@ -499,7 +499,7 @@ void Octree::processRemoveOctreeElementsBitstream(const unsigned char* bitstream
// Note: this is an expensive call. Don't call it unless you really need to reaverage the entire tree (from startNode) // Note: this is an expensive call. Don't call it unless you really need to reaverage the entire tree (from startNode)
void Octree::reaverageOctreeElements(OctreeElement* startNode) { void Octree::reaverageOctreeElements(OctreeElement* startNode) {
if (startNode == NULL) { if (!startNode) {
startNode = getRoot(); startNode = getRoot();
} }
// if our tree is a reaveraging tree, then we do this, otherwise we don't do anything // if our tree is a reaveraging tree, then we do this, otherwise we don't do anything

View file

@ -177,7 +177,7 @@ void OctreeEditPacketSender::queuePacketToNodes(unsigned char* buffer, ssize_t l
foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) {
// only send to the NodeTypes that are getMyNodeType() // only send to the NodeTypes that are getMyNodeType()
if (node->getActiveSocket() != NULL && node->getType() == getMyNodeType()) { if (node->getActiveSocket() && node->getType() == getMyNodeType()) {
QUuid nodeUUID = node->getUUID(); QUuid nodeUUID = node->getUUID();
bool isMyJurisdiction = true; bool isMyJurisdiction = true;
// we need to get the jurisdiction for this // we need to get the jurisdiction for this
@ -226,7 +226,7 @@ void OctreeEditPacketSender::queueOctreeEditMessage(PacketType type, unsigned ch
foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) {
// only send to the NodeTypes that are getMyNodeType() // only send to the NodeTypes that are getMyNodeType()
if (node->getActiveSocket() != NULL && node->getType() == getMyNodeType()) { if (node->getActiveSocket() && node->getType() == getMyNodeType()) {
QUuid nodeUUID = node->getUUID(); QUuid nodeUUID = node->getUUID();
bool isMyJurisdiction = true; bool isMyJurisdiction = true;

View file

@ -739,7 +739,7 @@ void OctreeElement::setChildAtIndex(int childIndex, OctreeElement* child) {
_externalChildrenMemoryUsage += NUMBER_OF_CHILDREN * sizeof(OctreeElement*); _externalChildrenMemoryUsage += NUMBER_OF_CHILDREN * sizeof(OctreeElement*);
} else if (previousChildCount == 2 && newChildCount == 1) { } else if (previousChildCount == 2 && newChildCount == 1) {
assert(child == NULL); // we are removing a child, so this must be true! assert(child); // we are removing a child, so this must be true!
OctreeElement* previousFirstChild = _children.external[firstIndex]; OctreeElement* previousFirstChild = _children.external[firstIndex];
OctreeElement* previousSecondChild = _children.external[secondIndex]; OctreeElement* previousSecondChild = _children.external[secondIndex];
delete[] _children.external; delete[] _children.external;

View file

@ -75,7 +75,7 @@ void OctreeHeadlessViewer::queryOctree() {
foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) {
// only send to the NodeTypes that are serverType // only send to the NodeTypes that are serverType
if (node->getActiveSocket() != NULL && node->getType() == serverType) { if (node->getActiveSocket() && node->getType() == serverType) {
totalServers++; totalServers++;
// get the server bounds for this server // get the server bounds for this server
@ -135,7 +135,7 @@ void OctreeHeadlessViewer::queryOctree() {
foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { foreach (const SharedNodePointer& node, nodeList->getNodeHash()) {
// only send to the NodeTypes that are serverType // only send to the NodeTypes that are serverType
if (node->getActiveSocket() != NULL && node->getType() == serverType) { if (node->getActiveSocket() && node->getType() == serverType) {
// get the server bounds for this server // get the server bounds for this server

View file

@ -23,7 +23,7 @@ public:
jsonCallbackReceiver(NULL), jsonCallbackMethod(), jsonCallbackReceiver(NULL), jsonCallbackMethod(),
errorCallbackReceiver(NULL), errorCallbackMethod() {}; errorCallbackReceiver(NULL), errorCallbackMethod() {};
bool isEmpty() const { return jsonCallbackReceiver == NULL && errorCallbackReceiver == NULL; } bool isEmpty() const { return !jsonCallbackReceiver && !errorCallbackReceiver; }
QObject* jsonCallbackReceiver; QObject* jsonCallbackReceiver;
QString jsonCallbackMethod; QString jsonCallbackMethod;

View file

@ -98,7 +98,7 @@ void Node::activatePublicSocket() {
} }
void Node::recordBytesReceived(int bytesReceived) { void Node::recordBytesReceived(int bytesReceived) {
if (_bytesReceivedMovingAverage == NULL) { if (!_bytesReceivedMovingAverage) {
_bytesReceivedMovingAverage = new SimpleMovingAverage(100); _bytesReceivedMovingAverage = new SimpleMovingAverage(100);
} }

View file

@ -810,7 +810,7 @@ void NodeList::activateSocketFromNodeCommunication(const QByteArray& packet, con
SharedNodePointer NodeList::soloNodeOfType(char nodeType) { SharedNodePointer NodeList::soloNodeOfType(char nodeType) {
if (memchr(SOLO_NODE_TYPES, nodeType, sizeof(SOLO_NODE_TYPES)) != NULL) { if (memchr(SOLO_NODE_TYPES, nodeType, sizeof(SOLO_NODE_TYPES))) {
foreach (const SharedNodePointer& node, getNodeHash()) { foreach (const SharedNodePointer& node, getNodeHash()) {
if (node->getType() == nodeType) { if (node->getType() == nodeType) {
return node; return node;

View file

@ -73,7 +73,7 @@ unsigned char* childOctalCode(const unsigned char* parentOctalCode, char childNu
// find the length (in number of three bit code sequences) // find the length (in number of three bit code sequences)
// in the parent // in the parent
int parentCodeSections = parentOctalCode != NULL int parentCodeSections = parentOctalCode
? numberOfThreeBitSectionsInCode(parentOctalCode) ? numberOfThreeBitSectionsInCode(parentOctalCode)
: 0; : 0;
@ -87,7 +87,7 @@ unsigned char* childOctalCode(const unsigned char* parentOctalCode, char childNu
unsigned char* newCode = new unsigned char[childCodeBytes]; unsigned char* newCode = new unsigned char[childCodeBytes];
// copy the parent code to the child // copy the parent code to the child
if (parentOctalCode != NULL) { if (parentOctalCode) {
memcpy(newCode, parentOctalCode, parentCodeBytes); memcpy(newCode, parentOctalCode, parentCodeBytes);
} }

View file

@ -98,7 +98,7 @@ VoxelSystem* VoxelTreeElement::getVoxelSystem() const {
} }
void VoxelTreeElement::setVoxelSystem(VoxelSystem* voxelSystem) { void VoxelTreeElement::setVoxelSystem(VoxelSystem* voxelSystem) {
if (voxelSystem == NULL) { if (!voxelSystem) {
_voxelSystemIndex = INDEX_FOR_NULL; _voxelSystemIndex = INDEX_FOR_NULL;
} else { } else {
uint8_t index; uint8_t index;

View file

@ -72,7 +72,7 @@ void SvoViewer::InitializePointRenderSystem()
PointRenderAssembleData args; PointRenderAssembleData args;
args.buffer = _pointVertices = new glm::vec3[_nodeCount]; args.buffer = _pointVertices = new glm::vec3[_nodeCount];
args.colorBuffer = _pointColors = new unsigned char[_nodeCount*3]; args.colorBuffer = _pointColors = new unsigned char[_nodeCount*3];
assert(args.buffer != NULL); assert(args.buffer);
args.count = 0; args.count = 0;
_systemTree.recurseTreeWithOperation(&PointRenderAssemblePerVoxel, &args); _systemTree.recurseTreeWithOperation(&PointRenderAssemblePerVoxel, &args);
@ -297,7 +297,7 @@ void SvoViewer::InitializeVoxelRenderSystem()
VoxelRenderAssembleData args; VoxelRenderAssembleData args;
args.buffer = _readVerticesArray; args.buffer = _readVerticesArray;
args.colorBuffer = _readColorsArray; args.colorBuffer = _readColorsArray;
assert(args.buffer != NULL && args.colorBuffer != NULL); assert(args.buffer && args.colorBuffer);
args.leafCount = 0; args.leafCount = 0;
args.lastBufferSegmentStart = 0; args.lastBufferSegmentStart = 0;
args.idxIds = _vboIndicesIds; args.idxIds = _vboIndicesIds;
@ -622,12 +622,12 @@ void SvoViewer::InitializeVoxelOptRenderSystem()
for (int i = 0; i < NUMBER_OF_CHILDREN; i++) for (int i = 0; i < NUMBER_OF_CHILDREN; i++)
{ {
OctreeElement* childNode1stOrder = node0fromRoot->getChildAtIndex(i); OctreeElement* childNode1stOrder = node0fromRoot->getChildAtIndex(i);
if (childNode1stOrder == NULL) continue; if (!childNode1stOrder) continue;
// Grab 2nd order nodes for better separation. At some point, this would need to be done intelligently. // Grab 2nd order nodes for better separation. At some point, this would need to be done intelligently.
for (int j = 0; j < NUMBER_OF_CHILDREN; j++) for (int j = 0; j < NUMBER_OF_CHILDREN; j++)
{ {
OctreeElement* childNode2ndOrder = childNode1stOrder->getChildAtIndex(j); OctreeElement* childNode2ndOrder = childNode1stOrder->getChildAtIndex(j);
if (childNode2ndOrder == NULL) continue; if (!childNode2ndOrder) continue;
//int num2ndOrderChildren = childNode2ndOrder->getChildCount(); //int num2ndOrderChildren = childNode2ndOrder->getChildCount();
// Figure out how populated this child is. // Figure out how populated this child is.

View file

@ -194,12 +194,12 @@ void SvoViewer::InitializeVoxelOpt2RenderSystem()
for (int i = 0; i < NUMBER_OF_CHILDREN; i++) for (int i = 0; i < NUMBER_OF_CHILDREN; i++)
{ {
OctreeElement* childNode1stOrder = node0fromRoot->getChildAtIndex(i); OctreeElement* childNode1stOrder = node0fromRoot->getChildAtIndex(i);
if (childNode1stOrder == NULL) continue; if (!childNode1stOrder) continue;
// Grab 2nd order nodes for better separation. At some point, this would need to be done intelligently. // Grab 2nd order nodes for better separation. At some point, this would need to be done intelligently.
for (int j = 0; j < NUMBER_OF_CHILDREN; j++) for (int j = 0; j < NUMBER_OF_CHILDREN; j++)
{ {
OctreeElement* childNode2ndOrder = childNode1stOrder->getChildAtIndex(j); OctreeElement* childNode2ndOrder = childNode1stOrder->getChildAtIndex(j);
if (childNode2ndOrder == NULL) continue; if (!childNode2ndOrder) continue;
//int num2ndOrderChildren = childNode2ndOrder->getChildCount(); //int num2ndOrderChildren = childNode2ndOrder->getChildCount();
// Figure out how populated this child is. // Figure out how populated this child is.
@ -240,7 +240,7 @@ void SvoViewer::InitializeVoxelOpt2RenderSystem()
for (int k = 0; k < NUM_CUBE_FACES; k++) for (int k = 0; k < NUM_CUBE_FACES; k++)
{ {
_segmentIdxBuffers[i].idxBuff[k] = new GLuint[2 * 3 * _numChildNodeLeaves[i]]; _segmentIdxBuffers[i].idxBuff[k] = new GLuint[2 * 3 * _numChildNodeLeaves[i]];
assert(_segmentIdxBuffers[i].idxBuff[k] != NULL); assert(_segmentIdxBuffers[i].idxBuff[k]);
} }
VoxelOpt2RenderAssembleData args; VoxelOpt2RenderAssembleData args;
@ -267,7 +267,7 @@ void SvoViewer::InitializeVoxelOpt2RenderSystem()
delete [] _readVertexStructs; delete [] _readVertexStructs;
//delete [] _readIndicesArray; //delete [] _readIndicesArray;
delete [] faceCenters; delete [] faceCenters;
for (int k = 0; k < NUM_CUBE_FACES; k++) if (_segmentIdxBuffers[i].idxBuff[k] != NULL) delete [] _segmentIdxBuffers[i].idxBuff[k]; for (int k = 0; k < NUM_CUBE_FACES; k++) if (_segmentIdxBuffers[i].idxBuff[k]) delete [] _segmentIdxBuffers[i].idxBuff[k];
} }
_voxelOptRenderInitialized = true; _voxelOptRenderInitialized = true;