Skip to content

Commit

Permalink
fix(lua): fix ents.BhvComponent.HitInfo.entity not using correct lua …
Browse files Browse the repository at this point in the history
…object
  • Loading branch information
Silverlan committed Feb 25, 2023
1 parent 6ddb2c6 commit 1ae8906
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions core/shared/src/lua/classes/entity_components.cpp
Expand Up @@ -782,6 +782,15 @@ void pragma::lua::register_entity_component_classes(luabind::module_ &mod)
auto defBvhHitInfo = luabind::class_<pragma::BvhHitInfo>("HitInfo");
defBvhHitInfo.def_readonly("mesh", &pragma::BvhHitInfo::mesh);
defBvhHitInfo.def_readonly("entity", &pragma::BvhHitInfo::entity);
defBvhHitInfo.property(
"entity",
+[](lua_State *l, pragma::BvhHitInfo &info) {
if(info.entity.expired())
Lua::PushNil(l);
else
info.entity->PushLuaObject(l);
},
+[](pragma::BvhHitInfo &info, BaseEntity *ent) { info.entity = ent ? ent->GetHandle() : EntityHandle {}; });
defBvhHitInfo.def_readonly("primitiveIndex", &pragma::BvhHitInfo::primitiveIndex);
defBvhHitInfo.def_readonly("distance", &pragma::BvhHitInfo::distance);
defBvhHitInfo.def_readonly("t", &pragma::BvhHitInfo::t);
Expand Down

0 comments on commit 1ae8906

Please sign in to comment.