mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-13 01:37:53 -06:00
Tech ENABLE_RAYCAST_PICKING - Rendering for rectangle selection made only inside the rectangle, on systems supporting framebuffers
Various other refactorings & fixes (cherry picked from commit prusa3d/PrusaSlicer@39b1222b22)
This commit is contained in:
parent
f0199159e7
commit
d2d77456ac
12 changed files with 289 additions and 105 deletions
|
@ -3,7 +3,6 @@
|
|||
|
||||
#include "MeshUtils.hpp"
|
||||
#include "GLModel.hpp"
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <optional>
|
||||
|
@ -13,21 +12,19 @@ namespace GUI {
|
|||
|
||||
struct Camera;
|
||||
|
||||
using PickingId = int;
|
||||
|
||||
class SceneRaycasterItem
|
||||
{
|
||||
PickingId m_id{ -1 };
|
||||
int m_id{ -1 };
|
||||
bool m_active{ true };
|
||||
const MeshRaycaster* m_raycaster;
|
||||
Transform3d m_trafo;
|
||||
|
||||
public:
|
||||
SceneRaycasterItem(PickingId id, const MeshRaycaster& raycaster, const Transform3d& trafo)
|
||||
SceneRaycasterItem(int id, const MeshRaycaster& raycaster, const Transform3d& trafo)
|
||||
: m_id(id), m_raycaster(&raycaster), m_trafo(trafo)
|
||||
{}
|
||||
|
||||
PickingId get_id() const { return m_id; }
|
||||
int get_id() const { return m_id; }
|
||||
bool is_active() const { return m_active; }
|
||||
void set_active(bool active) { m_active = active; }
|
||||
const MeshRaycaster* get_raycaster() const { return m_raycaster; }
|
||||
|
@ -46,7 +43,7 @@ public:
|
|||
Gizmo
|
||||
};
|
||||
|
||||
enum class EPickingIdBase
|
||||
enum class EIdBase
|
||||
{
|
||||
Bed = 0,
|
||||
Volume = 1000,
|
||||
|
@ -56,7 +53,7 @@ public:
|
|||
struct HitResult
|
||||
{
|
||||
EType type{ EType::None };
|
||||
PickingId raycaster_id{ -1 };
|
||||
int raycaster_id{ -1 };
|
||||
Vec3f position{ Vec3f::Zero() };
|
||||
Vec3f normal{ Vec3f::Zero() };
|
||||
|
||||
|
@ -81,11 +78,13 @@ private:
|
|||
public:
|
||||
SceneRaycaster();
|
||||
|
||||
std::shared_ptr<SceneRaycasterItem> add_raycaster(EType type, PickingId picking_id, const MeshRaycaster& raycaster, const Transform3d& trafo);
|
||||
void remove_raycasters(EType type, PickingId id);
|
||||
std::shared_ptr<SceneRaycasterItem> add_raycaster(EType type, int picking_id, const MeshRaycaster& raycaster, const Transform3d& trafo);
|
||||
void remove_raycasters(EType type, int id);
|
||||
void remove_raycasters(EType type);
|
||||
void remove_raycaster(std::shared_ptr<SceneRaycasterItem> item);
|
||||
|
||||
std::vector<std::shared_ptr<SceneRaycasterItem>>* get_raycasters(EType type);
|
||||
|
||||
void set_gizmos_on_top(bool value) { m_gizmos_on_top = value; }
|
||||
|
||||
HitResult hit(const Vec2d& mouse_pos, const Camera& camera, const ClippingPlane* clipping_plane = nullptr);
|
||||
|
@ -99,11 +98,9 @@ public:
|
|||
#endif // ENABLE_RAYCAST_PICKING_DEBUG
|
||||
|
||||
private:
|
||||
std::vector<std::shared_ptr<SceneRaycasterItem>>* get_raycasters(EType type);
|
||||
|
||||
static PickingId encode_id(EType type, PickingId id);
|
||||
static PickingId decode_id(EType type, PickingId id);
|
||||
static PickingId base_id(EType type);
|
||||
static int encode_id(EType type, int id);
|
||||
static int decode_id(EType type, int id);
|
||||
static int base_id(EType type);
|
||||
};
|
||||
|
||||
} // namespace GUI
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue