xissburg / edyn Goto Github PK
View Code? Open in Web Editor NEWEdyn is a real-time physics engine organized as an ECS.
License: MIT License
Edyn is a real-time physics engine organized as an ECS.
License: MIT License
Hi, i've been playing with the new functions. I found an issue
so when using rigidbody_set_kind with a kinematic type with an asynchronous execution mode
it only updates the tags for the remote entity and the local is left behind
so when afterwards i call
update_kinematic_position i get an assert for the tag
EDYN_ASSERT(registry.any_of<kinematic_tag>(entity));
i believe local entity's tags should also be updated
I decided to update to the latest commit 3c8efcf. But when I try and build using GCC v11, it spits out many errors:
edyn/include/edyn/shapes/shapes.hpp:133:34: error: call to non-‘constexpr’ function ‘edyn::vector3 edyn::coordinate_axis_vector(coordinate_axis)’
133 | return coordinate_axis_vector(shape.axis);
| ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
In file included from /edyn/include/edyn/collision/collide.hpp:4,
from /edyn/src/edyn/collision/collide/collide_sphere_plane.cpp:1:
/edyn/include/edyn/shapes/shapes.hpp: In function ‘constexpr edyn::vector3 edyn::shape_rolling_direction(const ShapeType&) [with ShapeType = cylinder_shape]’:
/edyn/include/edyn/shapes/shapes.hpp:133:34: error: call to non-‘constexpr’ function ‘edyn::vector3 edyn::coordinate_axis_vector(coordinate_axis)’
133 | return coordinate_axis_vector(shape.axis);
| ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
In file included from /edyn/include/edyn/shapes/cylinder_shape.hpp:7,
from /edyn/include/edyn/shapes/shapes.hpp:6:
/edyn/include/edyn/math/coordinate_axis.hpp:23:16: note: ‘edyn::vector3 edyn::coordinate_axis_vector(coordinate_axis)’ declared here
23 | inline vector3 coordinate_axis_vector(coordinate_axis axis) {
| ^~~~~~~~~~~~~~~~~~~~~~
I am attempting to build a basic 2D side scrolling platform game. Small disclaimer, this is my first time using a proper physics library but I wanted to try out enTT in my project, making Edyn a seemingly easy first choice to try out for physics.
I have a working example where collision occurs just fine: a dynamic box entity begins just above a static box entity and falls to the static entity, preventing the dynamic entity from moving further. The issue occurs when I add a single impulse at initialization of the dynamic entity, simulating a jump in the y axis. The impulse works as expected, however once the dynamic entity falls to the static entity, it falls through it.
At first, I assumed this issue was caused by an incorrect/large step size. However in both cases with and without the impulse a contact is generated when the dynamic entity touches the static entity, leading me to believe something else is broken? The one difference I did find is that in the working case, two contacts events are produced but only one is triggered for the fail case. Any help would be appreciated.
Edyn Version: Latest Master/1.1.0
Code Snippet:
#include <entt/entt.hpp>
#include <edyn/edyn.hpp>
entt::registry reg;
entt::entity player;
void contact_started(entt::registry ®istry, entt::entity entity)
{
auto &manifold = registry.get<edyn::contact_manifold>(entity);
float normal_impulse = 0;
for (unsigned i = 0; i < manifold.num_points; ++i) {
auto &cp = manifold.point[manifold.ids[i]];
normal_impulse += cp.normal_impulse + cp.normal_restitution_impulse;
}
// Do something with `normal_impulse`, e.g. play sound.
}
void GameInitialize()
{
edyn::init();
edyn::attach(reg);
edyn::on_contact_started(reg).connect<&contact_started>(reg);
{
auto def = edyn::rigidbody_def();
def.kind = edyn::rigidbody_kind::rb_dynamic;
def.position = {0.0f, 20.0f, 0.0f};
// NOTE: toggle to see the issue
if (1)
{
def.linvel = edyn::vector3_zero;
}
else
{
def.linvel = {0.0f, 50.0f, 0.0f};
}
def.shape = edyn::box_shape{0.5f, 0.2f, 0.4f};
def.mass = 50.0f;
def.update_inertia();
def.material->restitution = 0.2f;
def.material->friction = 0.9f;
def.gravity = edyn::gravity_earth;
player = reg.create();
edyn::make_rigidbody(player, reg, def);
}
{
auto def = edyn::rigidbody_def();
def.kind = edyn::rigidbody_kind::rb_static;
def.position = {0.0f, 0.0f, 0.0f};
def.linvel = edyn::vector3_zero;
def.shape = edyn::box_shape{10.5f, 1.0f, 0.4f};
def.material->restitution = 0.2f;
def.material->friction = 0.9f;
auto ground = reg.create();
edyn::make_rigidbody(ground, reg, def);
}
}
void GameUpdate()
{
edyn::update(reg);
}
void GameShutdown()
{
edyn::detach(reg);
edyn::deinit();
}
int main(int argc, char** argv)
{
GameInitialize();
for (;;)
{
GameUpdate();
}
GameShutdown();
}
You closed the previous issue, but in a comment there i stated this problem as well.
Opening it as a new one for a better tracking.
There is a crash when doing the following
Start with a dynamic rigidbody without a shape and with enabled gravity.
After that rigidbody_set_kind to kinematic
void broadphase::set_procedural(entt::entity entity, bool procedural) {
auto &resident = m_registry->get<tree_resident>(entity); <--- assert here
include\edyn/util/island_util.hpp(5,10): fatal error C1083: Cannot open include file: 'entt/entity/utility.hpp': No such file or directory
So i have this code here experimenting with the new set_kind function. As stated in the documentation before i update the kind
i also update the mass and intertia, making sure they are fine.
But after the call to the rigidbody_set_kind i get an asset for the mass telling me it's not in the valid range.
I set it before the call to set_kind having these check there passing and everything is valid.
I suspect the entity changes are not processed before the set_kind message is
void rigidbody_assert_supports_kind(entt::registry ®istry, entt::entity entity, rigidbody_kind kind) {
if (kind == rigidbody_kind::rb_dynamic) {
auto &mass = registry.get<edyn::mass>(entity);
EDYN_ASSERT(mass > EDYN_EPSILON && mass < large_scalar, "Dynamic rigid body must have non-zero mass.");
auto &inertia = registry.get<edyn::inertia>(entity);
EDYN_ASSERT(inertia != matrix3x3_zero, "Dynamic rigid body must have non-zero inertia.");
}
}
void update_rigidbody_mass(entt::entity entity, entt::registry& registry, const rigidbody_def& def)
{
if(def.kind == rigidbody_kind::rb_dynamic)
{
EDYN_ASSERT(def.mass > EDYN_EPSILON && def.mass < large_scalar, "Dynamic rigid body must have non-zero mass.");
registry.emplace_or_replace<mass>(entity, def.mass);
registry.emplace_or_replace<mass_inv>(entity, scalar(1) / def.mass);
}
else
{
registry.emplace_or_replace<mass>(entity, EDYN_SCALAR_MAX);
registry.emplace_or_replace<mass_inv>(entity, scalar(0));
}
// I even added those 2 as well
registry.patch<mass>(entity);
registry.patch<mass_inv>(entity);
}
void recreate_phyisics_body(physics_component& rigidbody, bool force = false)
{
bool is_kind_dirty = rigidbody.is_property_dirty(physics_property::kind);
bool needs_recreation = force; // || rigidbody.is_property_dirty(physics_property::kind);
if(needs_recreation)
{
recreate_phyisics_entity(rigidbody);
}
auto owner = rigidbody.get_owner();
auto& body = owner.get<edyn::rigidbody>();
auto internal_entity = body.internal;
auto entity = internal_entity.entity();
auto& registry = *internal_entity.registry();
update_def_mass(rigidbody, body.def);
update_def_shape(rigidbody, body.def);
update_def_material(rigidbody, body.def);
update_def_gravity(rigidbody, body.def);
update_def_kind(rigidbody, body.def);
update_def_inertia(rigidbody, body.def);
if(needs_recreation)
{
edyn::make_rigidbody(entity, registry, body.def);
}
else
{
if(rigidbody.is_property_dirty(physics_property::mass) || is_kind_dirty)
{
edyn::update_rigidbody_mass(entity, registry, body.def);
edyn::update_rigidbody_inertia(entity, registry, body.def);
}
if(rigidbody.is_property_dirty(physics_property::gravity) || is_kind_dirty)
{
edyn::update_rigidbody_gravity(entity, registry, body.def);
}
if(rigidbody.is_property_dirty(physics_property::material) || is_kind_dirty)
{
edyn::update_rigidbody_material(entity, registry, body.def);
}
if(rigidbody.is_property_dirty(physics_property::shape) || is_kind_dirty)
{
edyn::update_rigidbody_shape(entity, registry, body.def);
edyn::update_rigidbody_inertia(entity, registry, body.def);
}
if(is_kind_dirty)
{
edyn::update_rigidbody_kind(entity, registry, body.def);
}
if(body.def.kind == edyn::rigidbody_kind::rb_dynamic)
{
if(rigidbody.is_any_property_dirty())
{
edyn::wake_up_entity(registry, entity);
}
}
}
rigidbody.set_dirty(system_id, false);
}
Using VS2022 17.8.2, tried to just cmake . and compile using generated solution. But get many errors, below is the first one:
1>broadphase.cpp
1>D:\UE5\edyn-master\include\edyn\util\constraint_util.hpp(61,51): error C2760: syntax error: ')' was unexpected here; expected 'expression'
1>(compiling source file 'src/edyn/collision/broadphase.cpp')
1>D:\UE5\edyn-master\include\edyn\util\constraint_util.hpp(61,51): error C3878: syntax error: unexpected token ')' following 'simple_declaration'
1>(compiling source file 'src/edyn/collision/broadphase.cpp')
1>D:\UE5\edyn-master\include\edyn\util\constraint_util.hpp(61,51): message : error recovery skipped: ')'
1>(compiling source file 'src/edyn/collision/broadphase.cpp')
1>D:\UE5\edyn-master\src\edyn\collision\broadphase.cpp(37,40): error C2275: 'edyn::collision_filter': expected an expression instead of a type
Suppose you want to remove the shape of an entity at runtime
entity.remove<edyn::box_shape>();
entity.remove<edyn::shape_index>();
entity.remove<edyn::AABB>();
entity.remove<edyn::collision_filter>();
then the broadphase should listen to the on_destroy as well
broadphase::broadphase(entt::registry ®istry)
: m_registry(®istry)
{
registry.on_construct<AABB>().connect<&broadphase::on_construct_aabb>(*this);
registry.on_destroy<AABB>().connect<&broadphase::on_destroy_aabb>(*this);
i suggest changing the structure of the m_new_aabb_entities to something like
// entity, added/removed
std::vector<std::pair<entt::entity, bool>> m_new_aabb_entities;
and checking if added/removed in the
init_new_aabb_entities
something like
void broadphase::init_new_aabb_entities() {
if (m_new_aabb_entities.empty()) {
return;
}
auto aabb_view = m_registry->view<AABB>();
auto procedural_view = m_registry->view<procedural_tag>();
for (auto kvp : m_new_aabb_entities) {
auto entity = kvp.first;
auto added = kvp.second;
// Entity might've been destroyed, thus skip it.
if (!m_registry->valid(entity)) continue;
if(added)
{
auto &aabb = aabb_view.get<AABB>(entity);
bool procedural = procedural_view.contains(entity);
auto &tree = procedural ? m_tree : m_np_tree;
tree_node_id_t id = tree.create(aabb, entity);
m_registry->emplace<tree_resident>(entity, id, procedural);
}
else
{
m_registry->remove<tree_resident>(entity);
}
}
m_new_aabb_entities.clear();
}
I am getting a large number of build errors.
So when using async mode the registry_operation does the operations with same type sequentially
which does not correspond to the sync mode
for (auto &op : emplace_components) {
op->execute(registry, entity_map);
}
for (auto &op : replace_components) {
op->execute(registry, entity_map);
}
for (auto &op : remove_components) {
op->execute(registry, entity_map);
}
for example
// these 3 operations will trigger after the operations below which is not the same behavior
registry.remove<graph_node>(entity);
registry.remove<multi_island_resident>(entity);
registry.remove<island_resident>(entity);
// Insert rigid body as a node in the entity graph.
auto non_connecting = def.kind != rigidbody_kind::rb_dynamic;
auto node_index = registry.ctx().get<entity_graph>().insert_node(entity, non_connecting);
registry.emplace_or_replace<graph_node>(entity, node_index);
if(def.kind == rigidbody_kind::rb_dynamic)
{
registry.emplace_or_replace<island_resident>(entity);
}
else
{
registry.emplace_or_replace<multi_island_resident>(entity);
}
i believe the actions should be in one container or somehow preserve the order in which they occurred.
Not doing so would result in virtually impossible modification of properties of rigidbody at runtime for example changing the kind
Changing properties of a rigidbody at runtime should be possible.
Also there should be some way of "unmaking"a rigidbody i.e removing all the components that edyn adds, because there are a lot of internal tag components that it adds behind the scenes which are pretty hard to chase.
Hi, after your recent changes i now get an assert in the broadphase destructor event without creating any physics objects.
I am basically doing attach/detach
broadphase::~broadphase() {
m_connections.clear();
// This class creates all contact manifolds thus destroy them all.
auto manifold_view = m_registry->view<contact_manifold>();
m_registry->destroy(manifold_view.begin(), manifold_view.end()); <--- asserts here
m_registry->clear<tree_resident>();
}
I am using version 1.0.0
VS2019 debug build
When the shared_components dynamic initializer ( in shared_comp.h ) executes at startup I get a stack-based buffer overrun exception. Has anyone else run into this?
Building the latest, I get the following error:
1>F:\Edyn\edyn\include\edyn/networking/util/server_snapshot_importer.hpp(306,49): error C2131: expression did not evaluate to a constant
1>F:\Edyn\edyn\include\edyn/util/tuple_util.hpp(48,72): message : failure was caused by a read of an uninitialized symbol
1>F:\Edyn\edyn\include\edyn/util/tuple_util.hpp(48,72): message : see usage of 'value'
I have format-on-save enabled on my editor, and since this project's code style differs from my default I had to disable in this project.
in the rigidbody def it says the shape is optional but it is dereferenced without checking
i believe the code shoud be as follows
matrix3x3 inertia = matrix3x3_identity; // <- notice this should be identity by default
if (def.inertia) {
inertia = *def.inertia;
} else if(def.shape) { // <- here should be a check if the optional is valid
inertia = moment_of_inertia(*def.shape, def.mass);
if (def.center_of_mass) {
// Use parallel-axis theorem to calculate moment of inertia along
// axes away from the origin.
inertia = shift_moment_of_inertia(inertia, def.mass, *def.center_of_mass);
}
}
Error log:
{PATH}...edyn/include/edyn/math/geom.hpp:178:24: error: ‘SIZE_MAX’ was not declared in this scope
178 | auto closest_idx = SIZE_MAX;
compiler: g++ 10.1.0
There is a definition for this macro on the header file of the standard library(cstdint), adding #include <cstdint>
on the file edyn/include/edyn/math/geom.hpp
works just fine for me.
But I don't know which version of the standard library you're using or if you're setting this macro to another value.
When I select double precision in cmake ( i use cmake-gui ), the build_settings.h file does not appear to be correct:
#ifndef EDYN_BUILD_SETTINGS_H
#define EDYN_BUILD_SETTINGS_H
/* #undef EDYN_DOUBLE_PRECISION */
#endif // EDYN_BUILD_SETTINGS_H
If I change it to
#define EDYN_DOUBLE_PRECISION 1
it appears to work correctly
Hi,
I'm trying to integrate Edyn into my little EnTT-based engine, but I'm having some difficulties getting Edyn to compile. I'm using Clang 14 on Linux.
When I use the instructions from the README (install EnTT with Conan, cmake, make), I get many errors. For example:
In file included from /home/dan/code/million-monkeys/engine/third-party/edyn/src/edyn/collision/broadphase_main.cpp:1:
/home/dan/code/million-monkeys/engine/third-party/edyn/include/edyn/collision/broadphase_main.hpp:18:62: error: ‘get_t’ is not a member of ‘entt’
18 | using aabb_view_t = entt::basic_view<entt::entity, entt::get_t<AABB>, entt::exclude_t<>>;
| ^~~~~
/home/dan/code/million-monkeys/engine/third-party/edyn/include/edyn/collision/broadphase_main.hpp:18:72: error: template argument 2 is invalid
18 | using aabb_view_t = entt::basic_view<entt::entity, entt::get_t<AABB>, entt::exclude_t<>>;
| ^
/home/dan/code/million-monkeys/engine/third-party/edyn/include/edyn/collision/broadphase_main.hpp:19:72: error: ‘get_t’ is not a member of ‘entt’
19 | using multi_resident_view_t = entt::basic_view<entt::entity, entt::get_t<multi_island_resident>, entt::exclude_t<>>;
| ^~~~~
/home/dan/code/million-monkeys/engine/third-party/edyn/include/edyn/collision/broadphase_main.hpp:19:99: error: template argument 2 is invalid
19 | using multi_resident_view_t = entt::basic_view<entt::entity, entt::get_t<multi_island_resident>, entt::exclude_t<>>;
| ^
/home/dan/code/million-monkeys/engine/third-party/edyn/include/edyn/collision/broadphase_main.hpp:20:67: error: ‘get_t’ is not a member of ‘entt’
20 | using tree_view_view_t = entt::basic_view<entt::entity, entt::get_t<tree_view>, entt::exclude_t<>>;
... many more ...
It looks like the EnTT version is incorrect. I checked and Conan claims to have installed v3.10.1, however, the entt/entity/fwd.hpp
file that Conan installed is different from the one in my submodule copy of EnTT (on the v3.10.1
branch): the branch contains get_t
but the one Conan installed does not. I tried replacing Conan's version with mine, but I still get the same errors. Maybe I'm doing it wrong.
I also tried just compiling the source files myself by adding them directly to my build system, however, when I do that I get a different compile error:
clang++ -O0 -g -std=c++17 -Iedyn/include -Ientt/src -c edyn/src/edyn/collision/raycast.cpp -o ../build-debug/third-party/edyn_collision__raycast.o
In file included from edyn/src/edyn/collision/raycast.cpp:13:
edyn/include/edyn/shapes/shapes.hpp:100:5: error: no matching function for call to 'visit_component'
visit_component(shapes_tuple, index.value, entity, views_tuple, visitor);
^~~~~~~~~~~~~~~
edyn/src/edyn/collision/raycast.cpp:36:9: note: in instantiation of function template specialization 'edyn::visit_shape<(lambda at edyn/src/edyn/collision/raycast.cpp:36:56)>' requested here
visit_shape(sh_idx, entity, shape_views_tuple, [&](auto &&shape) {
^
edyn/include/edyn/util/visit_component.hpp:139:6: note: candidate function template not viable: no known conversion from 'const edyn::tuple_of_shape_views_t' (aka 'const tuple<basic_view<entt::entity, type_list<edyn::sphere_shape>, type_list<>>, basic_view<entt::entity, type_list<edyn::cylinder_shape>, type_list<>>, basic_view<entt::entity, type_list<edyn::capsule_shape>, type_list<>>, basic_view<entt::entity, type_list<edyn::box_shape>, type_list<>>, basic_view<entt::entity, type_list<edyn::polyhedron_shape>, type_list<>>, basic_view<entt::entity, type_list<edyn::compound_shape>, type_list<>>, basic_view<entt::entity, type_list<edyn::plane_shape>, type_list<>>, basic_view<entt::entity, type_list<edyn::mesh_shape>, type_list<>>, basic_view<entt::entity, type_list<edyn::paged_mesh_shape>, type_list<>>>') to 'entt::registry &' (aka 'basic_registry<entt::entity> &') for 4th argument
void visit_component(std::tuple<Ts...>, IndexType index, entt::entity entity,
^
edyn/include/edyn/util/visit_component.hpp:78:6: note: candidate template ignored: deduced packs of different lengths for parameter 'Ts' (<edyn::sphere_shape, edyn::cylinder_shape, edyn::capsule_shape, edyn::box_shape, edyn::polyhedron_shape, edyn::compound_shape, edyn::plane_shape, edyn::mesh_shape, edyn::paged_mesh_shape> vs. <edyn::sphere_shape>)
void visit_component(std::tuple<Ts...>, IndexType index, entt::entity entity,
^
edyn/include/edyn/util/visit_component.hpp:67:6: note: candidate function template not viable: requires 4 arguments, but 5 were provided
void visit_component(IndexType index, entt::entity entity,
^
edyn/include/edyn/util/visit_component.hpp:129:6: note: candidate function template not viable: requires 4 arguments, but 5 were provided
void visit_component(IndexType index, entt::entity entity,
^
It seems that it can't infer the Ts
template parameters on the visit_component
function?
Any help or ideas would be appreciated!
EDIT: I'm using the latest master branch of Edyn and v3.10.1 of EnTT
I am building edyn as part of my project and am using the highest warning level and had to basically do this to silence all the warnings coming from edyn.
Maybe you should take a look at them when you have a chance.
if(MSVC)
add_compile_options(/wd4244 /wd4100 /wd4996 /wd4701 /wd4305 /wd4267 /wd4127 /wd4456 /wd4458)
endif()
add_subdirectory(edyn)
P.s sorry for the multiple issues. I am enjoying the library very much and am trying to integrate it in a game engine.
These two warnings probably don't matter
1>D:/UE500/TestEdynPhysics/Plugins/PeernetDeterministicPhysics/Source/PeernetDeterministicPhysics/Private/edyn/parallel/island_worker.cpp(59): warning C5038: data member 'edyn::island_worker::m_splitting' will be initialized after data member 'edyn::island_worker::m_state'
1>D:/UE500/TestEdynPhysics/Plugins/PeernetDeterministicPhysics/Source/PeernetDeterministicPhysics/Private/edyn/parallel/island_worker.cpp(60): warning C5038: data member 'edyn::island_worker::m_state' will be initialized after data member 'edyn::island_worker::m_bphase'
But don't understand how to fix the following error:
1>D:\UE500\TestEdynPhysics\Plugins\PeernetDeterministicPhysics\Source\PeernetDeterministicPhysics\Public\entt\entity\storage.hpp(246): error C2512: 'edyn::multi_island_resident': no appropriate default constructor available
1> D:\UE500\TestEdynPhysics\Plugins\PeernetDeterministicPhysics\Source\PeernetDeterministicPhysics\Public\entt\entity\storage.hpp(246): note: Invalid aggregate initialization
I'm getting various implicit conversion errors with clang when emplacing entities. Most of the errors are because integers literals are used to construct an edyn::scalar
member.
Still, i found it very weird when conversion warnings shouldn't be treated as errors.
Here's an example:
[15/91] Building CXX object _deps/edyn-build/CMakeFiles/Edyn.dir/src/edyn/collision/narrowphase.cpp.o
FAILED: _deps/edyn-build/CMakeFiles/Edyn.dir/src/edyn/collision/narrowphase.cpp.o
/usr/bin/clang++ -DEDYN_DISABLE_ASSERT -DENTT_DISABLE_ASSERT -I_deps/edyn-src/include -I_deps/edyn-build/include -I_deps/entt-src/src -O3 -DNDEBUG -Wall -Wno-reorder -Wno-long-long -Wimplicit-fallthrough -std=gnu++17 -MD -MT _deps/edyn-build/CMakeFiles/Edyn.dir/src/edyn/collision/narrowphase.cpp.o -MF _deps/edyn-build/CMakeFiles/Edyn.dir/src/edyn/collision/narrowphase.cpp.o.d -o _deps/edyn-build/CMakeFiles/Edyn.dir/src/edyn/collision/narrowphase.cpp.o -c _deps/edyn-src/src/edyn/collision/narrowphase.cpp
In file included from _deps/edyn-src/src/edyn/collision/narrowphase.cpp:1:
In file included from _deps/edyn-src/include/edyn/collision/narrowphase.hpp:6:
In file included from _deps/entt-src/src/entt/entity/registry.hpp:21:
In file included from _deps/entt-src/src/entt/entity/group.hpp:12:
In file included from _deps/entt-src/src/entt/entity/pool.hpp:6:
_deps/entt-src/src/entt/entity/storage.hpp:365:38: error: non-constant-expression cannot be narrowed from type 'int' to 'edyn::scalar' (aka 'float') in initializer list [-Wc++11-narrowing]
instances.push_back(Type{std::forward<Args>(args)...});
^~~~~~~~~~~~~~~~~~~~~~~~
_deps/entt-src/src/entt/entity/registry.hpp:64:46: note: in instantiation of function template specialization 'entt::storage<entt::entity, edyn::contact_point, void>::emplace<std::array<entt::entity, 2> &, const edyn::vector3 &, const edyn::vector3 &, const edyn::vector3 &, int, int, int, const float &>' requested here
storage<entity_type, Component>::emplace(entt, std::forward<Args>(args)...);
^
_deps/entt-src/src/entt/entity/storage.hpp:365:38: note: insert an explicit cast to silence this issue
instances.push_back(Type{std::forward<Args>(args)...});
^~~~~~~~~~~~~~~~~~~~~~~~
static_cast<scalar>( )
_deps/entt-src/src/entt/entity/storage.hpp:365:38: error: non-constant-expression cannot be narrowed from type 'int' to 'edyn::scalar' (aka 'float') in initializer list [-Wc++11-narrowing]
instances.push_back(Type{std::forward<Args>(args)...});
^~~~~~~~~~~~~~~~~~~~~~~~
_deps/entt-src/src/entt/entity/storage.hpp:365:38: note: insert an explicit cast to silence this issue
instances.push_back(Type{std::forward<Args>(args)...});
^~~~~~~~~~~~~~~~~~~~~~~~
static_cast<scalar>( )
_deps/entt-src/src/entt/entity/storage.hpp:365:38: error: non-constant-expression cannot be narrowed from type 'int' to 'uint32_t' (aka 'unsigned int') in initializer list [-Wc++11-narrowing]
instances.push_back(Type{std::forward<Args>(args)...});
^~~~~~~~~~~~~~~~~~~~~~~~
_deps/entt-src/src/entt/entity/storage.hpp:365:38: note: insert an explicit cast to silence this issue
instances.push_back(Type{std::forward<Args>(args)...});
^~~~~~~~~~~~~~~~~~~~~~~~
static_cast<uint32_t>( )
3 errors generated.
hi, big guy. the entt version is out of date for edyn.
I compile failed either with the latest entt, or the fork in you repository.
can you update edyn to the latest version entt ?
many thanks
While working on physics system using Edyn for my engine, I see, that deleting an entity will lead to crash after creating new entity and run simulation
I tried to write minimal reproducible example - here it is
#include <entt/entt.hpp>
#include "edyn/edyn.hpp"
#include <iostream>
int main()
{
entt::registry registry;
edyn::init();
edyn::attach(registry);
// Create floor
auto floor_def = edyn::rigidbody_def();
floor_def.kind = edyn::rigidbody_kind::rb_static;
floor_def.shape = edyn::plane_shape{ {0, 1, 0}, 0 };
auto entity = edyn::make_rigidbody(registry, floor_def);
registry.destroy(entity);
auto entity2 = edyn::make_rigidbody(registry, floor_def);
edyn::update(registry);
}
In console I see
Assertion failed: valid(entity), file C:\src\vcpkg\installed\x64-windows\include\entt/entity/registry.hpp, line 895
Callstack of the crash
ucrtbased.dll!issue_debug_notification(const wchar_t * const message) Line 28 C++
ucrtbased.dll!__acrt_report_runtime_error(const wchar_t * message) Line 154 C++
ucrtbased.dll!abort() Line 61 C++
ucrtbased.dll!common_assert_to_stderr_direct(const wchar_t * const expression, const wchar_t * const file_name, const unsigned int line_number) Line 161 C++
ucrtbased.dll!common_assert_to_stderr<wchar_t>(const wchar_t * const expression, const wchar_t * const file_name, const unsigned int line_number) Line 179 C++
ucrtbased.dll!common_assert<wchar_t>(const wchar_t * const expression, const wchar_t * const file_name, const unsigned int line_number, void * const return_address) Line 420 C++
ucrtbased.dll!_wassert(const wchar_t * expression, const wchar_t * file_name, unsigned int line_number) Line 444 C++
> ConsoleApplication4.exe!entt::basic_registry<enum entt::entity>::any_of<edyn::procedural_tag>(const entt::entity entity) Line 895 C++
ConsoleApplication4.exe!edyn::island_coordinator::init_new_nodes_and_edges() Line 167 C++
ConsoleApplication4.exe!edyn::island_coordinator::update() Line 803 C++
ConsoleApplication4.exe!edyn::update(entt::basic_registry<enum entt::entity> & registry) Line 67 C++
ConsoleApplication4.exe!main() Line 26 C++
[External Code]
Edyn is build from sources from 4e497d7 commit
The friction direction is the direction of the tangential velocity before solving the constraints. The tangential velocity changes during the constraint solver iterations.
Two possible solutions:
Proposition:
struct capsule_shape {
scalar radius;
scalar half_length;
vector3 axis;
}
I noticed by default it is x-axis only.
i have a simple scene
2 dynamic rigid bodies (spheres bodies) with gravity enabled
1 kinematic rigid body a cube stretched as a ground
i start the simulation and then like a second later i stop it and the crash occurs here
void island_manager::on_destroy_multi_island_resident(entt::registry ®istry, entt::entity entity) {
auto &resident = registry.get<const multi_island_resident>(entity);
auto island_view = registry.view<edyn::island>();
for (auto island_entity : resident.island_entities) {
auto [island] = island_view.get(island_entity);
island.nodes.erase(entity); <---------------- HERE
// Non-procedural entities do not form islands thus there's no need to
// check whether this island was split by its removal. It is necessary
// to wake the island up though, as it might cause other entities to
// start moving.
if (!m_islands_to_wake_up.contains(island_entity)) {
m_islands_to_wake_up.push(island_entity);
}
}
}
in this assert
[[nodiscard]] size_type index(const entity_type entt) const noexcept {
ENTT_ASSERT(contains(entt), "Set does not contain entity");
return static_cast<size_type>(traits_type::to_entity(sparse_ref(entt)));
}
My start / end looks like this
void physics_system::on_play_begin(rtti::context& ctx)
{
auto& ec = ctx.get<ecs>();
auto& scn = ec.get_scene();
auto& registry = *scn.registry;
auto config = edyn::init_config{};
config.execution_mode = edyn::execution_mode::sequential;
edyn::attach(registry, config);
edyn::on_contact_started(registry).connect<&sensor_contact_started>(registry);
edyn::on_contact_ended(registry).connect<&sensor_contact_ended>(registry);
registry.view<physics_component>().each(
[&](auto e, auto&& comp)
{
comp.on_phyiscs_simulation_begin();
});
}
void physics_system::on_play_end(rtti::context& ctx)
{
auto& ec = ctx.get<ecs>();
auto& registry = *ec.get_scene().registry;
registry.view<physics_component>().each(
[&](auto e, auto&& comp)
{
comp.on_phyiscs_simulation_end();
});
edyn::update(registry);
edyn::on_contact_started(registry).disconnect<&sensor_contact_started>(registry);
edyn::on_contact_ended(registry).disconnect<&sensor_contact_ended>(registry);
edyn::detach(registry);
}
I've cloned the latest edyn commit and tried building my raycasted vehicle demo. But I get a crash as soon as the ray's intersect the terrain. When I run GNU debugger on the binary, I get this error log when it crashes:
0x00005555557e7f78 in edyn::intersect_aabb(edyn::vector3 const&, edyn::vector3 const&, edyn::vector3 const&, edyn::vector3 const&) ()
I've also run valgrind, and get this error log
valg.txt.zip
Not sure when the last stable commit was, but I've found some older edyn files dating to around early march which work without that crash
edny::detach is missing removal of several systems added by the attach function
registry.ctx().erase<contact_event_emitter>();
registry.ctx().erase<registry_operation_context>();
Originally posted by tree786isback May 18, 2022
I'm using edyn in a new graphics renderer. I'm not using external systems atm. When I run edyn::update(*registry)
in the update loop, it crashes on startup:
.conan/data/entt/3.9.0/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include/entt/core/memory.hpp:102: constexpr std::size_t entt::fast_mod(std::size_t, std::size_t): Assertion `is_power_of_two(mod)' failed.
Thread 75 "binary" received signal SIGABRT, Aborted.
[Switching to Thread 0x7fffcb7f6640 (LWP 24866)]
0x00007ffff774234c in __pthread_kill_implementation () from /usr/lib/libc.so.6
Dunno what is going on. But I fear it might be some threading issues, because the framework I'm using makes heavy use of threads (I believe the update loop is being calling in a separate thread than rendering).
Any ideas?
I liked your toptal posts about programming physics. I need someone to write a physics engine. the top tal link takes me to a survey instead of the "hire xissburg" page. after the fifth question I gave up. So my issue is I can't figure out how to throw money at you and get physics in return. Please contact me back. Thank you!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.