Skip to main content
Tweeted twitter.com/#!/StackGameDev/status/510893853722038272
Adding a quadtree tag
Link
John McDonald
  • 6.8k
  • 2
  • 33
  • 46
added 36 characters in body
Source Link
freesoul
  • 393
  • 5
  • 12

I'm planning to use a quadtree for optimizing collision detection. But this quadtree can handle only one type of objects (so I used a base class for my objects).

If I use double dispatch after two object pointers are returned by the quadtree in a collision (derived from the same base class that the quadtree can handle) knowing their ID that identifies their type (an int in the base class) , how am I able to use these pointers with their respective type in order to double dispatch?

Any solution or better way to do this? thanks.

A LIMITED SOLUTION:

Before double dispatching, I could make a resolver function that combines both IDs as they were flags into a single parameter, and make a switch that decides which type are obj1 and obj2.

However, its still not very elegant.

Thanks Any solution or better way to do this? thanks.

I'm planning to use a quadtree for optimizing collision detection. But this quadtree can handle only one type of objects.

If I use double dispatch after two object pointers are returned by the quadtree in a collision (derived from the same base class that the quadtree can handle) knowing their ID that identifies their type (an int in the base class) , how am I able to use these pointers with their respective type in order to double dispatch?

Any solution or better way to do this? thanks.

A LIMITED SOLUTION:

Before double dispatching, I could make a resolver function that combines both IDs as they were flags into a single parameter, and make a switch that decides which type are obj1 and obj2.

However, its still not very elegant.

Thanks.

I'm planning to use a quadtree for optimizing collision detection. But this quadtree can handle only one type of objects (so I used a base class for my objects).

If I use double dispatch after two object pointers are returned by the quadtree in a collision (derived from the same base class that the quadtree can handle) knowing their ID that identifies their type (an int in the base class) , how am I able to use these pointers with their respective type in order to double dispatch?

A LIMITED SOLUTION:

Before double dispatching, I could make a resolver function that combines both IDs as they were flags into a single parameter, and make a switch that decides which type are obj1 and obj2.

However, its still not very elegant. Any solution or better way to do this? thanks.

deleted 359 characters in body
Source Link
freesoul
  • 393
  • 5
  • 12

I'm planning to use a quadtree for optimizing collision detection. But this quadtree can handle only one type of objects. Is there a way to filter collision detection between some pair of type objects, but having all them on the quadtree? If I derive all my objects from a base class, how can I recognize them in order to make this pair filtering?

If I have an ID on each type object, I can figure outuse double dispatch after two options:

A- Having a switch into a switch,object pointers are returned by the quadtree in a generic collision test function.

B- Have a(derived from the same base class having multiple overloaded pair collision function depending on object types as arguments arg1 and arg2. The problem here is how I castthat the object typesquadtree can handle) knowing their ID beffore callingthat identifies their type (an int in the base class) , how am I able to use these pointers with their respective type in order to double dispatch?

Any solution or better way to do this? thanks.

A LIMITED SOLUTION:

Before double dispatching, I could make a single collisionresolver function with a single switch, if I combinethat combines both IDs as they arewere flags into a single parameter, and make a switch that decides which type are obj1 and obj2.

However, its still not very elegant.

Thanks.

I'm planning to use a quadtree for optimizing collision detection. But this quadtree can handle only one type of objects. Is there a way to filter collision detection between some pair of type objects, but having all them on the quadtree? If I derive all my objects from a base class, how can I recognize them in order to make this pair filtering?

If I have an ID on each type object, I can figure out two options:

A- Having a switch into a switch, in a generic collision test function.

B- Have a class having multiple overloaded pair collision function depending on object types as arguments arg1 and arg2. The problem here is how I cast the object types knowing their ID beffore calling the class?

Any solution or better way to do this? thanks.

A LIMITED SOLUTION:

I could make a single collision function with a single switch, if I combine both IDs as they are flags into a single parameter.

However, its still not very elegant.

Thanks.

I'm planning to use a quadtree for optimizing collision detection. But this quadtree can handle only one type of objects.

If I use double dispatch after two object pointers are returned by the quadtree in a collision (derived from the same base class that the quadtree can handle) knowing their ID that identifies their type (an int in the base class) , how am I able to use these pointers with their respective type in order to double dispatch?

Any solution or better way to do this? thanks.

A LIMITED SOLUTION:

Before double dispatching, I could make a resolver function that combines both IDs as they were flags into a single parameter, and make a switch that decides which type are obj1 and obj2.

However, its still not very elegant.

Thanks.

added 205 characters in body
Source Link
freesoul
  • 393
  • 5
  • 12
Loading
deleted 567 characters in body; edited title
Source Link
freesoul
  • 393
  • 5
  • 12
Loading
Source Link
freesoul
  • 393
  • 5
  • 12
Loading