mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 08:04:01 +02:00
Drafting the mechanism to add shape pipeline
This commit is contained in:
parent
d15c4ea2d3
commit
c3dd25e499
4 changed files with 54 additions and 2 deletions
|
@ -142,6 +142,15 @@ namespace render {
|
|||
payload->render(args);
|
||||
}
|
||||
}
|
||||
template <>
|
||||
const ShapeKey shapeGetShapeKey(const ParticlePayloadData::Pointer& payload) {
|
||||
return ShapeKey::Builder().withCustom(75).build();
|
||||
}
|
||||
|
||||
template <>
|
||||
bool shapeDefineCustomShapePipeline(const ParticlePayloadData::Pointer& payload, ShapePlumber& plumber, const ShapeKey& key) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -44,10 +44,17 @@ void renderShape(RenderArgs* args, const ShapePlumberPointer& shapeContext, cons
|
|||
auto key = item.getShapeKey() | globalKey;
|
||||
if (key.isValid() && !key.hasOwnPipeline()) {
|
||||
args->_pipeline = shapeContext->pickPipeline(args, key);
|
||||
if (!args->_pipeline) {
|
||||
if (key.isCustom()) {
|
||||
if (item.defineCustomShapePipeline(*shapeContext, key)) {
|
||||
args->_pipeline = shapeContext->pickPipeline(args, key);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (args->_pipeline) {
|
||||
args->_pipeline->prepareShapeItem(args, key, item);
|
||||
item.render(args);
|
||||
}
|
||||
}
|
||||
args->_pipeline = nullptr;
|
||||
} else if (key.hasOwnPipeline()) {
|
||||
item.render(args);
|
||||
|
@ -111,7 +118,19 @@ void render::renderStateSortShapes(const RenderContextPointer& renderContext,
|
|||
for (auto& pipelineKey : sortedPipelines) {
|
||||
auto& bucket = sortedShapes[pipelineKey];
|
||||
args->_pipeline = shapeContext->pickPipeline(args, pipelineKey);
|
||||
if (!args->_pipeline) {
|
||||
if (!args->_pipeline) {
|
||||
if (pipelineKey.isCustom()) {
|
||||
if (bucket.front().defineCustomShapePipeline(*shapeContext, pipelineKey)) {
|
||||
args->_pipeline = shapeContext->pickPipeline(args, pipelineKey);
|
||||
if (!args->_pipeline) {
|
||||
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
for (auto& item : bucket) {
|
||||
|
|
|
@ -320,6 +320,7 @@ public:
|
|||
virtual void render(RenderArgs* args) = 0;
|
||||
|
||||
virtual const ShapeKey getShapeKey() const = 0;
|
||||
virtual bool defineCustomShapePipeline(ShapePlumber& plumber, const ShapeKey& key) const = 0;
|
||||
|
||||
virtual uint32_t fetchMetaSubItems(ItemIDs& subItems) const = 0;
|
||||
|
||||
|
@ -369,6 +370,7 @@ public:
|
|||
|
||||
// Shape Type Interface
|
||||
const ShapeKey getShapeKey() const { return _payload->getShapeKey(); }
|
||||
bool defineCustomShapePipeline(ShapePlumber& plumber, const ShapeKey& key) const { return _payload->defineCustomShapePipeline(plumber, key); }
|
||||
|
||||
// Meta Type Interface
|
||||
uint32_t fetchMetaSubItems(ItemIDs& subItems) const { return _payload->fetchMetaSubItems(subItems); }
|
||||
|
@ -415,6 +417,7 @@ template <class T> void payloadRender(const std::shared_ptr<T>& payloadData, Ren
|
|||
// When creating a new shape payload you need to create a specialized version, or the ShapeKey will be ownPipeline,
|
||||
// implying that the shape will setup its own pipeline without the use of the ShapeKey.
|
||||
template <class T> const ShapeKey shapeGetShapeKey(const std::shared_ptr<T>& payloadData) { return ShapeKey::Builder::ownPipeline(); }
|
||||
template <class T> bool shapeDefineCustomShapePipeline(const std::shared_ptr<T>& payloadData, ShapePlumber& plumber, const ShapeKey& key) { return false; }
|
||||
|
||||
// Meta Type Interface
|
||||
// Meta items act as the grouping object for several sub items (typically shapes).
|
||||
|
@ -441,6 +444,7 @@ public:
|
|||
|
||||
// Shape Type interface
|
||||
virtual const ShapeKey getShapeKey() const override { return shapeGetShapeKey<T>(_data); }
|
||||
virtual bool defineCustomShapePipeline(ShapePlumber& plumber, const ShapeKey& key) const override { return shapeDefineCustomShapePipeline<T>(_data, plumber, key); }
|
||||
|
||||
// Meta Type Interface
|
||||
virtual uint32_t fetchMetaSubItems(ItemIDs& subItems) const override { return metaFetchMetaSubItems<T>(_data, subItems); }
|
||||
|
|
|
@ -39,7 +39,19 @@ public:
|
|||
OWN_PIPELINE,
|
||||
INVALID,
|
||||
|
||||
CUSTOM_0,
|
||||
CUSTOM_1,
|
||||
CUSTOM_2,
|
||||
CUSTOM_3,
|
||||
CUSTOM_4,
|
||||
CUSTOM_5,
|
||||
CUSTOM_6,
|
||||
CUSTOM_7,
|
||||
|
||||
NUM_FLAGS, // Not a valid flag
|
||||
|
||||
CUSTOM_MASK = (0xFF << CUSTOM_0),
|
||||
|
||||
};
|
||||
using Flags = std::bitset<NUM_FLAGS>;
|
||||
|
||||
|
@ -74,6 +86,8 @@ public:
|
|||
Builder& withOwnPipeline() { _flags.set(OWN_PIPELINE); return (*this); }
|
||||
Builder& invalidate() { _flags.set(INVALID); return (*this); }
|
||||
|
||||
Builder& withCustom(uint8_t custom) { _flags &= (~CUSTOM_MASK); _flags |= (custom << CUSTOM_0); return (*this); }
|
||||
|
||||
static const ShapeKey ownPipeline() { return Builder().withOwnPipeline(); }
|
||||
static const ShapeKey invalid() { return Builder().invalidate(); }
|
||||
|
||||
|
@ -128,6 +142,9 @@ public:
|
|||
Builder& withCullFace() { _flags.reset(NO_CULL_FACE); _mask.set(NO_CULL_FACE); return (*this); }
|
||||
Builder& withoutCullFace() { _flags.set(NO_CULL_FACE); _mask.set(NO_CULL_FACE); return (*this); }
|
||||
|
||||
Builder& withCustom(uint8_t custom) { _flags &= (~CUSTOM_MASK); _flags |= (custom << CUSTOM_0); _mask |= (CUSTOM_MASK); return (*this); }
|
||||
Builder& withoutCustom() { _flags &= (~CUSTOM_MASK); _mask |= (CUSTOM_MASK); return (*this); }
|
||||
|
||||
protected:
|
||||
friend class Filter;
|
||||
Flags _flags{0};
|
||||
|
@ -156,6 +173,9 @@ public:
|
|||
bool hasOwnPipeline() const { return _flags[OWN_PIPELINE]; }
|
||||
bool isValid() const { return !_flags[INVALID]; }
|
||||
|
||||
uint8_t getCustom() const { return (_flags.to_ulong() & CUSTOM_MASK) >> CUSTOM_0; }
|
||||
bool isCustom() const { return (_flags.to_ulong() & CUSTOM_MASK); }
|
||||
|
||||
// Comparator for use in stl containers
|
||||
class Hash {
|
||||
public:
|
||||
|
|
Loading…
Reference in a new issue