Facepunch / sbox-issues

162 stars 11 forks source link

Graphics.Draw renders Verticies wrong unless Material Editor or any Scene editor is open #2674

Open Adesii opened 1 year ago

Adesii commented 1 year ago

Describe the bug

This is a weird one.

When using Graphics.Draw or Vertexbuffer.Draw methods after selecting a Material in the AssetBrowser the Locations of the Verts is wrong unless opening a Editor with a Scene in it so: Hammer with Map, ModelDoc, Material Editor with Compiled Material.

This persists until closing the game even between restarts. Not selecting anything in the Assetbrowser will display it normally. then breaks when selecting a Material.

Also Drawing without ever having a Scene editor open also doesn't work, might be related to my game not having any SceneObjects in it so it never initialized the Attributes correctly?

To Reproduce

  1. Download and Launch example-test.zip
  2. if everything appears normal, restart the game. (normal means a Grid on the ground)
  3. if just a whitescreen appear this is the Initial bug of not drawing.
  4. Click on worldmat.vmat or any compiled material
  5. see the Grid being angled
  6. Open the vmat or ModelDoc
  7. see it being normal again
  8. closing it will make it break again

Example Project: example-test.zip

(drawing is done in the MainGameHook.cs file at the very bottom)

Expected behavior

obviously it should draw normally like it does when opening ModelDoc.

Media/Files

Example of it being broken:

https://user-images.githubusercontent.com/37816311/206924346-fa51e2a5-b4de-453a-b63f-2112e8a37912.mp4

Additional context

No response

Adesii commented 1 year ago

Spawning any SceneObject fixes the issue. But just spawning a random SceneObject that won't be needed seems like... a bandage fix for now