#include "particles.h"
#include "porting.h"
#include "profiler.h"
-#include "quicktune_shortcutter.h"
#include "raycast.h"
#include "server.h"
#include "settings.h"
#include "util/basic_macros.h"
#include "util/directiontables.h"
#include "util/pointedthing.h"
+#include "util/quicktune_shortcutter.h"
#include "irrlicht_changes/static_text.h"
#include "version.h"
#include "script/scripting_client.h"
CachedPixelShaderSetting<float, 3> m_eye_position_pixel;
CachedVertexShaderSetting<float, 3> m_eye_position_vertex;
CachedPixelShaderSetting<float, 3> m_minimap_yaw;
+ CachedPixelShaderSetting<float, 3> m_camera_offset_pixel;
+ CachedPixelShaderSetting<float, 3> m_camera_offset_vertex;
CachedPixelShaderSetting<SamplerLayer_t> m_base_texture;
CachedPixelShaderSetting<SamplerLayer_t> m_normal_texture;
CachedPixelShaderSetting<SamplerLayer_t> m_texture_flags;
m_eye_position_pixel("eyePosition"),
m_eye_position_vertex("eyePosition"),
m_minimap_yaw("yawVec"),
+ m_camera_offset_pixel("cameraOffset"),
+ m_camera_offset_vertex("cameraOffset"),
m_base_texture("baseTexture"),
m_normal_texture("normalTexture"),
m_texture_flags("textureFlags"),
sunlight.b };
m_day_light.set(dnc, services);
- u32 animation_timer = porting::getTimeMs() % 100000;
+ u32 animation_timer = porting::getTimeMs() % 1000000;
float animation_timer_f = (float)animation_timer / 100000.f;
m_animation_timer_vertex.set(&animation_timer_f, services);
m_animation_timer_pixel.set(&animation_timer_f, services);
m_minimap_yaw.set(minimap_yaw_array, services);
}
+ float camera_offset_array[3];
+ v3f offset = intToFloat(m_client->getCamera()->getOffset(), BS);
+#if (IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR < 8)
+ camera_offset_array[0] = offset.X;
+ camera_offset_array[1] = offset.Y;
+ camera_offset_array[2] = offset.Z;
+#else
+ offset.getAs3Values(camera_offset_array);
+#endif
+ m_camera_offset_pixel.set(camera_offset_array, services);
+ m_camera_offset_vertex.set(camera_offset_array, services);
+
SamplerLayer_t base_tex = 0,
normal_tex = 1,
flags_tex = 2;
void updateChat(f32 dtime, const v2u32 &screensize);
bool nodePlacement(const ItemDefinition &selected_def, const ItemStack &selected_item,
- const v3s16 &nodepos, const v3s16 &neighbourpos, const PointedThing &pointed);
+ const v3s16 &nodepos, const v3s16 &neighbourpos, const PointedThing &pointed,
+ const NodeMetadata *meta);
static const ClientEventHandler clientEventHandler[CLIENTEVENT_MAX];
InputHandler *input = nullptr;
void Game::checkZoomEnabled()
{
LocalPlayer *player = client->getEnv().getLocalPlayer();
- if (player->getZoomFOV() < 0.001f)
+ if (player->getZoomFOV() < 0.001f || player->getFov().fov > 0.0f)
m_game_ui->showTranslatedStatusText("Zoom currently disabled by game or mod");
}
runData.repeat_rightclick_timer = 0;
infostream << "Ground right-clicked" << std::endl;
- if (meta && !meta->getString("formspec").empty() && !random_input
- && !isKeyDown(KeyType::SNEAK)) {
- // Report right click to server
- if (nodedef_manager->get(map.getNode(nodepos)).rightclickable) {
- client->interact(INTERACT_PLACE, pointed);
- }
-
- infostream << "Launching custom inventory view" << std::endl;
-
- InventoryLocation inventoryloc;
- inventoryloc.setNodeMeta(nodepos);
-
- NodeMetadataFormSource *fs_src = new NodeMetadataFormSource(
- &client->getEnv().getClientMap(), nodepos);
- TextDest *txt_dst = new TextDestNodeMetadata(nodepos, client);
-
- auto *&formspec = m_game_ui->updateFormspec("");
- GUIFormSpecMenu::create(formspec, client, &input->joystick, fs_src,
- txt_dst, client->getFormspecPrepend());
-
- formspec->setFormSpec(meta->getString("formspec"), inventoryloc);
- } else {
- // Report right click to server
-
- camera->setDigging(1); // right click animation (always shown for feedback)
+ camera->setDigging(1); // right click animation (always shown for feedback)
- soundmaker->m_player_rightpunch_sound = SimpleSoundSpec();
+ soundmaker->m_player_rightpunch_sound = SimpleSoundSpec();
- // If the wielded item has node placement prediction,
- // make that happen
- // And also set the sound and send the interact
- auto &def = selected_item.getDefinition(itemdef_manager);
- bool placed = nodePlacement(def, selected_item, nodepos, neighbourpos,
- pointed);
+ // If the wielded item has node placement prediction,
+ // make that happen
+ // And also set the sound and send the interact
+ // But first check for meta formspec and rightclickable
+ auto &def = selected_item.getDefinition(itemdef_manager);
+ bool placed = nodePlacement(def, selected_item, nodepos, neighbourpos,
+ pointed, meta);
- if (placed && client->modsLoaded())
- client->getScript()->on_placenode(pointed, def);
- }
+ if (placed && client->modsLoaded())
+ client->getScript()->on_placenode(pointed, def);
}
}
bool Game::nodePlacement(const ItemDefinition &selected_def,
const ItemStack &selected_item, const v3s16 &nodepos, const v3s16 &neighbourpos,
- const PointedThing &pointed)
+ const PointedThing &pointed, const NodeMetadata *meta)
{
std::string prediction = selected_def.node_placement_prediction;
const NodeDefManager *nodedef = client->ndef();
return false;
}
+ // formspec in meta
+ if (meta && !meta->getString("formspec").empty() && !random_input
+ && !isKeyDown(KeyType::SNEAK)) {
+ // on_rightclick callbacks are called anyway
+ if (nodedef_manager->get(map.getNode(nodepos)).rightclickable)
+ client->interact(INTERACT_PLACE, pointed);
+
+ infostream << "Launching custom inventory view" << std::endl;
+
+ InventoryLocation inventoryloc;
+ inventoryloc.setNodeMeta(nodepos);
+
+ NodeMetadataFormSource *fs_src = new NodeMetadataFormSource(
+ &client->getEnv().getClientMap(), nodepos);
+ TextDest *txt_dst = new TextDestNodeMetadata(nodepos, client);
+
+ auto *&formspec = m_game_ui->updateFormspec("");
+ GUIFormSpecMenu::create(formspec, client, &input->joystick, fs_src,
+ txt_dst, client->getFormspecPrepend());
+
+ formspec->setFormSpec(meta->getString("formspec"), inventoryloc);
+ return false;
+ }
+
+ // on_rightclick callback
if (prediction.empty() || (nodedef->get(node).rightclickable &&
!isKeyDown(KeyType::SNEAK))) {
// Report to server