1 /*---------------------------------------------------------------------------*
2   Project:  NintendoWare
3   File:     gfx_ParticleContext.cpp
4 
5   Copyright (C)2009-2010 Nintendo Co., Ltd./HAL Laboratory, Inc.  All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain
8   proprietary information of Nintendo of America Inc. and/or Nintendo
9   Company Ltd., and are protected by Federal copyright law.  They may
10   not be disclosed to third parties or copied or duplicated in any form,
11   in whole or in part, without the prior written consent of Nintendo.
12 
13   $Revision: 28118 $
14  *---------------------------------------------------------------------------*/
15 
16 #include "precompiled.h"
17 
18 #include <nw/gfx/gfx_ParticleContext.h>
19 
20 namespace nw
21 {
22 namespace gfx
23 {
24 
25 //----------------------------------------
26 ParticleContext*
Create(os::IAllocator * allocator)27 ParticleContext::Builder::Create(
28     os::IAllocator* allocator
29 )
30 {
31     NW_NULL_ASSERT(allocator);
32 
33     VEC3Array emissionPositions(allocator);
34     U16Array emissionParents(allocator);
35     F32Array particleWorkF32(allocator);
36 
37     if (m_IsFixedSizeMemory)
38     {
39         emissionPositions = VEC3Array(this->m_MaxEmission, allocator);
40         emissionParents = U16Array(this->m_MaxEmission, allocator);
41         particleWorkF32 = F32Array(this->m_MaxStreamLength, allocator);
42     }
43     else
44     {
45 #ifndef NW_MOVE_ARRAY_VARIABILITY_ENABLED
46         NW_FATAL_ERROR("Can't disable IsFixedSizeMemory without NW_MOVE_ARRAY_VARIABILITY_ENABLED");
47 #endif
48     }
49 
50     void* memory = allocator->Alloc(sizeof(ParticleContext));
51     NW_NULL_ASSERT(memory);
52 
53     ParticleContext* context = new(memory) ParticleContext(
54         allocator, emissionPositions, emissionParents, particleWorkF32);
55 
56     return context;
57 }
58 
59 } // namespace gfx
60 } // namespace nw
61