From 0313b4905edc7385de80ce1f3f95eea3ca9a2004 Mon Sep 17 00:00:00 2001 From: Ada Date: Fri, 4 Apr 2025 00:09:00 +1000 Subject: [PATCH] Toggleable unlit mode, physical hitbox --- .../entities-renderer/src/RenderableCanvasEntityItem.cpp | 7 ++++--- .../entities-renderer/src/RenderableCanvasEntityItem.h | 2 ++ libraries/entities/src/CanvasEntityItem.h.in | 4 +--- libraries/entities/src/EntityItemProperties.txt | 1 + .../create/entityProperties/html/js/entityProperties.js | 7 ++++++- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableCanvasEntityItem.cpp b/libraries/entities-renderer/src/RenderableCanvasEntityItem.cpp index c44f5f815b..4eadab2b63 100644 --- a/libraries/entities-renderer/src/RenderableCanvasEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableCanvasEntityItem.cpp @@ -12,8 +12,6 @@ #include #include -#include "RenderPipelines.h" - using namespace render; using namespace render::entities; @@ -30,6 +28,7 @@ CanvasEntityRenderer::~CanvasEntityRenderer() { void CanvasEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) { _texture = entity->getTexture(); + _unlit = entity->getUnlit(); } void CanvasEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene, Transaction& transaction, const TypedEntityPointer& entity) { @@ -65,7 +64,9 @@ void CanvasEntityRenderer::doRender(RenderArgs* args) { _prevRenderTransform = transform; } - DependencyManager::get()->bindSimpleProgram(batch, true, true); + // FIXME: bindSimpleProgram doesn't support transparent and unlit, + // so we can only have one or the other + DependencyManager::get()->bindSimpleProgram(batch, true, !_unlit, _unlit, false, false, true, graphics::MaterialKey::CullFaceMode::CULL_NONE); DependencyManager::get()->renderQuad( batch, glm::vec2(-0.5f), glm::vec2(0.5f), glm::vec2(0.0f, 1.0f), glm::vec2(1.0f, 0.0f), glm::vec4(1.0f), _geometryId diff --git a/libraries/entities-renderer/src/RenderableCanvasEntityItem.h b/libraries/entities-renderer/src/RenderableCanvasEntityItem.h index 2142fd286f..c7b96b4148 100644 --- a/libraries/entities-renderer/src/RenderableCanvasEntityItem.h +++ b/libraries/entities-renderer/src/RenderableCanvasEntityItem.h @@ -36,7 +36,9 @@ protected: private: gpu::TexturePointer _texture; + std::shared_ptr _material { std::make_shared() }; int _geometryId { 0 }; + bool _unlit { false }; }; } } diff --git a/libraries/entities/src/CanvasEntityItem.h.in b/libraries/entities/src/CanvasEntityItem.h.in index 54a4edf0af..956f305b84 100644 --- a/libraries/entities/src/CanvasEntityItem.h.in +++ b/libraries/entities/src/CanvasEntityItem.h.in @@ -19,9 +19,7 @@ public: CanvasEntityItem(const EntityItemID& entityItemID); ~CanvasEntityItem(); - bool shouldBePhysical() const override { return false; } - - virtual bool supportsDetailedIntersection() const override { return false; } + virtual ShapeType getShapeType() const override { return SHAPE_TYPE_BOX; } ALLOW_INSTANTIATION // This class can be instantiated ENTITY_PROPERTY_SUBCLASS_METHODS diff --git a/libraries/entities/src/EntityItemProperties.txt b/libraries/entities/src/EntityItemProperties.txt index fe95f79114..bfcbb2d401 100644 --- a/libraries/entities/src/EntityItemProperties.txt +++ b/libraries/entities/src/EntityItemProperties.txt @@ -269,3 +269,4 @@ enum:SOUND_LOCAL_ONLY prop:localOnly type:bool default:false, Canvas enum:CANVAS_WIDTH prop:width type:uint16_t default:128 basicProp, enum:CANVAS_HEIGHT prop:height type:uint16_t default:128 basicProp, +enum:UNLIT prop:unlit type:bool default:false common renderProp, diff --git a/scripts/system/create/entityProperties/html/js/entityProperties.js b/scripts/system/create/entityProperties/html/js/entityProperties.js index 64969e9136..12e47a2a14 100644 --- a/scripts/system/create/entityProperties/html/js/entityProperties.js +++ b/scripts/system/create/entityProperties/html/js/entityProperties.js @@ -1706,6 +1706,11 @@ const GROUPS = [ type: "number-draggable", propertyID: "height", }, + { + label: "Unlit", + type: "bool", + propertyID: "unlit", + } ] }, { @@ -2193,7 +2198,7 @@ const GROUPS_PER_TYPE = { PolyVox: [ 'base', 'polyvox', 'spatial', 'behavior', 'grabAndEquip', 'scripts', 'collision', 'physics' ], Grid: [ 'base', 'grid', 'spatial', 'behavior', 'grabAndEquip', 'scripts', 'physics' ], Sound: [ 'base', 'sound', 'spatial', 'behavior', 'grabAndEquip', 'scripts', 'physics' ], - Canvas: [ 'base', 'canvas', 'spatial', 'grabAndEquip', 'scripts' ], + Canvas: [ 'base', 'canvas', 'spatial', 'grabAndEquip', 'scripts', 'physics' ], Multiple: [ 'base', 'spatial', 'behavior', 'grabAndEquip', 'scripts', 'collision', 'physics' ], };