0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[ODE]dSpaceCollideにメンバ関数を渡す

Last updated at Posted at 2015-10-28

プロプログラマの皆さんには何言ってんだこいつレベルの記事でしょうが,備忘録的に.

  • OpenDynamicsEngineを使用する上で,オブジェクト指向っぽくしたい
  • コールバック関数を渡すときにstaticじゃないとメンバ関数を渡せない

ので,

main.cpp
class simWorld
{
public:
~~
public:
	simWorld()
	{
      ~~
    };
	
	~simWorld()
	{
		~~
	}
		
	static void nearCallback(void *data, dGeomID o1, dGeomID o2)
	{
		simWorld *tgt = (simWorld*)data;
        
        ~~
	};
	
	void simLoop ()
	{
		dSpaceCollide(space,this,nearCallback);

        ~~
	};

	
	
	
};

ってな感じでdataにthisを渡してあげるとイイカンジです.
nearCallback内では[tgt->]な感じでアクセス.

右も左もわからないので,こんなことやっちゃダメとかなにかありましたらコメント頂けると助かります...

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?