3
0
Fork 0
mirror of https://github.com/lubosz/overte.git synced 2025-04-26 07:15:37 +02:00

working on lines

This commit is contained in:
SamGondelman 2018-12-12 09:39:01 -08:00
parent 250baa9c72
commit b261665072
10 changed files with 61 additions and 65 deletions

View file

@ -17,38 +17,67 @@
using namespace render;
using namespace render::entities;
void LineEntityRenderer::onRemoveFromSceneTyped(const TypedEntityPointer& entity) {
if (_lineVerticesID != GeometryCache::UNKNOWN_ID) {
auto geometryCache = DependencyManager::get<GeometryCache>();
if (geometryCache) {
geometryCache->releaseID(_lineVerticesID);
LineEntityRenderer::LineEntityRenderer(const EntityItemPointer& entity) :
Parent(entity) {
_lineVerticesID = DependencyManager::get<GeometryCache>()->allocateID();
}
LineEntityRenderer::~LineEntityRenderer() {
auto geometryCache = DependencyManager::get<GeometryCache>();
if (geometryCache) {
geometryCache->releaseID(_lineVerticesID);
for (auto id : _glowGeometryIDs) {
geometryCache->releaseID(id);
}
}
}
bool LineEntityRenderer::isTransparent() const {
return Parent::isTransparent() || _glow > 0.0f || _alpha < 1.0f;
}
bool LineEntityRenderer::needsRenderUpdateFromTypedEntity(const TypedEntityPointer& entity) const {
return entity->pointsChanged();
if (entity->pointsChanged()) {
return true;
}
if (_color != entity->getColor()) {
return true;
}
if (_alpha != entity->getAlpha()) {
return true;
}
if (_lineWidth != entity->getLineWidth()) {
return true;
}
if (_glow != entity->getGlow()) {
return true;
}
return false;
}
void LineEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) {
entity->resetPointsChanged();
_linePoints = entity->getLinePoints();
auto geometryCache = DependencyManager::get<GeometryCache>();
if (_lineVerticesID == GeometryCache::UNKNOWN_ID) {
_lineVerticesID = geometryCache->allocateID();
}
glm::vec4 lineColor(toGlm(entity->getColor()), entity->getLocalRenderAlpha());
_color = entity->getColor();
_alpha = entity->getAlpha();
_lineWidth = entity->getLineWidth();
_glow = entity->getGlow();
// TODO: take into account _lineWidth
geometryCache->updateVertices(_lineVerticesID, _linePoints, lineColor);
}
void LineEntityRenderer::doRender(RenderArgs* args) {
if (_lineVerticesID == GeometryCache::UNKNOWN_ID) {
return;
}
PerformanceTimer perfTimer("RenderableLineEntityItem::render");
Q_ASSERT(args->_batch);
gpu::Batch& batch = *args->_batch;
const auto& modelTransform = getModelTransform();
Transform transform = Transform();
transform.setTranslation(modelTransform.getTranslation());

View file

@ -24,17 +24,25 @@ class LineEntityRenderer : public TypedEntityRenderer<LineEntityItem> {
friend class EntityRenderer;
public:
LineEntityRenderer(const EntityItemPointer& entity) : Parent(entity) { }
LineEntityRenderer(const EntityItemPointer& entity);
~LineEntityRenderer();
bool isTransparent() const override;
protected:
virtual void onRemoveFromSceneTyped(const TypedEntityPointer& entity) override;
virtual bool needsRenderUpdateFromTypedEntity(const TypedEntityPointer& entity) const override;
virtual void doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) override;
virtual void doRender(RenderArgs* args) override;
private:
int _lineVerticesID { GeometryCache::UNKNOWN_ID };
std::vector<int> _glowGeometryIDs;
QVector<glm::vec3> _linePoints;
glm::u8vec3 _color;
float _alpha;
float _lineWidth;
float _glow;
};
} } // namespace

View file

