Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3601406
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:37:05+00:00 2026-05-18T20:37:05+00:00

I’m making a paint program to paint on 3D meshes using a circular brush.

  • 0

I’m making a paint program to paint on 3D meshes using a circular brush. Because of the way I’m specifying the area to change to the brush color, I believe that the MouseMove Events are firing off quicker than the program can finish drawing, thus instead of just changing a circle to a different color, it’s overflowing and ends up painting the entire mesh.

The following gets called on mouseMove:

void Mesh::setCircle(Face *face, int radius, Color color) {
    for (unsigned int i = 0; i < mouseOvers.size(); i++)
        faceList[mouseOvers[i]].mouseOver = false;
    mouseOvers.clear();

    ...
    // finds the faces on the mesh around the centerIndex on the circle (just the outline of the circle)
    // calls face->mouseOver = true; for each of those faces
    // adds the indices of the faces to mouseOvers
}

The above is used to give the outline of the brush on the mesh so that users know what they’re about to paint. When the user clicks on the mouse button, the following is called:

void Mesh::getAdjacent(Face *face, vector<Face *> &adjacent) {
    for (unsigned int i = 0; i < mouseOvers.size(); i++)
        adjacent.push_back(&faceList[mouseOvers[i]]);

    int currentUp = face->listIndex;
    int currentDown = currentUp;
    helperGetAdjacent(currentUp, adjacent);

    while (!faceList[currentUp].mouseOver) {
        //up
        if (currentUp >= numCols) {
            currentUp -= numCols;
            helperGetAdjacent(currentUp, adjacent);
        }
        else
            break;
    }
    while (!faceList[currentDown].mouseOver) {
        //down
        if (currentDown < numCols * (numRows-1)) {
            currentDown += numCols;
            helperGetAdjacent(currentDown, adjacent);
        }
        else
            break;
    }
}

void Mesh::helperGetAdjacent(int trunk, vector<Face *> &adjacent) {
    int currentRight = trunk;
    int currentLeft = trunk;

    adjacent.push_back(&faceList[trunk]);

    while (!faceList[currentRight].mouseOver) {
        // check right
        if (currentRight % numCols != numCols - 1) {
            adjacent.push_back(&faceList[currentRight + 1]);
            currentRight++;
        }
        else
            break;
    }
    while (!faceList[currentLeft].mouseOver) {
        //check left
        if (currentLeft % numCols != 0) {
            adjacent.push_back(&faceList[currentLeft - 1]);
            currentLeft--;
        }    
        else
            break;
    }
}

Short summary of the code above, I’m using the mouseOver property in the faces to determine when to stop adding faces to adjacent (which is returned and colored in another function).

Now, this works when the user just clicks on the mouse. When the user drags it while holding it down, I just call that getAdjacent function again. If the user moves the mouse slow enough, the expected behaviour (the faces get colored by the mouse like a brush), but if the user drags faster (and this isn’t really fast), the entire mesh will be colored.

My suspicion is that the mousemove event is being called in a different thread, causing the setCircle function to be called before the getAdjacent function has finished. The mouseOver member in Face changes to false and the getAdjacent doesn’t stop at the right place.

How can I remedy this problem?

Thanks very much!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T20:37:05+00:00Added an answer on May 18, 2026 at 8:37 pm

    Your suspicion is incorrect… Qt only uses a single thread (the main thread) for its GUI stuff. So your problem is somewhere else. It could be a bug in your code (I won’t try to debug the logic here, since I don’t think I could do a decent job of it), or it could be that Qt is combining MouseMove events when possible (to avoid an ever-lengthening queue of events if the callbacks are slow in returning), which might be not what your code expects.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have a text area in my form which accepts all possible characters from
I have thousands of HTML files to process using Groovy/Java and I need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.