Example #1
0
void OctreeQueryNode::resetOctreePacket() {
    // if shutting down, return immediately
    if (_isShuttingDown) {
        return;
    }

    // Whenever we call this, we will keep a copy of the last packet, so we can determine if the last packet has
    // changed since we last reset it. Since we know that no two packets can ever be identical without being the same
    // scene information, (e.g. the root node packet of a static scene), we can use this as a strategy for reducing
    // packet send rate.
    _lastOctreePacketLength = getPacketLength();
    memcpy(_lastOctreePacket, _octreePacket, _lastOctreePacketLength);

    // If we're moving, and the client asked for low res, then we force monochrome, otherwise, use
    // the clients requested color state.
    _currentPacketIsColor = getWantColor();
    _currentPacketIsCompressed = getWantCompression();
    OCTREE_PACKET_FLAGS flags = 0;
    if (_currentPacketIsColor) {
        setAtBit(flags,PACKET_IS_COLOR_BIT);
    }
    if (_currentPacketIsCompressed) {
        setAtBit(flags,PACKET_IS_COMPRESSED_BIT);
    }

    _octreePacketAvailableBytes = MAX_PACKET_SIZE;
    int numBytesPacketHeader = populatePacketHeader(reinterpret_cast<char*>(_octreePacket), _myPacketType);
    _octreePacketAt = _octreePacket + numBytesPacketHeader;
    _octreePacketAvailableBytes -= numBytesPacketHeader;

    // pack in flags
    OCTREE_PACKET_FLAGS* flagsAt = (OCTREE_PACKET_FLAGS*)_octreePacketAt;
    *flagsAt = flags;
    _octreePacketAt += sizeof(OCTREE_PACKET_FLAGS);
    _octreePacketAvailableBytes -= sizeof(OCTREE_PACKET_FLAGS);
    
    // pack in sequence number
    OCTREE_PACKET_SEQUENCE* sequenceAt = (OCTREE_PACKET_SEQUENCE*)_octreePacketAt;
    *sequenceAt = _sequenceNumber;
    _octreePacketAt += sizeof(OCTREE_PACKET_SEQUENCE);
    _octreePacketAvailableBytes -= sizeof(OCTREE_PACKET_SEQUENCE);

    // pack in timestamp
    OCTREE_PACKET_SENT_TIME now = usecTimestampNow();
    OCTREE_PACKET_SENT_TIME* timeAt = (OCTREE_PACKET_SENT_TIME*)_octreePacketAt;
    *timeAt = now;
    _octreePacketAt += sizeof(OCTREE_PACKET_SENT_TIME);
    _octreePacketAvailableBytes -= sizeof(OCTREE_PACKET_SENT_TIME);

    _octreePacketWaiting = false;
}
Example #2
0
void VoxelNodeData::resetVoxelPacket() {
    // If we're moving, and the client asked for low res, then we force monochrome, otherwise, use 
    // the clients requested color state.    
    _currentPacketIsColor = (LOW_RES_MONO && getWantLowResMoving() && _viewFrustumChanging) ? false : getWantColor();
    PACKET_TYPE voxelPacketType = _currentPacketIsColor ? PACKET_TYPE_VOXEL_DATA : PACKET_TYPE_VOXEL_DATA_MONOCHROME;
    int numBytesPacketHeader = populateTypeAndVersion(_voxelPacket, voxelPacketType);
    _voxelPacketAt = _voxelPacket + numBytesPacketHeader;
    _voxelPacketAvailableBytes = MAX_VOXEL_PACKET_SIZE - numBytesPacketHeader;
    _voxelPacketWaiting = false;
}
Example #3
0
void VoxelNodeData::resetVoxelPacket() {
    // Whenever we call this, we will keep a copy of the last packet, so we can determine if the last packet has
    // changed since we last reset it. Since we know that no two packets can ever be identical without being the same
    // scene information, (e.g. the root node packet of a static scene), we can use this as a strategy for reducing
    // packet send rate.
    _lastVoxelPacketLength = getPacketLength();
    memcpy(_lastVoxelPacket, _voxelPacket, _lastVoxelPacketLength);

    // If we're moving, and the client asked for low res, then we force monochrome, otherwise, use 
    // the clients requested color state.    
    _currentPacketIsColor = (LOW_RES_MONO && getWantLowResMoving() && _viewFrustumChanging) ? false : getWantColor();
    PACKET_TYPE voxelPacketType = _currentPacketIsColor ? PACKET_TYPE_VOXEL_DATA : PACKET_TYPE_VOXEL_DATA_MONOCHROME;
    int numBytesPacketHeader = populateTypeAndVersion(_voxelPacket, voxelPacketType);
    _voxelPacketAt = _voxelPacket + numBytesPacketHeader;
    _voxelPacketAvailableBytes = MAX_VOXEL_PACKET_SIZE - numBytesPacketHeader;
    _voxelPacketWaiting = false;
}