physics entity now extends transformable
This commit is contained in:
parent
8c78395219
commit
9c0c354fcd
|
@ -10,24 +10,25 @@
|
||||||
typedef struct {
|
typedef struct {
|
||||||
RigidBody* (*const get_rigidbody)(void* self);
|
RigidBody* (*const get_rigidbody)(void* self);
|
||||||
Shape* (*const get_shape)(void* self);
|
Shape* (*const get_shape)(void* self);
|
||||||
Transformable (*const as_transformable)(void* self);
|
|
||||||
} IPhysicsEntity;
|
} IPhysicsEntity;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
void* self;
|
void* data;
|
||||||
IPhysicsEntity const* tc;
|
IPhysicsEntity const* tc;
|
||||||
|
ITransformable const* transformable;
|
||||||
} PhysicsEntity;
|
} PhysicsEntity;
|
||||||
|
|
||||||
#define impl_PhysicsEntity_for(T, get_rigidbody_f, get_shape_f)\
|
#define impl_PhysicsEntity_for(T, get_rigidbody_f, get_shape_f)\
|
||||||
static inline PhysicsEntity T##_as_PhysicsEntity(T* x) {\
|
static inline PhysicsEntity T##_as_PhysicsEntity(T* x) {\
|
||||||
TC_FN_TYPECHECK(RigidBody*, get_rigidbody_f, T* e);\
|
TC_FN_TYPECHECK(Transformable, T##_as_Transformable, T*);\
|
||||||
TC_FN_TYPECHECK(Shape*, get_shape_f, T* e);\
|
TC_FN_TYPECHECK(RigidBody*, get_rigidbody_f, T*);\
|
||||||
|
TC_FN_TYPECHECK(Shape*, get_shape_f, T*);\
|
||||||
static IPhysicsEntity const tc = {\
|
static IPhysicsEntity const tc = {\
|
||||||
.get_rigidbody = (RigidBody*(*const)(void*)) get_transform_f,\
|
.get_rigidbody = (RigidBody*(*const)(void*)) get_rigidbody_f,\
|
||||||
.get_shape = (Shape*(*const)(void*)) get_shape_f,\
|
.get_shape = (Shape*(*const)(void*)) get_shape_f,\
|
||||||
.as_transformable = T##_as_Transformable\
|
|
||||||
};\
|
};\
|
||||||
return (PhysicsEntity){.tc = &interface, .self = x};\
|
Transformable transformable = T##_as_Transformable(x);\
|
||||||
|
return (PhysicsEntity){.data = x, .tc = &tc, .transformable = transformable.tc};\
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // !_fencer_collidable_h
|
#endif // !_fencer_collidable_h
|
||||||
|
|
Loading…
Reference in a new issue