fix: reduce size of pick functor for compatibility with armeabi-v7a
This commit is contained in:
@@ -178,6 +178,12 @@ external void Viewer_pick(
|
|||||||
callback,
|
callback,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ffi.Native<ffi.Bool Function(ffi.Pointer<TViewer>, EntityId)>(isLeaf: true)
|
||||||
|
external bool Viewer_isNonPickableEntity(
|
||||||
|
ffi.Pointer<TViewer> viewer,
|
||||||
|
int entityId,
|
||||||
|
);
|
||||||
|
|
||||||
@ffi.Native<ffi.Pointer<TEngine> Function(ffi.Pointer<TViewer>)>(isLeaf: true)
|
@ffi.Native<ffi.Pointer<TEngine> Function(ffi.Pointer<TViewer>)>(isLeaf: true)
|
||||||
external ffi.Pointer<TEngine> Viewer_getEngine(
|
external ffi.Pointer<TEngine> Viewer_getEngine(
|
||||||
ffi.Pointer<TViewer> viewer,
|
ffi.Pointer<TViewer> viewer,
|
||||||
|
|||||||
@@ -99,6 +99,12 @@ namespace thermion
|
|||||||
void setBackgroundImagePosition(float x, float y, bool clamp, uint32_t width, uint32_t height);
|
void setBackgroundImagePosition(float x, float y, bool clamp, uint32_t width, uint32_t height);
|
||||||
|
|
||||||
typedef void (*PickCallback)(EntityId entityId, int x, int y, View *view, float depth, float fragX, float fragY, float fragZ);
|
typedef void (*PickCallback)(EntityId entityId, int x, int y, View *view, float depth, float fragX, float fragY, float fragZ);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Returns true if the specified entity is a gizmo, grid or background image entity.
|
||||||
|
///
|
||||||
|
bool isNonPickableEntity(EntityId entityId);
|
||||||
|
|
||||||
void pick(View *view, uint32_t x, uint32_t y, PickCallback callback);
|
void pick(View *view, uint32_t x, uint32_t y, PickCallback callback);
|
||||||
|
|
||||||
Engine* getEngine() {
|
Engine* getEngine() {
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ extern "C"
|
|||||||
EMSCRIPTEN_KEEPALIVE TSwapChain* Viewer_getSwapChainAt(TViewer *tViewer, int index);
|
EMSCRIPTEN_KEEPALIVE TSwapChain* Viewer_getSwapChainAt(TViewer *tViewer, int index);
|
||||||
EMSCRIPTEN_KEEPALIVE void Viewer_setViewRenderable(TViewer *viewer, TSwapChain *swapChain, TView* view, bool renderable);
|
EMSCRIPTEN_KEEPALIVE void Viewer_setViewRenderable(TViewer *viewer, TSwapChain *swapChain, TView* view, bool renderable);
|
||||||
EMSCRIPTEN_KEEPALIVE void Viewer_pick(TViewer *viewer, TView* tView, int x, int y, void (*callback)(EntityId entityId, int x, int y, TView *tView, float depth, float fragX, float fragY, float fragZ));
|
EMSCRIPTEN_KEEPALIVE void Viewer_pick(TViewer *viewer, TView* tView, int x, int y, void (*callback)(EntityId entityId, int x, int y, TView *tView, float depth, float fragX, float fragY, float fragZ));
|
||||||
|
EMSCRIPTEN_KEEPALIVE bool Viewer_isNonPickableEntity(TViewer *viewer, EntityId entityId);
|
||||||
|
|
||||||
// Engine
|
// Engine
|
||||||
EMSCRIPTEN_KEEPALIVE TEngine *Viewer_getEngine(TViewer* viewer);
|
EMSCRIPTEN_KEEPALIVE TEngine *Viewer_getEngine(TViewer* viewer);
|
||||||
|
|||||||
@@ -1191,23 +1191,16 @@ namespace thermion
|
|||||||
return _engine->getCameraComponent(Entity::import(entity));
|
return _engine->getCameraComponent(Entity::import(entity));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FilamentViewer::isNonPickableEntity(EntityId entityId) {
|
||||||
|
auto renderable = Entity::import(entityId);
|
||||||
|
return _sceneManager->isGizmoEntity(renderable) || renderable == _imageEntity || renderable == _sceneManager->_gridOverlay->sphere() || _sceneManager->_gridOverlay->grid();
|
||||||
|
}
|
||||||
|
|
||||||
void FilamentViewer::pick(View *view, uint32_t x, uint32_t y, PickCallback callback)
|
void FilamentViewer::pick(View *view, uint32_t x, uint32_t y, PickCallback callback)
|
||||||
{
|
{
|
||||||
view->pick(x, y, [=](filament::View::PickingQueryResult const &result) {
|
view->pick(x, y, [=](filament::View::PickingQueryResult const &result) {
|
||||||
|
callback(Entity::smuggle(result.renderable), x, y, view, result.depth, result.fragCoords.x, result.fragCoords.y, result.fragCoords.z);
|
||||||
if(_sceneManager->isGizmoEntity(result.renderable)) {
|
});
|
||||||
Log("Gizmo entity, ignoring");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
std::unordered_set<Entity, Entity::Hasher> nonPickableEntities = {
|
|
||||||
_imageEntity,
|
|
||||||
_sceneManager->_gridOverlay->sphere(),
|
|
||||||
_sceneManager->_gridOverlay->grid(),
|
|
||||||
};
|
|
||||||
|
|
||||||
if (nonPickableEntities.find(result.renderable) == nonPickableEntities.end()) {
|
|
||||||
callback(Entity::smuggle(result.renderable), x, y, view, result.depth, result.fragCoords.x, result.fragCoords.y, result.fragCoords.z);
|
|
||||||
} });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FilamentViewer::unprojectTexture(EntityId entityId, uint8_t *input, uint32_t inputWidth, uint32_t inputHeight, uint8_t *out, uint32_t outWidth, uint32_t outHeight)
|
void FilamentViewer::unprojectTexture(EntityId entityId, uint8_t *input, uint32_t inputWidth, uint32_t inputHeight, uint8_t *out, uint32_t outWidth, uint32_t outHeight)
|
||||||
|
|||||||
@@ -56,6 +56,11 @@ extern "C"
|
|||||||
((FilamentViewer *)viewer)->pick(view, static_cast<uint32_t>(x), static_cast<uint32_t>(y), reinterpret_cast<FilamentViewer::PickCallback>(callback));
|
((FilamentViewer *)viewer)->pick(view, static_cast<uint32_t>(x), static_cast<uint32_t>(y), reinterpret_cast<FilamentViewer::PickCallback>(callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EMSCRIPTEN_KEEPALIVE bool Viewer_isNonPickableEntity(TViewer *tViewer, EntityId entityId) {
|
||||||
|
auto *viewer = reinterpret_cast<FilamentViewer*>(tViewer);
|
||||||
|
return viewer->isNonPickableEntity(entityId);
|
||||||
|
}
|
||||||
|
|
||||||
EMSCRIPTEN_KEEPALIVE void destroy_filament_viewer(TViewer *viewer)
|
EMSCRIPTEN_KEEPALIVE void destroy_filament_viewer(TViewer *viewer)
|
||||||
{
|
{
|
||||||
delete ((FilamentViewer *)viewer);
|
delete ((FilamentViewer *)viewer);
|
||||||
|
|||||||
Reference in New Issue
Block a user