@ -1302,7 +1302,6 @@ EntityItemProperties EntityItem::getProperties(const EntityPropertyFlags& desire
COPY_ENTITY_PROPERTY_TO_PROPERTIES(registrationPoint, getRegistrationPoint);
COPY_ENTITY_PROPERTY_TO_PROPERTIES(angularVelocity, getLocalAngularVelocity);
COPY_ENTITY_PROPERTY_TO_PROPERTIES(angularDamping, getAngularDamping);
COPY_ENTITY_PROPERTY_TO_PROPERTIES(localRenderAlpha, getLocalRenderAlpha);
COPY_ENTITY_PROPERTY_TO_PROPERTIES(visible, getVisible);
COPY_ENTITY_PROPERTY_TO_PROPERTIES(canCastShadow, getCanCastShadow);
COPY_ENTITY_PROPERTY_TO_PROPERTIES(collisionless, getCollisionless);
@ -1449,7 +1448,6 @@ bool EntityItem::setProperties(const EntityItemProperties& properties) {
SET_ENTITY_PROPERTY_FROM_PROPERTIES(scriptTimestamp, setScriptTimestamp);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(serverScripts, setServerScripts);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(collisionSoundURL, setCollisionSoundURL);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(localRenderAlpha, setLocalRenderAlpha);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(visible, setVisible);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(canCastShadow, setCanCastShadow);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(userData, setUserData);
@ -2652,20 +2650,6 @@ void EntityItem::setDescription(const QString& value) {
});
}
float EntityItem::getLocalRenderAlpha() const {
float result;
withReadLock([&] {
result = _localRenderAlpha;
});
return result;
}
void EntityItem::setLocalRenderAlpha(float localRenderAlpha) {
withWriteLock([&] {
_localRenderAlpha = localRenderAlpha;
});
}
glm::vec3 EntityItem::getGravity() const {
glm::vec3 result;
withReadLock([&] {

View file

@ -207,9 +207,6 @@ public:
glm::vec3 getUnscaledDimensions() const;
virtual void setUnscaledDimensions(const glm::vec3& value);
float getLocalRenderAlpha() const;
void setLocalRenderAlpha(float localRenderAlpha);
void setDensity(float density);
float computeMass() const;
void setMass(float mass);
@ -592,7 +589,6 @@ protected:
mutable bool _recalcMinAACube { true };
mutable bool _recalcMaxAACube { true };
float _localRenderAlpha { ENTITY_ITEM_DEFAULT_LOCAL_RENDER_ALPHA };
float _density { ENTITY_ITEM_DEFAULT_DENSITY }; // kg/m^3
// NOTE: _volumeMultiplier is used to allow some mass properties code exist in the EntityItem base class
// rather than in all of the derived classes. If we ever collapse these classes to one we could do it a

View file

@ -50,10 +50,6 @@ EntityItemProperties::EntityItemProperties(EntityPropertyFlags desiredProperties
_lastEdited(0),
_type(EntityTypes::Unknown),
_localRenderAlpha(1.0f),
_localRenderAlphaChanged(false),
_defaultSettings(true),
_naturalDimensions(1.0f, 1.0f, 1.0f),
_naturalPosition(0.0f, 0.0f, 0.0f),
@ -1732,9 +1728,6 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool
properties.setProperty("isFacingAvatar", convertScriptValue(engine, getBillboardMode() == BillboardMode::FULL));
}
// FIXME - I don't think these properties are supported any more
//COPY_PROPERTY_TO_QSCRIPTVALUE(localRenderAlpha);
return properties;
}
@ -1775,7 +1768,6 @@ void EntityItemProperties::copyFromScriptValue(const QScriptValue& object, bool
COPY_PROPERTY_FROM_QSCRIPTVALUE(emitterShouldTrail, bool, setEmitterShouldTrail);
COPY_PROPERTY_FROM_QSCRIPTVALUE(modelURL, QString, setModelURL);
COPY_PROPERTY_FROM_QSCRIPTVALUE(compoundShapeURL, QString, setCompoundShapeURL);
COPY_PROPERTY_FROM_QSCRIPTVALUE(localRenderAlpha, float, setLocalRenderAlpha);
COPY_PROPERTY_FROM_QSCRIPTVALUE(collisionless, bool, setCollisionless);
COPY_PROPERTY_FROM_QSCRIPTVALUE_GETTER(ignoreForCollisions, bool, setCollisionless, getCollisionless); // legacy support
COPY_PROPERTY_FROM_QSCRIPTVALUE(collisionMask, uint16_t, setCollisionMask);
@ -2021,7 +2013,6 @@ void EntityItemProperties::merge(const EntityItemProperties& other) {
COPY_PROPERTY_IF_CHANGED(emitterShouldTrail);
COPY_PROPERTY_IF_CHANGED(modelURL);
COPY_PROPERTY_IF_CHANGED(compoundShapeURL);
COPY_PROPERTY_IF_CHANGED(localRenderAlpha);
COPY_PROPERTY_IF_CHANGED(collisionless);
COPY_PROPERTY_IF_CHANGED(collisionMask);
COPY_PROPERTY_IF_CHANGED(dynamic);
@ -3401,7 +3392,6 @@ void EntityItemProperties::markAllChanged() {
_alphaChanged = true;
_modelURLChanged = true;
_compoundShapeURLChanged = true;
_localRenderAlphaChanged = true;
_isSpotlightChanged = true;
_collisionlessChanged = true;
_collisionMaskChanged = true;

View file

@ -350,9 +350,6 @@ public:
bool containsPositionChange() const { return _positionChanged; }
bool containsDimensionsChange() const { return _dimensionsChanged; }
float getLocalRenderAlpha() const { return _localRenderAlpha; }
void setLocalRenderAlpha(float value) { _localRenderAlpha = value; _localRenderAlphaChanged = true; }
static OctreeElement::AppendState encodeEntityEditPacket(PacketType command, EntityItemID id, const EntityItemProperties& properties,
QByteArray& buffer, EntityPropertyFlags requestedProperties, EntityPropertyFlags& didntFitProperties);
@ -363,8 +360,6 @@ public:
static bool decodeEntityEditPacket(const unsigned char* data, int bytesToRead, int& processedBytes,
EntityItemID& entityID, EntityItemProperties& properties);
bool localRenderAlphaChanged() const { return _localRenderAlphaChanged; }
void clearID() { _id = UNKNOWN_ENTITY_ID; _idSet = false; }
void markAllChanged();
@ -452,8 +447,6 @@ private:
EntityTypes::EntityType _type;
void setType(const QString& typeName) { _type = EntityTypes::getEntityTypeFromName(typeName); }
float _localRenderAlpha;
bool _localRenderAlphaChanged;
bool _defaultSettings;
bool _dimensionsInitialized = true; // Only false if creating an entity locally with no dimensions properties

View file

@ -44,7 +44,6 @@ const QString ENTITY_ITEM_DEFAULT_CERTIFICATE_ID = QString("");
const quint32 ENTITY_ITEM_DEFAULT_STATIC_CERTIFICATE_VERSION = 0;
const float ENTITY_ITEM_DEFAULT_ALPHA = 1.0f;
const float ENTITY_ITEM_DEFAULT_LOCAL_RENDER_ALPHA = 1.0f;
const bool ENTITY_ITEM_DEFAULT_VISIBLE = true;
const bool ENTITY_ITEM_DEFAULT_VISIBLE_IN_SECONDARY_CAMERA = true;
const bool ENTITY_ITEM_DEFAULT_CAN_CAST_SHADOW { true };

View file

@ -173,19 +173,15 @@ void LineEntityItem::setLineWidth(float lineWidth) {
}
float LineEntityItem::getLineWidth() const {
float result;
withReadLock([&] {
result = _lineWidth;
return resultWithReadLock<bool>([&] {
return _lineWidth;
});
return result;
}
QVector<glm::vec3> LineEntityItem::getLinePoints() const {
QVector<glm::vec3> result;
withReadLock([&] {
result = _points;
return resultWithReadLock<QVector<glm::vec3>>([&] {
return _points;
});
return result;
}
void LineEntityItem::resetPointsChanged() {

View file

@ -33,7 +33,7 @@ PacketVersion versionForPacketType(PacketType packetType) {
case PacketType::EntityEdit:
case PacketType::EntityData:
case PacketType::EntityPhysics:
return static_cast<PacketVersion>(EntityVersion::MissingTextProperties);
return static_cast<PacketVersion>(EntityVersion::MissingLineProperties);
case PacketType::EntityQuery:
return static_cast<PacketVersion>(EntityQueryPacketVersion::ConicalFrustums);
case PacketType::AvatarIdentity:

View file

@ -250,7 +250,8 @@ enum class EntityVersion : PacketVersion {
CleanupProperties,
ImageEntities,
GridEntities,
MissingTextProperties
MissingTextProperties,
MissingLineProperties
};
enum class EntityScriptCallMethodVersion : PacketVersion {