implement picker/getNameForEntity
This commit is contained in:
@@ -946,6 +946,16 @@ size_t AssetManager::getLightEntityCount(EntityId entity) const noexcept {
|
||||
return asset.mAsset->getLightEntityCount();
|
||||
}
|
||||
|
||||
const char* AssetManager::getNameForEntity(EntityId entityId) {
|
||||
const auto& entity = Entity::import(entityId);
|
||||
auto nameInstance = _ncm->getInstance(entity);
|
||||
if(!nameInstance.isValid()) {
|
||||
Log("Failed to find name instance for entity ID %d", entityId);
|
||||
return nullptr;
|
||||
}
|
||||
return _ncm->getName(nameInstance);
|
||||
}
|
||||
|
||||
|
||||
} // namespace polyvox
|
||||
|
||||
|
||||
@@ -113,6 +113,8 @@ static const uint16_t sFullScreenTriangleIndices[3] = {0, 1, 2};
|
||||
|
||||
FilamentViewer::FilamentViewer(const void* sharedContext, const ResourceLoaderWrapper* const resourceLoaderWrapper, void* const platform, const char* uberArchivePath)
|
||||
: _resourceLoaderWrapper(resourceLoaderWrapper) {
|
||||
|
||||
ASSERT_POSTCONDITION(_resourceLoaderWrapper != nullptr, "Resource loader must be non-null");
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
ASSERT_POSTCONDITION(platform == nullptr, "Custom Platform not supported on iOS");
|
||||
@@ -630,7 +632,7 @@ void FilamentViewer::createRenderTarget(intptr_t texture, uint32_t width, uint32
|
||||
// Make a specific viewport just for our render target
|
||||
_view->setRenderTarget(_rt);
|
||||
|
||||
Log("Set render target for glTextureId %u %u x %u", texture, width, height);
|
||||
Log("Set render target for texture id %u to %u x %u", texture, width, height);
|
||||
|
||||
}
|
||||
|
||||
@@ -1051,7 +1053,16 @@ void FilamentViewer::scrollUpdate(float x, float y, float delta) {
|
||||
}
|
||||
|
||||
void FilamentViewer::scrollEnd() {
|
||||
|
||||
// noop
|
||||
}
|
||||
|
||||
void FilamentViewer::pick(uint32_t x, uint32_t y, EntityId* entityId) {
|
||||
Log("Picking at %d,%d", x, y);
|
||||
_view->pick(x, y, [=](filament::View::PickingQueryResult const & result) {
|
||||
|
||||
*entityId = Entity::smuggle(result.renderable);
|
||||
Log("Got result %d", *entityId);
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace polyvox
|
||||
|
||||
@@ -373,15 +373,24 @@ extern "C" {
|
||||
((AssetManager*)assetManager)->stopAnimation(asset, index);
|
||||
}
|
||||
|
||||
int hide_mesh(void* assetManager, EntityId asset, const char* meshName) {
|
||||
FLUTTER_PLUGIN_EXPORT int hide_mesh(void* assetManager, EntityId asset, const char* meshName) {
|
||||
return ((AssetManager*)assetManager)->hide(asset, meshName);
|
||||
}
|
||||
|
||||
int reveal_mesh(void* assetManager, EntityId asset, const char* meshName) {
|
||||
FLUTTER_PLUGIN_EXPORT int reveal_mesh(void* assetManager, EntityId asset, const char* meshName) {
|
||||
return ((AssetManager*)assetManager)->reveal(asset, meshName);
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void ios_dummy() {
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void pick(void* const viewer, int x, int y, EntityId* entityId) {
|
||||
((FilamentViewer*)viewer)->pick(static_cast<uint32_t>(x), static_cast<uint32_t>(y), static_cast<int32_t*>(entityId));
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT const char* get_name_for_entity(void* const assetManager, const EntityId entityId) {
|
||||
return ((AssetManager*)assetManager)->getNameForEntity(entityId);
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void ios_dummy() {
|
||||
Log("Dummy called");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -444,6 +444,16 @@ extern "C"
|
||||
fut.wait();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT const char* get_name_for_entity_ffi(void* const assetManager, const EntityId entityId) {
|
||||
std::packaged_task<const char*()> lambda([&] {
|
||||
return get_name_for_entity(assetManager, entityId);
|
||||
});
|
||||
auto fut = _rl->add_task(lambda);
|
||||
fut.wait();
|
||||
return fut.get();
|
||||
}
|
||||
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void ios_dummy_ffi() {
|
||||
Log("Dummy called");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user