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