expose removeCollisionComponent
This commit is contained in:
@@ -194,6 +194,7 @@ extern "C"
|
|||||||
FLUTTER_PLUGIN_EXPORT void ios_dummy();
|
FLUTTER_PLUGIN_EXPORT void ios_dummy();
|
||||||
FLUTTER_PLUGIN_EXPORT void flutter_filament_free(void *ptr);
|
FLUTTER_PLUGIN_EXPORT void flutter_filament_free(void *ptr);
|
||||||
FLUTTER_PLUGIN_EXPORT void add_collision_component(void *const sceneManager, EntityId entityId, void (*callback)(const EntityId entityId1, const EntityId entityId2), bool affectsCollidingTransform);
|
FLUTTER_PLUGIN_EXPORT void add_collision_component(void *const sceneManager, EntityId entityId, void (*callback)(const EntityId entityId1, const EntityId entityId2), bool affectsCollidingTransform);
|
||||||
|
FLUTTER_PLUGIN_EXPORT void remove_collision_component(void *const sceneManager, EntityId entityId);
|
||||||
FLUTTER_PLUGIN_EXPORT void add_animation_component(void *const sceneManager, EntityId entityId);
|
FLUTTER_PLUGIN_EXPORT void add_animation_component(void *const sceneManager, EntityId entityId);
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT EntityId create_geometry(void *const viewer, float* vertices, int numVertices, uint16_t* indices, int numIndices, const char* materialPath);
|
FLUTTER_PLUGIN_EXPORT EntityId create_geometry(void *const viewer, float* vertices, int numVertices, uint16_t* indices, int numIndices, const char* materialPath);
|
||||||
|
|||||||
@@ -589,6 +589,10 @@ extern "C"
|
|||||||
((SceneManager*)sceneManager)->addCollisionComponent(entityId, onCollisionCallback, affectsCollidingTransform);
|
((SceneManager*)sceneManager)->addCollisionComponent(entityId, onCollisionCallback, affectsCollidingTransform);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FLUTTER_PLUGIN_EXPORT void remove_collision_component(void *const sceneManager, EntityId entityId) {
|
||||||
|
((SceneManager*)sceneManager)->removeCollisionComponent(entityId);
|
||||||
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void add_animation_component(void *const sceneManager, EntityId entityId) {
|
FLUTTER_PLUGIN_EXPORT void add_animation_component(void *const sceneManager, EntityId entityId) {
|
||||||
((SceneManager*)sceneManager)->addAnimationComponent(entityId);
|
((SceneManager*)sceneManager)->addAnimationComponent(entityId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -626,15 +626,18 @@ abstract class FilamentController {
|
|||||||
Future addAnimationComponent(FilamentEntity entity);
|
Future addAnimationComponent(FilamentEntity entity);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Makes [collidableEntity] collidable with
|
/// Makes [entity] collidable.
|
||||||
/// (a) any entity whose transform is being controlled (via [control]) or
|
/// This allows you to call [testCollisions] with any other entity ("entity B") to see if [entity] has collided with entity B. The callback will be invoked if so.
|
||||||
/// (b) any entity that has been marked as non-transformable but collidable (via [markNonTransformableCollidable])
|
/// Alternatively, if [affectsTransform] is true and this entity collides with another entity, any queued position updates to the latter entity will be ignored.
|
||||||
/// These are differentiated because a collision will affect the transform for controlled entities
|
|
||||||
/// (e.g. if a controlled entity collides with a wall, we ignore the control update to the transform so it doesn't go through the wall)
|
|
||||||
///
|
///
|
||||||
Future addCollisionComponent(FilamentEntity collidableEntity,
|
Future addCollisionComponent(FilamentEntity entity,
|
||||||
{void Function(int entityId1, int entityId2)? callback,
|
{void Function(int entityId1, int entityId2)? callback,
|
||||||
bool affectsCollingTransform = false});
|
bool affectsTransform = false});
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Removes the collision component from [entity], meaning this will no longer be tested when [testCollisions] or [queuePositionUpdate] is called with another entity.
|
||||||
|
///
|
||||||
|
Future removeCollisionComponent(FilamentEntity entity);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Creates a (renderable) entity with the specified geometry and adds to the scene.
|
/// Creates a (renderable) entity with the specified geometry and adds to the scene.
|
||||||
|
|||||||
@@ -1485,10 +1485,12 @@ class FilamentControllerFFI extends FilamentController {
|
|||||||
return transformController;
|
return transformController;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final _collisions = <FilamentEntity, NativeCallable>{};
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future addCollisionComponent(FilamentEntity collidableEntity,
|
Future addCollisionComponent(FilamentEntity entity,
|
||||||
{void Function(int entityId1, int entityId2)? callback,
|
{void Function(int entityId1, int entityId2)? callback,
|
||||||
bool affectsCollingTransform = false}) async {
|
bool affectsTransform = false}) async {
|
||||||
if (_sceneManager == null) {
|
if (_sceneManager == null) {
|
||||||
throw Exception("SceneManager must be non-null");
|
throw Exception("SceneManager must be non-null");
|
||||||
}
|
}
|
||||||
@@ -1497,14 +1499,20 @@ class FilamentControllerFFI extends FilamentController {
|
|||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
var ptr = NativeCallable<
|
var ptr = NativeCallable<
|
||||||
Void Function(Int32 entityId1, Int32 entityId2)>.listener(callback);
|
Void Function(Int32 entityId1, Int32 entityId2)>.listener(callback);
|
||||||
add_collision_component(_sceneManager!, collidableEntity,
|
add_collision_component(
|
||||||
ptr.nativeFunction, affectsCollingTransform);
|
_sceneManager!, entity, ptr.nativeFunction, affectsTransform);
|
||||||
|
_collisions[entity] = ptr;
|
||||||
} else {
|
} else {
|
||||||
add_collision_component(
|
add_collision_component(
|
||||||
_sceneManager!, collidableEntity, nullptr, affectsCollingTransform);
|
_sceneManager!, entity, nullptr, affectsTransform);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future removeCollisionComponent(FilamentEntity entity) async {
|
||||||
|
remove_collision_component(_sceneManager!, entity);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future addAnimationComponent(FilamentEntity entity) async {
|
Future addAnimationComponent(FilamentEntity entity) async {
|
||||||
add_animation_component(_sceneManager!, entity);
|
add_animation_component(_sceneManager!, entity);
|
||||||
|
|||||||
@@ -931,6 +931,13 @@ external void add_collision_component(
|
|||||||
bool affectsCollidingTransform,
|
bool affectsCollidingTransform,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ffi.Native<ffi.Void Function(ffi.Pointer<ffi.Void>, EntityId)>(
|
||||||
|
symbol: 'remove_collision_component', assetId: 'flutter_filament_plugin')
|
||||||
|
external void remove_collision_component(
|
||||||
|
ffi.Pointer<ffi.Void> sceneManager,
|
||||||
|
int entityId,
|
||||||
|
);
|
||||||
|
|
||||||
@ffi.Native<ffi.Void Function(ffi.Pointer<ffi.Void>, EntityId)>(
|
@ffi.Native<ffi.Void Function(ffi.Pointer<ffi.Void>, EntityId)>(
|
||||||
symbol: 'add_animation_component', assetId: 'flutter_filament_plugin')
|
symbol: 'add_animation_component', assetId: 'flutter_filament_plugin')
|
||||||
external void add_animation_component(
|
external void add_animation_component(
|
||||||
|
|||||||
Reference in New Issue
Block a user