Skip to content

Conversation

@TP-David
Copy link
Contributor

@TP-David TP-David commented Oct 31, 2024

Pull Request Template

Description

Adds support for intersecting text using PolytopeIntersector or LineSegmentIntersector.

Adds computeBillboardMatrix method.

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Tested in vsgtext using the following eventHandler:

    class IntersectionHandler : public vsg::Inherit<vsg::Visitor, IntersectionHandler>
    {
    public:
        vsg::ref_ptr<vsg::Camera> camera;
        vsg::ref_ptr<vsg::Group> scenegraph;
        IntersectionHandler(
            vsg::ref_ptr<vsg::Camera> in_camera,
            vsg::ref_ptr<vsg::Group> in_scenegraph) :
            camera(in_camera),
            scenegraph(in_scenegraph)
        {
        }

        void apply(vsg::ButtonPressEvent& pointerEvent) override
        {
#if 1
            double size = 5.0;
            double xMin = static_cast<double>(pointerEvent.x) - size;
            double xMax = static_cast<double>(pointerEvent.x) + size;
            double yMin = static_cast<double>(pointerEvent.y) - size;
            double yMax = static_cast<double>(pointerEvent.y) + size;

            auto intersector = vsg::PolytopeIntersector::create(*camera, xMin, yMin, xMax, yMax);
#else
            auto intersector = vsg::LineSegmentIntersector::create(*camera, pointerEvent.x, pointerEvent.y);
#endif
            scenegraph->accept(*intersector);

            std::cout << "Hits: " << intersector->intersections.size() << std::endl;
        }

    };
    viewer->addEventHandler(IntersectionHandler::create(camera, scenegraph));

It prints 0 when clicking outside of text, and non-zero when clicking text (billboarded, CPU/GPU, different layouts).

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@TP-David TP-David changed the title Intersect text technique Intersect text with PolytopeIntersector or LineSegmentIntersector Oct 31, 2024
@robertosfield robertosfield merged commit 2a0ff8c into vsg-dev:master Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants