Nebula
Toggle main menu visibility
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
//------------------------------------------------------------------------------
14
namespace
Physics
15
{
16
17
//------------------------------------------------------------------------------
18
class
Allocator
:
public
physx::PxAllocatorCallback
19
{
20
public
:
21
// FIXME check for memleaks?
22
~Allocator
() { }
24
void
*
allocate
(
size_t
size,
const
char
* typeName,
const
char
* filename,
int
line);
26
void
deallocate
(
void
* ptr);
27
};
28
29
30
//------------------------------------------------------------------------------
31
32
class
ErrorCallback
:
public
physx::PxErrorCallback
33
{
34
public
:
36
void
reportError
(physx::PxErrorCode::Enum code,
const
char
* message,
const
char
* file,
int
line);
37
};
38
39
//------------------------------------------------------------------------------
42
inline
void
*
43
Allocator::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
//------------------------------------------------------------------------------
53
inline
void
54
Allocator::deallocate
(
void
* ptr)
55
{
56
Memory::Free
(Memory::HeapType::PhysicsHeap, ptr);
57
}
58
59
}
60
61
62
Physics::Allocator
Definition
callbacks.h:19
Physics::Allocator::deallocate
void deallocate(void *ptr)
Definition
callbacks.h:54
Physics::Allocator::~Allocator
~Allocator()
Definition
callbacks.h:22
Physics::Allocator::allocate
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
Physics::ErrorCallback
Definition
callbacks.h:33
Physics::ErrorCallback::reportError
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
n_assert_fmt
#define n_assert_fmt(exp, msg,...)
Definition
debug.h:53
memory.h
Implements a memory related functions.
Memory::Alloc
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
Memory::Free
void Free(HeapType heapType, void *ptr)
Free a block of memory.
Definition
osxmemory.cc:136
Physics
Diverse functions for manipulating physics actors.
Definition
actorcontext.cc:18
code
physics
physics
callbacks.h
Generated on
for Nebula. Dark theme by
Tilen Majerle
. All rights reserved.