Skip to content
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

[Question]: Unable to draw lines in 2D #14

Open
dogboydog opened this issue May 22, 2023 · 5 comments
Open

[Question]: Unable to draw lines in 2D #14

dogboydog opened this issue May 22, 2023 · 5 comments
Labels
enhancement New feature or request question Further information is requested

Comments

@dogboydog
Copy link

Godot version

v3.5.2.stable.mono.official [170ba337a]

DebugDraw3D version

1.0.2

On which operating systems the error occurs

Windows

Using which renderers the error occurs

GLES3

Issue description

Hello, I'm quite interested to try this plugin for my project as it seems really cool.

In earlier messages you asked to confirm the plugin is installed by searching the help for DebugDraw I believe. In my project and my test repro for this issue, I can't see that in the help.

image

image

I'm also kind of unclear about how to use this for 2D, is it possible? The arguments are Vector3, but not sure if these will display in a 2D view. I would ideally like to draw lines with with global position /world space position of 2D nodes and have them display over everything.

Steps to reproduce

Open this zip project and run the main scene

The text is showing but the lines are not drawing

		public override void _Process(float delta)
		{
        DebugDrawCS.Freeze3dRender = true;
        DebugDrawCS.ForceUseCameraFromScene = true;
        DebugDrawCS.DebugEnabled = true;
        DebugDrawCS.VisibleInstanceBounds = true;
        DebugDrawCS.DrawLine(new Vector3(0, 0, 0), new Vector3(200,200,0), Colors.Red, 1f);
        DebugDrawCS.DrawLine(new Vector3(0, 0, 3), new Vector3(1,1,3), Colors.Green, 1f);
        DebugDrawCS.DrawLine(new Vector3(0, 0, 8), new Vector3(8,8,8), Colors.Blue, 1f);
        DebugDrawCS.SetText("Test", "4");
        DebugDrawCS.SetText("Test2", "444");
        DebugDrawCS.GeometryRenderLayers = 6;
		}

Minimal reproduction project

DebugDrawTest.zip

@dogboydog dogboydog added the bug Something isn't working label May 22, 2023
@dogboydog dogboydog changed the title [Bug]: Unable to draw lines [Bug]: Unable to draw lines in 2D May 22, 2023
@DmitriySalnikov
Copy link
Owner

DmitriySalnikov commented May 22, 2023

DebugDrawCS.Freeze3dRender = true;

It does not allow you to change the geometry that has already been drawn. In this case, nothing was drawn... You need to remove `freeze'.

DebugDrawCS.GeometryRenderLayers = 6;

This is not the 6th layer. These are the 2nd and 3rd layers. Because 6 in binary is equal to 0110.
The 6th layer is 32, or 1 << 5 or you can use one of the methods set_*_mask_bit (in this case set_layer_mask_bit)
image
Also, in order to see 3D lines, you need at least one 3D camera on the scene. You can even use this tool:
image

Your example without freeze:
image

I was thinking about adding support for 2d debug. Because at the moment, in order to draw a line, you need to manually save it somewhere, then call update/queue_redraw and only then draw it in the _draw method. With this extension, it would be possible to simplify this to a single method call.
It seemed to me that the addon for this has already been developed for 2D or not?

In earlier messages you asked to confirm the plugin is installed by searching the help for DebugDraw I believe. In my project and my test repro for this issue, I can't see that in the help.

This was said about Godot 4, where GDExtension is used, which tries to load the library as if it were part of the engine itself. Therefore, you can find this class in the documentation.
Godot 3 uses GDNative, which simply allows you to use classes and methods from the native library after loading it with load and new.

@dogboydog
Copy link
Author

dogboydog commented May 22, 2023

Thanks for your feedback, sorry for my misunderstanding of those boolean settings but i was trying out different settings to see if I could view the lines.

I see the question about the help is not relevant to the Godot 3.5 version.

It seemed to me that the addon for this has already been developed for 2D or not?

Sorry could you rephrase what you mean here? Are you saying it should already work for 2d? Or that there may be some other addon for 2d that I should use instead? In order to use yours with 2d, I would need to add a 3d camera to the scene? I don't always run via the godot editor so i wouldn't necessarily be able to use the editor button you show, but maybe I could instantiate a 3d camera via code. not sure how messy that will get for a 2d game though

@DmitriySalnikov
Copy link
Owner

Sorry could you rephrase what you mean here?

I meant that maybe there is another extension for debug drawing in 2d.

but maybe I could instantiate a 3d camera via code

I'm not sure if there is a easy way to render 3d over 2d. Usually 2d is drawn on top of 3d.

@dogboydog dogboydog changed the title [Bug]: Unable to draw lines in 2D [Question]: Unable to draw lines in 2D May 22, 2023
@dogboydog
Copy link
Author

Ah okay. I haven't found a 2D-enabled one in my searches so far. There is the proposal open to make easier debug drawing an engine feature which seems unlikely to be implemented, which is how I found this addon.

I found this, which has 2D support but is for Godot 4

https://github.com/jirikostiha/godot-sharp-some

Maybe I should pursue doing it this way for now:

in order to draw a line, you need to manually save it somewhere, then call update/queue_redraw and only then draw it in the _draw method.

@dogboydog
Copy link
Author

dogboydog commented May 23, 2023

Looks like Line2D could be used for some basic drawing, and you could surround that related code with #if. Thanks for your help finding the problems with my usage of your plugin though, appreciate it

@DmitriySalnikov DmitriySalnikov added enhancement New feature or request question Further information is requested and removed bug Something isn't working labels May 26, 2023
@skooter500 skooter500 mentioned this issue Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants