New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: function dxDrawCircle #266

Merged
merged 20 commits into from Aug 4, 2018

Conversation

Projects
9 participants
@CrosRoad95
Contributor

CrosRoad95 commented Jul 26, 2018

Client side function: dxDrawCircle

Syntax:

bool dxDrawCircle( vector2 position, unsigned float radius [, float startAngle = 0, float stopAngle = 360, color theColor = white, color theCenterColor = theColor, int segments = 32, int ratio = 1, bPostGUI = false ])

Arguments:

  1. position - Center of circle.
  2. radius - Radius of circle.
  3. startAngle - From which angle circle become drawing.
  4. stopAngle - On which angle circle stop drawing.
  5. theColor - Color outside center.
  6. theCenterColor - Color in center of circle.
  7. segments - How many triangles you want to draw, higher = more smoothly circle.
  8. ratio - Ration between width and height, 2 mean that circle is 2 times widther then higher.
  9. bPostGui - Draw post gui?

Examples:

  1. Pacmans low segments example ( equal 5 ):
    image
  2. Function dxDrawRoundedRectangle based on dxDrawCircle:
    image
  3. Pacman ( White squere at center is dxDrawRectangle, for debugging if circle drawing properly. ):
    image
  4. Example how working fRatio argument:
    https://gyazo.com/9c19a4441ef4cd2cc330d3c8c2083268
  5. Example how working startAngle and stopAngle:
    image
  6. Example how working startAngle and stopAngle with segments = 5 :
    image
  7. Example of different theColor and theColorCenter
    image
  8. Default segments count:
dxDrawCircle(1500,150,20);
dxDrawCircle(1700,150,100);
dxDrawCircle(1500,250,50);

image

The circle:

image

Performance:

I put 200 pacmans with 64 segments then what couse ( on my medium pc ) about - 20fps.
Example script below which draw a lot of stuff doing small fps drop.

Tips:

  1. If you want to draw small circle, use low amount of segments.
  2. You can draw every pieces of circle individually to make colorful circle.

Script:

circle.zip

CrosRoad95 added some commits May 30, 2018

@Pirulax

This comment has been minimized.

Show comment
Hide comment
@Pirulax

Pirulax Jul 26, 2018

Contributor

How does it looks like with the default resolution?

Contributor

Pirulax commented Jul 26, 2018

How does it looks like with the default resolution?

@CrosRoad95

This comment has been minimized.

Show comment
Hide comment
@CrosRoad95

CrosRoad95 Jul 26, 2018

Contributor

@Pirulax i added how looks circle with only first 3 arguments ( x, y and radius ).

Contributor

CrosRoad95 commented Jul 26, 2018

@Pirulax i added how looks circle with only first 3 arguments ( x, y and radius ).

@Citizen01

This comment has been minimized.

Show comment
Hide comment
@Citizen01

Citizen01 Jul 26, 2018

Feels weird to have 0° on the right side of the circle instead of the top but I guess it's not coming from you and that's how the underlaying function works ?

Citizen01 commented Jul 26, 2018

Feels weird to have 0° on the right side of the circle instead of the top but I guess it's not coming from you and that's how the underlaying function works ?

@Pirulax

This comment has been minimized.

Show comment
Hide comment
@Pirulax

Pirulax Jul 26, 2018

Contributor

I think the same about it starting from the right side, Im lazy to look at your code, but adding a -90 to the deg should solve ur problem.

Contributor

Pirulax commented Jul 26, 2018

I think the same about it starting from the right side, Im lazy to look at your code, but adding a -90 to the deg should solve ur problem.

@ccw808

This comment has been minimized.

Show comment
Hide comment
@ccw808
Member

ccw808 commented Jul 26, 2018

@CrosRoad95

This comment has been minimized.

Show comment
Hide comment
@CrosRoad95

CrosRoad95 Jul 27, 2018

Contributor

I tested dxDrawCircle from wiki, my function is 2-3 times faster ( with default arguments, you can decrees amount of segments what speed up drawing )

Contributor

CrosRoad95 commented Jul 27, 2018

I tested dxDrawCircle from wiki, my function is 2-3 times faster ( with default arguments, you can decrees amount of segments what speed up drawing )

@botder botder added the new feature label Jul 29, 2018

@qaisjp qaisjp added the enhancement label Jul 29, 2018

@Einheit-101

This comment has been minimized.

Show comment
Hide comment
@Einheit-101

Einheit-101 Jul 29, 2018

This is amazing. DX circles were a mayor performance hog, but dxDrawCircle (Shader variant) was already pretty good. If this here is even 2-3 times faster it would drain no performance at all.
At this point i would like to thank everyone who is putting a lot of effort into MTA lately.

Einheit-101 commented Jul 29, 2018

This is amazing. DX circles were a mayor performance hog, but dxDrawCircle (Shader variant) was already pretty good. If this here is even 2-3 times faster it would drain no performance at all.
At this point i would like to thank everyone who is putting a lot of effort into MTA lately.

@Pirulax

This comment has been minimized.

Show comment
Hide comment
@Pirulax

Pirulax Jul 31, 2018

Contributor

The time your resource prints in render is the time it takes to add those circles to the render queue.

Contributor

Pirulax commented Jul 31, 2018

The time your resource prints in render is the time it takes to add those circles to the render queue.

@saml1er

I tested these functions with the script (circle.zip) provided. I was also able to draw around 900 circles and rectangles with full FPS, so it's indeed good performance-wise. If variables are renamed properly, this PR is ready to merge.

Show outdated Hide outdated Client/core/Graphics/CGraphics.cpp
Show outdated Hide outdated Client/core/Graphics/CGraphics.cpp
Show outdated Hide outdated Client/core/Graphics/CGraphics.h
Show outdated Hide outdated Client/sdk/core/CGraphicsInterface.h
Show outdated Hide outdated Client/core/Graphics/CGraphics.h
Show outdated Hide outdated Client/core/Graphics/CGraphics.cpp
Show outdated Hide outdated Client/core/Graphics/CGraphics.cpp
Show outdated Hide outdated Client/mods/deathmatch/logic/luadefs/CLuaDrawingDefs.cpp

CrosRoad95 added some commits Aug 4, 2018

CrosRoad95 added some commits Aug 4, 2018

@saml1er saml1er merged commit 7a9a246 into multitheftauto:master Aug 4, 2018

3 checks passed

WIP ready for review
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@patrikjuvonen patrikjuvonen added this to In progress in release/v1.5.6 via automation Aug 7, 2018

@patrikjuvonen patrikjuvonen added this to the 1.5.6 milestone Aug 7, 2018

@patrikjuvonen patrikjuvonen moved this from In progress to Done in release/v1.5.6 Aug 7, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment