Merge pull request #662 from MihailRis/core-cameras-and-mouse-delta
Core cameras and mouse delta things
This commit is contained in:
commit
497160a5b9
@ -48,6 +48,12 @@ input.get_mouse_pos() --> {int, int}
|
|||||||
|
|
||||||
Returns cursor screen position.
|
Returns cursor screen position.
|
||||||
|
|
||||||
|
```lua
|
||||||
|
input.get_mouse_delta() --> {int, int}
|
||||||
|
```
|
||||||
|
|
||||||
|
Returns cursor movement delta.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
input.get_bindings() --> strings array
|
input.get_bindings() --> strings array
|
||||||
```
|
```
|
||||||
|
|||||||
@ -48,6 +48,12 @@ input.get_mouse_pos() --> {int, int}
|
|||||||
|
|
||||||
Возвращает позицию курсора на экране.
|
Возвращает позицию курсора на экране.
|
||||||
|
|
||||||
|
```lua
|
||||||
|
input.get_mouse_delta() --> {int, int}
|
||||||
|
```
|
||||||
|
|
||||||
|
Возращает дельту позиции курсора.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
input.get_bindings() --> массив строк
|
input.get_bindings() --> массив строк
|
||||||
```
|
```
|
||||||
|
|||||||
@ -49,8 +49,7 @@ LevelFrontend::LevelFrontend(
|
|||||||
auto sound = rassets.get<audio::Sound>(material->stepsSound);
|
auto sound = rassets.get<audio::Sound>(material->stepsSound);
|
||||||
glm::vec3 pos {};
|
glm::vec3 pos {};
|
||||||
auto soundsCamera = currentPlayer->currentCamera.get();
|
auto soundsCamera = currentPlayer->currentCamera.get();
|
||||||
if (soundsCamera == currentPlayer->spCamera.get() ||
|
if (currentPlayer->isCurrentCameraBuiltin()) {
|
||||||
soundsCamera == currentPlayer->tpCamera.get()) {
|
|
||||||
soundsCamera = currentPlayer->fpCamera.get();
|
soundsCamera = currentPlayer->fpCamera.get();
|
||||||
}
|
}
|
||||||
bool relative = player == currentPlayer &&
|
bool relative = player == currentPlayer &&
|
||||||
|
|||||||
@ -207,8 +207,7 @@ void CameraControl::update(
|
|||||||
tpCamera->front = camera->front;
|
tpCamera->front = camera->front;
|
||||||
tpCamera->right = camera->right;
|
tpCamera->right = camera->right;
|
||||||
}
|
}
|
||||||
if (player.currentCamera == spCamera || player.currentCamera == tpCamera ||
|
if (player.isCurrentCameraBuiltin()) {
|
||||||
player.currentCamera == camera) {
|
|
||||||
player.currentCamera->setFov(glm::radians(settings.fov.get()));
|
player.currentCamera->setFov(glm::radians(settings.fov.get()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -280,7 +279,7 @@ void PlayerController::postUpdate(
|
|||||||
updateFootsteps(delta);
|
updateFootsteps(delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pause && input) {
|
if (!pause && input && player.isCurrentCameraBuiltin()) {
|
||||||
camControl.updateMouse(this->input, windowHeight);
|
camControl.updateMouse(this->input, windowHeight);
|
||||||
}
|
}
|
||||||
camControl.refreshRotation();
|
camControl.refreshRotation();
|
||||||
|
|||||||
@ -82,6 +82,12 @@ static int l_get_mouse_pos(lua::State* L) {
|
|||||||
return lua::pushvec2(L, engine->getInput().getCursor().pos);
|
return lua::pushvec2(L, engine->getInput().getCursor().pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int l_get_mouse_delta(lua::State* L) {
|
||||||
|
if (engine->isHeadless())
|
||||||
|
return 0;
|
||||||
|
return lua::pushvec2(L, engine->getInput().getCursor().delta);
|
||||||
|
}
|
||||||
|
|
||||||
static int l_get_bindings(lua::State* L) {
|
static int l_get_bindings(lua::State* L) {
|
||||||
if (engine->isHeadless())
|
if (engine->isHeadless())
|
||||||
return 0;
|
return 0;
|
||||||
@ -171,6 +177,7 @@ const luaL_Reg inputlib[] = {
|
|||||||
{"mousecode", lua::wrap<l_mousecode>},
|
{"mousecode", lua::wrap<l_mousecode>},
|
||||||
{"add_callback", lua::wrap<l_add_callback>},
|
{"add_callback", lua::wrap<l_add_callback>},
|
||||||
{"get_mouse_pos", lua::wrap<l_get_mouse_pos>},
|
{"get_mouse_pos", lua::wrap<l_get_mouse_pos>},
|
||||||
|
{"get_mouse_delta", lua::wrap<l_get_mouse_delta>},
|
||||||
{"get_bindings", lua::wrap<l_get_bindings>},
|
{"get_bindings", lua::wrap<l_get_bindings>},
|
||||||
{"get_binding_text", lua::wrap<l_get_binding_text>},
|
{"get_binding_text", lua::wrap<l_get_binding_text>},
|
||||||
{"is_active", lua::wrap<l_is_active>},
|
{"is_active", lua::wrap<l_is_active>},
|
||||||
|
|||||||
@ -84,6 +84,12 @@ Hitbox* Player::getHitbox() {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Player::isCurrentCameraBuiltin() const {
|
||||||
|
return currentCamera.get() == fpCamera.get() ||
|
||||||
|
currentCamera.get() == spCamera.get() ||
|
||||||
|
currentCamera.get() == tpCamera.get();
|
||||||
|
}
|
||||||
|
|
||||||
void Player::updateSelectedEntity() {
|
void Player::updateSelectedEntity() {
|
||||||
selectedEid = selection.entity;
|
selectedEid = selection.entity;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -131,6 +131,8 @@ public:
|
|||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isCurrentCameraBuiltin() const;
|
||||||
|
|
||||||
Hitbox* getHitbox();
|
Hitbox* getHitbox();
|
||||||
|
|
||||||
void setSpawnPoint(glm::vec3 point);
|
void setSpawnPoint(glm::vec3 point);
|
||||||
@ -147,4 +149,8 @@ public:
|
|||||||
inline u64id_t getId() const {
|
inline u64id_t getId() const {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Level& getLevel() const {
|
||||||
|
return level;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user