mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 16:18:05 +02:00
get virtual entities constructing from buffers
This commit is contained in:
parent
0c7afc39ca
commit
6b62c6b976
4 changed files with 52 additions and 58 deletions
|
@ -455,48 +455,6 @@ void EntityTreeElement::updateEntityItemID(const EntityItemID& creatorTokenEntit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
void EntityTreeElement::updateEntityItemID(FindAndUpdateEntityItemIDArgs* args) {
|
|
||||||
bool wantDebug = false;
|
|
||||||
uint16_t numberOfEntities = _entityItems->size();
|
|
||||||
for (uint16_t i = 0; i < numberOfEntities; i++) {
|
|
||||||
EntityItem* thisEntity = (*_entityItems)[i];
|
|
||||||
|
|
||||||
if (!args->creatorTokenFound) {
|
|
||||||
// first, we're looking for matching creatorTokenIDs, if we find that, then we fix it to know the actual ID
|
|
||||||
if (thisEntity->getCreatorTokenID() == args->creatorTokenID) {
|
|
||||||
if (wantDebug) {
|
|
||||||
qDebug() << "EntityTreeElement::updateEntityItemID()... found the entity... updating it's ID... "
|
|
||||||
<< "creatorTokenID=" << args->creatorTokenID
|
|
||||||
<< "entityID=" << args->entityID;
|
|
||||||
}
|
|
||||||
|
|
||||||
thisEntity->setID(args->entityID);
|
|
||||||
args->creatorTokenFound = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// if we're in an isViewing tree, we also need to look for an kill any viewed entities
|
|
||||||
if (!args->viewedEntityFound && args->isViewing) {
|
|
||||||
if (thisEntity->getCreatorTokenID() == UNKNOWN_ENTITY_TOKEN && thisEntity->getID() == args->entityID) {
|
|
||||||
|
|
||||||
if (wantDebug) {
|
|
||||||
qDebug() << "EntityTreeElement::updateEntityItemID()... VIEWED entity FOUND??? "
|
|
||||||
<< "args->creatorTokenID=" << args->creatorTokenID
|
|
||||||
<< "thisEntity->getCreatorTokenID()=" << thisEntity->getCreatorTokenID()
|
|
||||||
<< "args->entityID=" << args->entityID;
|
|
||||||
}
|
|
||||||
|
|
||||||
_entityItems->removeAt(i); // remove the entity at this index
|
|
||||||
numberOfEntities--; // this means we have 1 fewer entity in this list
|
|
||||||
i--; // and we actually want to back up i as well.
|
|
||||||
args->viewedEntityFound = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
const EntityItem* EntityTreeElement::getClosestEntity(glm::vec3 position) const {
|
const EntityItem* EntityTreeElement::getClosestEntity(glm::vec3 position) const {
|
||||||
const EntityItem* closestEntity = NULL;
|
const EntityItem* closestEntity = NULL;
|
||||||
float closestEntityDistance = FLT_MAX;
|
float closestEntityDistance = FLT_MAX;
|
||||||
|
@ -666,7 +624,7 @@ int EntityTreeElement::readElementDataFromBuffer(const unsigned char* data, int
|
||||||
_myTree->rememberDirtyCube(existingEntityCube);
|
_myTree->rememberDirtyCube(existingEntityCube);
|
||||||
bytesForThisEntity = entityItem->readEntityDataFromBuffer(dataAt, bytesLeftToRead, args);
|
bytesForThisEntity = entityItem->readEntityDataFromBuffer(dataAt, bytesLeftToRead, args);
|
||||||
} else {
|
} else {
|
||||||
entityItem = EntityTypes::constructEntityItem(dataAt, bytesLeftToRead);
|
entityItem = EntityTypes::constructEntityItem(dataAt, bytesLeftToRead, args);
|
||||||
|
|
||||||
if (entityItem) {
|
if (entityItem) {
|
||||||
bytesForThisEntity = entityItem->readEntityDataFromBuffer(dataAt, bytesLeftToRead, args);
|
bytesForThisEntity = entityItem->readEntityDataFromBuffer(dataAt, bytesLeftToRead, args);
|
||||||
|
|
|
@ -35,16 +35,6 @@ public:
|
||||||
int _movingItems;
|
int _movingItems;
|
||||||
};
|
};
|
||||||
|
|
||||||
class FindAndUpdateEntityItemIDArgs {
|
|
||||||
public:
|
|
||||||
uint32_t entityID;
|
|
||||||
uint32_t creatorTokenID;
|
|
||||||
bool creatorTokenFound;
|
|
||||||
bool viewedEntityFound;
|
|
||||||
bool isViewing;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class EntityTreeElementExtraEncodeData {
|
class EntityTreeElementExtraEncodeData {
|
||||||
public:
|
public:
|
||||||
QMap<EntityItemID, EntityPropertyFlags> includedItems;
|
QMap<EntityItemID, EntityPropertyFlags> includedItems;
|
||||||
|
@ -125,7 +115,6 @@ public:
|
||||||
void addEntityItem(EntityItem* entity);
|
void addEntityItem(EntityItem* entity);
|
||||||
|
|
||||||
|
|
||||||
//void updateEntityItemID(FindAndUpdateEntityItemIDArgs* args);
|
|
||||||
void updateEntityItemID(const EntityItemID& creatorTokenEntityID, const EntityItemID& knownIDEntityID);
|
void updateEntityItemID(const EntityItemID& creatorTokenEntityID, const EntityItemID& knownIDEntityID);
|
||||||
|
|
||||||
const EntityItem* getClosestEntity(glm::vec3 position) const;
|
const EntityItem* getClosestEntity(glm::vec3 position) const;
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
|
|
||||||
#include <ByteCountCoding.h>
|
#include <ByteCountCoding.h>
|
||||||
|
#include <Octree.h>
|
||||||
|
|
||||||
#include "EntityItem.h"
|
#include "EntityItem.h"
|
||||||
#include "EntityItemProperties.h"
|
#include "EntityItemProperties.h"
|
||||||
|
@ -75,9 +76,55 @@ EntityItem* EntityTypes::constructEntityItem(EntityType_t entityType, const Enti
|
||||||
return newEntityItem;
|
return newEntityItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityItem* EntityTypes::constructEntityItem(const unsigned char* data, int bytesToRead) {
|
EntityItem* EntityTypes::constructEntityItem(const unsigned char* data, int bytesToRead,
|
||||||
|
ReadBitstreamToTreeParams& args) {
|
||||||
|
|
||||||
qDebug() << "EntityTypes::constructEntityItem(const unsigned char* data, int bytesToRead).... CALLED BUT NOT IMPLEMENTED!!!";
|
//qDebug() << "EntityTypes::constructEntityItem(const unsigned char* data, int bytesToRead).... CALLED BUT NOT IMPLEMENTED!!!";
|
||||||
|
|
||||||
|
if (args.bitstreamVersion < VERSION_ENTITIES_SUPPORT_SPLIT_MTU) {
|
||||||
|
qDebug() << "EntityTypes::constructEntityItem(const unsigned char* data, int bytesToRead).... OLD BITSTREAM!!!";
|
||||||
|
|
||||||
|
EntityItemID tempEntityID;
|
||||||
|
EntityItemProperties tempProperties;
|
||||||
|
return new ModelEntityItem(tempEntityID, tempProperties);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Header bytes
|
||||||
|
// object ID [16 bytes]
|
||||||
|
// ByteCountCoded(type code) [~1 byte]
|
||||||
|
// last edited [8 bytes]
|
||||||
|
// ByteCountCoded(last_edited to last_updated delta) [~1-8 bytes]
|
||||||
|
// PropertyFlags<>( everything ) [1-2 bytes]
|
||||||
|
// ~27-35 bytes...
|
||||||
|
const int MINIMUM_HEADER_BYTES = 27; // TODO: this is not correct, we don't yet have 16 byte IDs
|
||||||
|
|
||||||
|
int bytesRead = 0;
|
||||||
|
if (bytesToRead >= MINIMUM_HEADER_BYTES) {
|
||||||
|
int originalLength = bytesToRead;
|
||||||
|
QByteArray originalDataBuffer((const char*)data, originalLength);
|
||||||
|
|
||||||
|
// id
|
||||||
|
QByteArray encodedID = originalDataBuffer.mid(bytesRead); // maximum possible size
|
||||||
|
ByteCountCoded<quint32> idCoder = encodedID;
|
||||||
|
encodedID = idCoder; // determine true length
|
||||||
|
bytesRead += encodedID.size();
|
||||||
|
|
||||||
|
// type
|
||||||
|
QByteArray encodedType = originalDataBuffer.mid(bytesRead); // maximum possible size
|
||||||
|
ByteCountCoded<quint32> typeCoder = encodedType;
|
||||||
|
encodedType = typeCoder; // determine true length
|
||||||
|
bytesRead += encodedType.size();
|
||||||
|
quint32 type = typeCoder;
|
||||||
|
EntityTypes::EntityType_t entityType = (EntityTypes::EntityType_t)type;
|
||||||
|
|
||||||
|
EntityItemID tempEntityID;
|
||||||
|
EntityItemProperties tempProperties;
|
||||||
|
|
||||||
|
qDebug() << "EntityTypes::constructEntityItem(data, bytesToRead).... NEW BITSTREAM!!! entityType=" << entityType;
|
||||||
|
|
||||||
|
return constructEntityItem(entityType, tempEntityID, tempProperties);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return NULL; // TODO Implement this for real!
|
return NULL; // TODO Implement this for real!
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
class EntityItem;
|
class EntityItem;
|
||||||
class EntityItemID;
|
class EntityItemID;
|
||||||
class EntityItemProperties;
|
class EntityItemProperties;
|
||||||
|
class ReadBitstreamToTreeParams;
|
||||||
|
|
||||||
class EntityTypes {
|
class EntityTypes {
|
||||||
public:
|
public:
|
||||||
|
@ -40,7 +40,7 @@ public:
|
||||||
static EntityTypes::EntityType_t getEntityTypeFromName(const QString& name);
|
static EntityTypes::EntityType_t getEntityTypeFromName(const QString& name);
|
||||||
|
|
||||||
static EntityItem* constructEntityItem(EntityType_t entityType, const EntityItemID& entityID, const EntityItemProperties& properties);
|
static EntityItem* constructEntityItem(EntityType_t entityType, const EntityItemID& entityID, const EntityItemProperties& properties);
|
||||||
static EntityItem* constructEntityItem(const unsigned char* data, int bytesToRead);
|
static EntityItem* constructEntityItem(const unsigned char* data, int bytesToRead, ReadBitstreamToTreeParams& args);
|
||||||
static bool decodeEntityEditPacket(const unsigned char* data, int bytesToRead, int& processedBytes,
|
static bool decodeEntityEditPacket(const unsigned char* data, int bytesToRead, int& processedBytes,
|
||||||
EntityItemID& entityID, EntityItemProperties& properties);
|
EntityItemID& entityID, EntityItemProperties& properties);
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in a new issue