|
38 | 38 | #include "xrServer_Objects_ALife_Monsters.h" |
39 | 39 | #include "xrScriptEngine/ScriptExporter.hpp" |
40 | 40 | #include "HUDManager.h" |
| 41 | +#include "raypick.h" |
| 42 | +#include "xrCDB/xr_collide_defs.h" |
41 | 43 |
|
42 | 44 | using namespace luabind; |
43 | 45 | using namespace luabind::policy; |
@@ -649,6 +651,27 @@ void set_active_cam(u8 mode) |
649 | 651 | #endif |
650 | 652 | //-Alundaio |
651 | 653 |
|
| 654 | +// KD: raypick |
| 655 | +bool ray_pick(const Fvector& start, const Fvector& dir, float range, |
| 656 | + collide::rq_target tgt, script_rq_result& script_R, |
| 657 | + CScriptGameObject* ignore_object) |
| 658 | +{ |
| 659 | + collide::rq_result R; |
| 660 | + IGameObject* ignore = nullptr; |
| 661 | + if (ignore_object) |
| 662 | + ignore = smart_cast<IGameObject*>(&(ignore_object->object())); |
| 663 | + if (Level().ObjectSpace.RayPick(start, dir, range, tgt, R, ignore)) |
| 664 | + { |
| 665 | + script_R.set(R); |
| 666 | + return true; |
| 667 | + } |
| 668 | + return false; |
| 669 | +} |
| 670 | + |
| 671 | +// XXX nitrocaster: one can export enum like class, without defining dummy type |
| 672 | +template<typename T> |
| 673 | +struct EnumCallbackType {}; |
| 674 | + |
652 | 675 | IC static void CLevel_Export(lua_State* luaState) |
653 | 676 | { |
654 | 677 | class_<CEnvDescriptor>("CEnvDescriptor") |
@@ -731,11 +754,45 @@ IC static void CLevel_Export(lua_State* luaState) |
731 | 754 |
|
732 | 755 | def("vertex_id", &vertex_id), |
733 | 756 |
|
734 | | - def("game_id", &GameID)], |
| 757 | + def("game_id", &GameID), |
| 758 | + def("ray_pick", &ray_pick)], |
735 | 759 |
|
736 | 760 | module(luaState, "actor_stats")[def("add_points", &add_actor_points), |
737 | 761 | def("add_points_str", &add_actor_points_str), def("get_points", &get_actor_points)]; |
738 | 762 |
|
| 763 | + module(luaState) |
| 764 | + [ |
| 765 | + class_<CRayPick>("ray_pick") |
| 766 | + .def(constructor<>()) |
| 767 | + .def(constructor<Fvector&, Fvector&, float, collide::rq_target, CScriptGameObject*>()) |
| 768 | + .def("set_position", &CRayPick::set_position) |
| 769 | + .def("set_direction", &CRayPick::set_direction) |
| 770 | + .def("set_range", &CRayPick::set_range) |
| 771 | + .def("set_flags", &CRayPick::set_flags) |
| 772 | + .def("set_ignore_object", &CRayPick::set_ignore_object) |
| 773 | + .def("query", &CRayPick::query) |
| 774 | + .def("get_result", &CRayPick::get_result) |
| 775 | + .def("get_object", &CRayPick::get_object) |
| 776 | + .def("get_distance", &CRayPick::get_distance) |
| 777 | + .def("get_element", &CRayPick::get_element), |
| 778 | + class_<script_rq_result>("rq_result") |
| 779 | + .def_readonly("object", &script_rq_result::O) |
| 780 | + .def_readonly("range", &script_rq_result::range) |
| 781 | + .def_readonly("element", &script_rq_result::element) |
| 782 | + .def(constructor<>()), |
| 783 | + class_<EnumCallbackType<collide::rq_target>>("rq_target") |
| 784 | + .enum_("targets") |
| 785 | + [ |
| 786 | + value("rqtNone", int(collide::rqtNone)), |
| 787 | + value("rqtObject", int(collide::rqtObject)), |
| 788 | + value("rqtStatic", int(collide::rqtStatic)), |
| 789 | + value("rqtShape", int(collide::rqtShape)), |
| 790 | + value("rqtObstacle", int(collide::rqtObstacle)), |
| 791 | + value("rqtBoth", int(collide::rqtBoth)), |
| 792 | + value("rqtDyn", int(collide::rqtDyn)) |
| 793 | + ] |
| 794 | + ]; |
| 795 | + |
739 | 796 | module(luaState)[def("command_line", &command_line), def("IsGameTypeSingle", &IsGameTypeSingle), |
740 | 797 | def("IsDynamicMusic", &IsDynamicMusic), def("render_get_dx_level", &render_get_dx_level), |
741 | 798 | def("IsImportantSave", &IsImportantSave)]; |
|
0 commit comments