void SelectionPlugin::onUndoOperation( const UndoOperationPtr& operation ) { assert( operation != nullptr ); Class* klass = operation->getType(); if( !ClassInherits(klass, ReflectionGetType(SelectionOperation)) ) return; SelectionOperation* selection = RefCast<SelectionOperation>(operation).get(); selection->redo(); }
ResourceLoader* ResourceManager::findLoaderByClass(const Class* klass) { for(auto e : resourceLoaders) { auto& loader = e.value; auto resourceClass = loader->getResourceClass(); if(ClassInherits(resourceClass, klass)) return loader.get(); } return nullptr; }
static void ReflectionWalkArray(ReflectionContext* context) { const Field* field = context->field; std::vector<byte>& array = *(std::vector<byte>*) context->address; uint16 elementSize = ReflectionArrayGetElementSize(context->field); uint32 arraySize = array.size() / elementSize; context->arraySize = arraySize; context->walkArray(context, ReflectionWalkType::Begin); for(size_t i = 0; i < arraySize; i++) { void* address = (&array[0] + i * elementSize); context->elementAddress = address; if(FieldIsPointer(field) && !ReflectionWalkPointer(context)) continue; Object* object = context->object; Type* type = context->type; context->object = (Object*) context->elementAddress; context->type = field->type; bool isObject = ClassInherits((Class*) context->type, ObjectGetType()); if( isObject ) context->type = ClassGetType(context->object); if( isObject && !context->type ) { LogDebug("Could not get type out of object"); return; } context->walkArray(context, ReflectionWalkType::ElementBegin); ReflectionWalkType(context, context->type); context->walkArray(context, ReflectionWalkType::ElementEnd); context->object = object; context->type = type; } context->walkArray(context, ReflectionWalkType::End); }
void Camera::cull( RenderBlock& block, const Entity* entity ) { if( !entity ) return; // Try to see if this is a Group-derived node. Class* klass = entity->getType(); if( ClassInherits(klass, ReflectionGetType(Group)) ) { const Group* group = (Group*) entity; const Array<EntityPtr>& entities = group->getEntities(); // Cull the children entities recursively. for( size_t i = 0; i < entities.size(); i++ ) { const Entity* child = entities[i].get(); cull( block, child ); } return; } // If this is a visible.renderable object, then we perform frustum culling // and then we push it to a list of things passed later to the renderer. //entity->onPreCull(); if( !entity->isVisible() ) return; const Transform* transform = entity->getTransform().get(); const BoundingBox& box = transform->getWorldBoundingVolume(); bool isCulled = !entity->getTag(Tags::NonCulled); if( frustumCulling && isCulled && !frustum.intersects(box) ) return; #pragma TODO("Fix multiple geometry instancing") const Array<GeometryPtr>& geoms = entity->getGeometry(); for( size_t i = 0; i < geoms.size(); i++ ) { const GeometryPtr& geometry = geoms[i]; geometry->appendRenderables( block.renderables, transform ); } #if 0 const LightPtr& light = entity->getComponent<Light>(); if( light ) { LightState ls; ls.light = light.get(); ls.transform = transform.get(); block.lights.pushBack( ls ); } #endif #ifdef BUILD_DEBUG const ComponentMap& components = entity->getComponents(); for( auto it = components.begin(); it != components.end(); it++ ) { const ComponentPtr& component = it->value; component->onPreRender(*this); if( !component->isDebugRenderableVisible() ) continue; DebugDrawFlags flags = (DebugDrawFlags) 0; component->onDebugDraw(drawer, flags); } #endif }