mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-05 19:31:04 +00:00
Tool specific pointing and blocking pointable type (#13992)
This commit is contained in:
parent
fb461d21a5
commit
5958714309
39 changed files with 676 additions and 67 deletions
|
@ -489,7 +489,8 @@ ClientEnvEvent ClientEnvironment::getClientEnvEvent()
|
|||
|
||||
void ClientEnvironment::getSelectedActiveObjects(
|
||||
const core::line3d<f32> &shootline_on_map,
|
||||
std::vector<PointedThing> &objects)
|
||||
std::vector<PointedThing> &objects,
|
||||
const std::optional<Pointabilities> &pointabilities)
|
||||
{
|
||||
auto allObjects = m_ao_manager.getActiveSelectableObjects(shootline_on_map);
|
||||
const v3f line_vector = shootline_on_map.getVector();
|
||||
|
@ -516,9 +517,23 @@ void ClientEnvironment::getSelectedActiveObjects(
|
|||
current_raw_normal = current_normal;
|
||||
}
|
||||
if (collision) {
|
||||
current_intersection += obj->getPosition();
|
||||
objects.emplace_back(obj->getId(), current_intersection, current_normal, current_raw_normal,
|
||||
(current_intersection - shootline_on_map.start).getLengthSQ());
|
||||
PointabilityType pointable;
|
||||
if (pointabilities) {
|
||||
if (gcao->isPlayer()) {
|
||||
pointable = pointabilities->matchPlayer(gcao->getGroups()).value_or(
|
||||
gcao->getProperties().pointable);
|
||||
} else {
|
||||
pointable = pointabilities->matchObject(gcao->getName(),
|
||||
gcao->getGroups()).value_or(gcao->getProperties().pointable);
|
||||
}
|
||||
} else {
|
||||
pointable = gcao->getProperties().pointable;
|
||||
}
|
||||
if (pointable != PointabilityType::POINTABLE_NOT) {
|
||||
current_intersection += obj->getPosition();
|
||||
objects.emplace_back(obj->getId(), current_intersection, current_normal, current_raw_normal,
|
||||
(current_intersection - shootline_on_map.start).getLengthSQ(), pointable);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -131,7 +131,8 @@ public:
|
|||
|
||||
virtual void getSelectedActiveObjects(
|
||||
const core::line3d<f32> &shootline_on_map,
|
||||
std::vector<PointedThing> &objects
|
||||
std::vector<PointedThing> &objects,
|
||||
const std::optional<Pointabilities> &pointabilities
|
||||
);
|
||||
|
||||
const std::set<std::string> &getPlayerNames() { return m_player_names; }
|
||||
|
|
|
@ -411,8 +411,7 @@ GenericCAO::~GenericCAO()
|
|||
|
||||
bool GenericCAO::getSelectionBox(aabb3f *toset) const
|
||||
{
|
||||
if (!m_prop.is_visible || !m_is_visible || m_is_local_player
|
||||
|| !m_prop.pointable) {
|
||||
if (!m_prop.is_visible || !m_is_visible || m_is_local_player) {
|
||||
return false;
|
||||
}
|
||||
*toset = m_selection_box;
|
||||
|
|
|
@ -174,6 +174,8 @@ public:
|
|||
|
||||
inline const ObjectProperties &getProperties() const { return m_prop; }
|
||||
|
||||
inline const std::string &getName() const { return m_name; }
|
||||
|
||||
scene::ISceneNode *getSceneNode() const override;
|
||||
|
||||
scene::IAnimatedMeshSceneNode *getAnimatedMeshSceneNode() const override;
|
||||
|
@ -208,6 +210,11 @@ public:
|
|||
return m_is_local_player;
|
||||
}
|
||||
|
||||
inline bool isPlayer() const
|
||||
{
|
||||
return m_is_player;
|
||||
}
|
||||
|
||||
inline bool isVisible() const
|
||||
{
|
||||
return m_is_visible;
|
||||
|
|
|
@ -841,6 +841,7 @@ protected:
|
|||
* the camera position. This also gives the maximal distance
|
||||
* of the search.
|
||||
* @param[in] liquids_pointable if false, liquids are ignored
|
||||
* @param[in] pointabilities item specific pointable overriding
|
||||
* @param[in] look_for_object if false, objects are ignored
|
||||
* @param[in] camera_offset offset of the camera
|
||||
* @param[out] selected_object the selected object or
|
||||
|
@ -848,6 +849,7 @@ protected:
|
|||
*/
|
||||
PointedThing updatePointedThing(
|
||||
const core::line3d<f32> &shootline, bool liquids_pointable,
|
||||
const std::optional<Pointabilities> &pointabilities,
|
||||
bool look_for_object, const v3s16 &camera_offset);
|
||||
void handlePointingAtNothing(const ItemStack &playerItem);
|
||||
void handlePointingAtNode(const PointedThing &pointed,
|
||||
|
@ -3343,6 +3345,7 @@ void Game::processPlayerInteraction(f32 dtime, bool show_hud)
|
|||
|
||||
PointedThing pointed = updatePointedThing(shootline,
|
||||
selected_def.liquids_pointable,
|
||||
selected_def.pointabilities,
|
||||
!runData.btn_down_for_dig,
|
||||
camera_offset);
|
||||
|
||||
|
@ -3454,6 +3457,7 @@ void Game::processPlayerInteraction(f32 dtime, bool show_hud)
|
|||
PointedThing Game::updatePointedThing(
|
||||
const core::line3d<f32> &shootline,
|
||||
bool liquids_pointable,
|
||||
const std::optional<Pointabilities> &pointabilities,
|
||||
bool look_for_object,
|
||||
const v3s16 &camera_offset)
|
||||
{
|
||||
|
@ -3470,7 +3474,7 @@ PointedThing Game::updatePointedThing(
|
|||
runData.selected_object = NULL;
|
||||
hud->pointing_at_object = false;
|
||||
|
||||
RaycastState s(shootline, look_for_object, liquids_pointable);
|
||||
RaycastState s(shootline, look_for_object, liquids_pointable, pointabilities);
|
||||
PointedThing result;
|
||||
env.continueRaycast(&s, &result);
|
||||
if (result.type == POINTEDTHING_OBJECT) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue