Skip to content

Conversation

@forkerer
Copy link
Contributor

@forkerer forkerer commented Sep 22, 2018

This pull requests is my suggestion of fixing #434.
Instead of using separate queues for primitives, they are now processed along with other dxDraws.
I had some problems with not being able to use smart pointers, due to the fact that draw queue items are stored as union, and they ain't that happy with unique/shared_ptr's. I would be glad if someone with more c++ experience looked over the code to confirm that it's the correct way of solving it.

There's a simple screenshot showing that the order is properly processed (rectangle > primitive >primitiveMaterial > rectangle):

image

This pull request also includes a bit of code cleanup for primitive batchers, as well as CLuaDrawingDefs.cpp primitive functions.


// Set states
m_pDevice->SetRenderState(D3DRS_ZENABLE, m_bZTest ? D3DZB_TRUE : D3DZB_FALSE);
m_pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depth-buffering is not required for 2D draws, so D3DRS_ZENABLE should be set to D3DZB_FALSE

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about stuff like this: https://www.youtube.com/watch?v=CbJerQJBM0M where 2D images, or in this case primitives are placed in 3D world using shaders.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By convention, the 2D drawing functions draw in front of the final world render (The video shows the logo always in front of the car). So the depth buffer should be
disabled by default.

For drawing primitives in the 3D world, we could add dxDrawPrimitive3D (similar to dxDrawLine3D)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no we could, we must add 3d version

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough, disabled the depth buffering for material primitives :)

@ghost
Copy link

ghost commented Sep 23, 2018

You did a very great job with refactoring code. Looks much better.

@patrikjuvonen patrikjuvonen changed the title Modify dxDraw(Material)Primitive to use same queue as other dxDraw functions. Modify dxDraw(Material)Primitive to use same queue as other dxDraw functions Sep 25, 2018
@ccw808 ccw808 merged commit 882f572 into multitheftauto:master Sep 27, 2018
@ccw808
Copy link
Member

ccw808 commented Sep 27, 2018

Thank you!

@qaisjp qaisjp added this to the 1.5.7 milestone Oct 2, 2018
@botder botder assigned forkerer and unassigned forkerer Oct 7, 2018
@patrikjuvonen patrikjuvonen added bug Something isn't working refactor and removed refactor labels Jan 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants