Nebula
Loading...
Searching...
No Matches
callbacks.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
9//------------------------------------------------------------------------------
10
11#include "memory/memory.h"
12
13//------------------------------------------------------------------------------
14namespace Physics
15{
16
17//------------------------------------------------------------------------------
18class Allocator: public physx::PxAllocatorCallback
19{
20public:
21 // FIXME check for memleaks?
24 void* allocate(size_t size, const char* typeName, const char* filename, int line);
26 void deallocate(void* ptr);
27};
28
29
30//------------------------------------------------------------------------------
31
32class ErrorCallback : public physx::PxErrorCallback
33{
34public:
36 void reportError(physx::PxErrorCode::Enum code, const char* message, const char* file, int line);
37};
38
39//------------------------------------------------------------------------------
42inline void*
43Allocator::allocate(size_t size, const char * typeName, const char* filename, int line)
44{
45 void* buffer = Memory::Alloc(Memory::HeapType::PhysicsHeap, size);
46 n_assert_fmt(buffer, "Allocation of %s failed: %s, line: %d", typeName, filename, line);
47 return buffer;
48}
49
50//------------------------------------------------------------------------------
53inline void
55{
56 Memory::Free(Memory::HeapType::PhysicsHeap, ptr);
57}
58
59}
60
61
62
Definition callbacks.h:19
void deallocate(void *ptr)
Definition callbacks.h:54
~Allocator()
Definition callbacks.h:22
void * allocate(size_t size, const char *typeName, const char *filename, int line)
physx callback for allocating memory, should be at least 16 byte aligned
Definition callbacks.h:43
Definition callbacks.h:33
void reportError(physx::PxErrorCode::Enum code, const char *message, const char *file, int line)
error callback channeling px messages to nebula log system
Definition callbacks.cc:20
#define n_assert_fmt(exp, msg,...)
Definition debug.h:53
Implements a memory related functions.
void * Alloc(HeapType heapType, size_t size, size_t alignment)
Allocate a block of memory from one of the global heaps.
Definition osxmemory.cc:56
void Free(HeapType heapType, void *ptr)
Free a block of memory.
Definition osxmemory.cc:136
Diverse functions for manipulating physics actors.
Definition actorcontext.cc:18