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

World GetDirectSpaceState() return Null [Mono] #11913

Closed
khairul169 opened this issue Oct 7, 2017 · 1 comment · Fixed by #11954
Closed

World GetDirectSpaceState() return Null [Mono] #11913

khairul169 opened this issue Oct 7, 2017 · 1 comment · Fixed by #11954

Comments

@khairul169
Copy link
Contributor

khairul169 commented Oct 7, 2017

Operating system or device, Godot version, GPU Model and driver (if graphics related):
Godot engine 3.0 master 195b122

Issue description:
Cannot get direct space state for raycasting.. tried to do several method like World.GetDirectSpaceState() and PhysicsServer.SpaceGetDirectState(World.GetSpace()), but both return Null.

This is also happened with Physics2DDirectSpaceState.

Steps to reproduce:
Create a c# script, and paste this code:

World WorldRef = GetViewport().FindWorld();
GD.print(WorldRef.GetDirectSpaceState()); // Null
GD.print(PhysicsServer.SpaceGetDirectState(WorldRef.GetSpace())); // Null

Console output:

ERROR: CSharpLanguage::alloc_instance_binding_data: Parameter ' type_class ' is null.
   At: modules\mono\csharp_script.cpp:659
DSS: Null

Link to minimal example project:

@neikeq neikeq added this to the 3.0 milestone Oct 7, 2017
@neikeq
Copy link
Contributor

neikeq commented Oct 7, 2017

The problem is that classes like PhysicsDirectSpaceStateSW are not registered manually. Instead, _post_initialize will register them when an instance is created. Bindings generators cannot detect many of these classes because of that.

I think the best solution would be the following:

  • Only the classes that are registered manually must be exposed to the bindings and to the class reference. Classes that are initialized on _post_initialize must be be registered in a special way so that bindings and class reference generators can differentiate them from the rest of the classes and ignore them.
  • When the engine wants to pass an instance of one of those special classes to C#, we need to create a managed instance that wraps it, and we do that by searching the class name via reflection. PhysicsDirectSpaceStateSW won't work. We need either get_class_name() or a new virtual method to return the name of the closest registered parent class (PhysicsDirectSpaceState in the case of PhysicsDirectSpaceStateSW).

@reduz WDYT?

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

Successfully merging a pull request may close this issue.

2 participants