mirror of
https://github.com/harfang3d/harfang3d.git
synced 2024-06-15 19:52:14 +00:00
Tidying
This commit is contained in:
parent
4b6990aae0
commit
8eb2091881
|
@ -321,9 +321,9 @@ void Scene::SetCameraZNear(ComponentRef ref, float v) {
|
|||
warn("Invalid camera component");
|
||||
}
|
||||
|
||||
void Scene::SetCameraCenterOffset(ComponentRef ref, const Vec2 & offset) {
|
||||
void Scene::SetCameraCenterOffset(ComponentRef ref, const Vec2 & v) {
|
||||
if (auto *c = GetComponent_(cameras, ref))
|
||||
c->center_offset = offset;
|
||||
c->center_offset = v;
|
||||
else
|
||||
warn("Invalid camera component");
|
||||
}
|
||||
|
@ -503,13 +503,21 @@ void Camera::SetSize(float v) {
|
|||
warn("Orphaned camera component");
|
||||
}
|
||||
|
||||
void Camera::SetCenterOffset(const Vec2 & offset) {
|
||||
void Camera::SetCenterOffset(const Vec2 & v) {
|
||||
if (scene_ref && scene_ref->scene)
|
||||
scene_ref->scene->SetCameraCenterOffset(ref, offset);
|
||||
scene_ref->scene->SetCameraCenterOffset(ref, v);
|
||||
else
|
||||
warn("Orphaned camera component");
|
||||
}
|
||||
|
||||
Vec2 Camera::GetCenterOffset() const {
|
||||
if (scene_ref && scene_ref->scene)
|
||||
return scene_ref->scene->GetCameraCenterOffset(ref);
|
||||
|
||||
warn("Orphaned camera component");
|
||||
return {};
|
||||
}
|
||||
|
||||
Camera Scene::CreateCamera(const float znear, const float zfar, const float fov) { return {scene_ref, cameras.add_ref({{znear, zfar}, fov, false})}; }
|
||||
|
||||
Camera Scene::CreateOrthographicCamera(const float znear, const float zfar, const float size) {
|
||||
|
|
|
@ -92,7 +92,7 @@ struct Camera { // 16B on 64 bit
|
|||
void SetIsOrthographic(bool v);
|
||||
float GetSize() const;
|
||||
void SetSize(float v);
|
||||
void SetCenterOffset(const Vec2 & offset);
|
||||
void SetCenterOffset(const Vec2 & v);
|
||||
Vec2 GetCenterOffset() const;
|
||||
|
||||
intrusive_shared_ptr_st<SceneRef> scene_ref;
|
||||
|
|
|
@ -245,7 +245,7 @@ ViewState Scene::ComputeCameraViewState(NodeRef ref, const Vec2 &aspect_ratio) c
|
|||
if (auto cam_ = GetComponent_(cameras, node_->components[NCI_Camera])) {
|
||||
const auto &world = transform_worlds[trs_ref.idx];
|
||||
return cam_->ortho ? ComputeOrthographicViewState(world, cam_->size, cam_->zrange.znear, cam_->zrange.zfar, aspect_ratio)
|
||||
: ComputePerspectiveViewState(world, cam_->fov, cam_->zrange.znear, cam_->zrange.zfar, aspect_ratio, cam_->center_offset);
|
||||
: ComputePerspectiveViewState(world, cam_->fov, cam_->zrange.znear, cam_->zrange.zfar, aspect_ratio, Vec2::Zero, cam_->center_offset);
|
||||
} else {
|
||||
warn("Invalid node camera");
|
||||
}
|
||||
|
|
|
@ -308,7 +308,7 @@ public:
|
|||
void SetCameraSize(ComponentRef ref, float v);
|
||||
bool GetCameraIsOrthographic(ComponentRef ref) const;
|
||||
void SetCameraIsOrthographic(ComponentRef ref, const bool &v);
|
||||
void SetCameraCenterOffset(ComponentRef ref, const Vec2 & offset);
|
||||
void SetCameraCenterOffset(ComponentRef ref, const Vec2 & v);
|
||||
Vec2 GetCameraCenterOffset(ComponentRef ref) const;
|
||||
|
||||
Camera CreateCamera(float znear, float zfar, float fov = Deg(45.f));
|
||||
|
|
Loading…
Reference in New Issue
Block a user