Jump to content

Cost of Drawing / Reducing paint refresh rate


Solzhenitsyn

Recommended Posts

Hi,

 

I am drawing wireframes of relevant entities while I am debugging, but on my toaster it is causing a lot of lag. Is there any way to reduce the refresh rate of onPaint, or a cheaper way of drawing wireframes?

 

 

Drawing tiny rectangles... 

 

feels.png

 

Ran into a similar problem with my agility script... With small obstacles that didn't have a lot of area on the screen, it didn't lag at all, but once I got to big gaps that had a lot of area, i basically completely froze.

 

i'd offer a possible recommendation (idk the kind of precision you need) of just highlighting the tiles upon which the object is located, something like this:

g.fill(GraphicUtilities.getModelArea(getBot(), ent.getGridX(), ent.getGridY(), ent.getZ(), ent.getModel()));

given an entity 'ent' and a graphics2d g

 

this is probably the simplest solution that i could give on the fly

Edited by Imateamcape
Link to comment
Share on other sites

Ran into a similar problem with my agility script... With small obstacles that didn't have a lot of area on the screen, it didn't lag at all, but once I got to big gaps that had a lot of area, i basically completely froze.

 

i'd offer a possible recommendation (idk the kind of precision you need) of just highlighting the tiles upon which the object is located, something like this:

g.fill(GraphicUtilities.getModelArea(getBot(), ent.getGridX(), ent.getGridY(), ent.getZ(), ent.getModel()));

given an entity 'ent' and a graphics2d g

 

this is probably the simplest solution that i could give on the fly

 

 

This seems a bit more straight forward but same outcome :)

 

g.drawPolygon(rs2object.getPosition().getPolygon(getBot()));

  • Like 1
Link to comment
Share on other sites

The refresh rate is what's causing the "lag". Typically injection based bots (OSBot?) will hook into the relevant graphics methods to paint over the game buffer before it's drawn to the canvas.

 

You're going to want to post your code so we can see if there's any optimizations you could do.

Link to comment
Share on other sites

Swizz, don't take this personally (or do, I don't really care) -- I don't think you've ever said anything useful to me before. Half of the time, I don't even think you've read the post or any of the thread. For that matter, I'm actually trying to think of the last time I've seen you say something useful, period. 

 

My question:

Is there any way to reduce the refresh rate of onPaint (...)?

 

Your response:

The refresh rate is what's causing the "lag". Typically injection based bots (OSBot?) will hook into the relevant graphics methods to paint over the game buffer before it's drawn to the canvas.

 

You're going to want to post your code so we can see if there's any optimizations you could do. 

 

 
The worst part is, your response isn't even correct -- the refresh rate only matters because it contributes to the quadratic explosion (e.g., a high number of vertices versus  a high refresh rate).
 
facep.gif
 
Thanks, @Imateamcape @@House.
 
Here is my solution, which is more resource intensive than House or TC, but reduces it to a manageable level: 
 
Filter out 2/3 of the vertices which exist in the mesh:
 
Old:
oPSbdjo.png
 
New (increased opacity to compensate for fewer vertices):
f3HKzzn.png
 
If anyone knows how to reduce the refresh rate of the paint, I would still like to know so that I can do both.
Edited by Solzhenitsyn
Link to comment
Share on other sites

Can look at my paint class here for buffering/caching the paint. https://github.com/Lem0ns/OSBotAPI/blob/master/painters/Painter.java

 

Other than that, drawing anything that isn't 100% opaque is going to be expensive, if you're doing a wireframe best to just have it solid color. Also, possibly allow toggling of these expensive calls for a "low cpu" mode.

  • Like 2
Link to comment
Share on other sites

 

Swizz, don't take this personally (or do, I don't really care) -- I don't think you've ever said anything useful to me before. Half of the time, I don't even think you've read the post or any of the thread. For that matter, I'm actually trying to think of the last time I've seen you say something useful, period. 

 

My question:

 

Your response:

 

 
The worst part is, your response isn't even correct -- the refresh rate only matters because it contributes to the quadratic explosion (e.g., a high number of vertices versus  a high refresh rate).
 
facep.gif
 
Thanks, @Imateamcape @@House.
 
Here is my solution, which is more resource intensive than House or TC, but reduces it to a manageable level: 
 
Filter out 2/3 of the vertices which exist in the mesh:
 
Old:
oPSbdjo.png
 
New (increased opacity to compensate for fewer vertices):
f3HKzzn.png
 
If anyone knows how to reduce the refresh rate of the paint, I would still like to know so that I can do both.

 

I obviously misread your post, doesn't take a genius to see that.

 

Do I even know you? I don't think we've ever even talked before lol. Not sure why you're trying to act like such an elitist when you're clearly just the typical "I wrote a binary search algorithm and therefore am a wizard" kid. Get off your high horse before you start making a fool of yourself.

 

As for your actual question no I don't think it's possible unless you manipulate the game directly. The bots refresh rate is directly correlated to the game because, as I said, the bot does nothing but draw using the same graphics context.

Link to comment
Share on other sites

I obviously misread your post, doesn't take a genius to see that.

 

Do I even know you? I don't think we've ever even talked before lol. Not sure why you're trying to act like such an elitist when you're clearly just the typical "I wrote a binary search algorithm and therefore am a wizard" kid. Get off your high horse before you start making a fool of yourself.

 

As for your actual question no I don't think it's possible unless you manipulate the game directly. The bots refresh rate is directly correlated to the game because, as I said, the bot does nothing but draw using the same graphics context.

 

I am totally willing to admit that I know almost nothing about computer science.

 

What you are not willing to admit is that you don't read threads, often not even the first post in a thread, before posting advice. That's useless, and a waste of space.

 

So you are correct, I'm no wizard -- but your thoughtless and lazy posts on the threads of myself and others contribute less than virtually any other member who regularly posts on the scripting forums. You obviously know a lot, but withholding that information by teasing only a hint of the solution, or worse yet, delivering nothing at all is far worse than knowing little but making a real attempt to help.

  • Like 1
Link to comment
Share on other sites

I am totally willing to admit that I know almost nothing about computer science.

 

What you are not willing to admit is that you don't read threads, often not even the first post in a thread, before posting advice. That's useless, and a waste of space.

 

So you are correct, I'm no wizard -- but your thoughtless and lazy posts on the threads of myself and others contribute less than virtually any other member who regularly posts on the scripting forums. You obviously know a lot, but withholding that information by teasing only a hint of the solution, or worse yet, delivering nothing at all is far worse than knowing little but making a real attempt to help.

Can you provide some sort of proof to back up your "thoughtless and lazy posts" claim? I've contributed much more to this site than 90% of the active scripters here. I'm also not here to spoon feed people unless they ask for it. You learn nothing but receiving complete solutions for all of your problems.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...