Logo
NativePhysicsNotifyTarget.h
1#pragma once
2
3namespace XXSharpKmyPhysics
4{
5 class NativePhysicsNotifyTarget : public kmyPhysics::PhysicsNotifyTarget
6 {
7 public:
8 void* operator new(size_t sz) {
9 return malloc(sz);
10 }
11 void operator delete(void* ptr) {
12 if (ptr)free(ptr);
13 }
14
15 NativePhysicsNotifyTarget();
16 void onUpdate()override;
17 void onStartContact(kmyPhysics::ContactInfo &c)override;
18 void onContact(kmyPhysics::ContactInfo &c)override;
19 void onEndContact(kmyPhysics::ContactInfo &c)override;
20 void onDestroy()override;
21
22 //System::Runtime::InteropServices::GCHandle handle;
23 };
24
25 private ref class PhysicsNotifyTarget
26 {
27 public:
28 PhysicsNotifyTarget()
29 {
30 handle = System::Runtime::InteropServices::GCHandle::Alloc(this);
31 //nativetgt = new NativePhysicsNotifyTarget(handle);
32 }
33 !PhysicsNotifyTarget()
34 {
35 handle.Free();
36 //delete nativetgt;
37 }
38 ~PhysicsNotifyTarget()
39 {
40
41 }
42 virtual void onUpdate() {}
43 virtual void onStartContact(PhysicsNotifyTarget^ other, XXSharpKmyMath::Vector3 position, XXSharpKmyMath::Vector3 normal) {}
44 virtual void onContact(PhysicsNotifyTarget^ other, XXSharpKmyMath::Vector3 position, XXSharpKmyMath::Vector3 normal) {}
45 virtual void onEndContact(PhysicsNotifyTarget^ other, XXSharpKmyMath::Vector3 position, XXSharpKmyMath::Vector3 normal) {}
46 virtual void onDestroy() {}
47
48 //NativePhysicsNotifyTarget *nativetgt;
49 System::Runtime::InteropServices::GCHandle handle;
50 };
51
52}