MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / write

Method write

Engine/source/T3D/decal/decalDataFile.cpp:91–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89//-----------------------------------------------------------------------------
90
91bool DecalDataFile::write( Stream& stream )
92{
93 // Write our identifier... so we have a better
94 // idea if we're reading pure garbage.
95 // This identifier stands for "Torque Decal Data File".
96 stream.write( 4, "TDDF" );
97
98 // Now the version number.
99 stream.write( (U8)FILE_VERSION );
100
101 Vector<DecalInstance*> allDecals;
102
103 // Gather all DecalInstances that should be saved.
104 for ( U32 i = 0; i < mSphereList.size(); i++ )
105 {
106 Vector<DecalInstance*>::const_iterator item = mSphereList[i]->mItems.begin();
107 for ( ; item != mSphereList[i]->mItems.end(); item++ )
108 {
109 if ( (*item)->mFlags & SaveDecal )
110 allDecals.push_back( (*item) );
111 }
112 }
113
114 // Gather all the DecalData datablocks used.
115 Vector<const DecalData*> allDatablocks;
116 for ( U32 i = 0; i < allDecals.size(); i++ )
117 allDatablocks.push_back_unique( allDecals[i]->mDataBlock );
118
119 // Write out datablock lookupNames.
120 U32 count = allDatablocks.size();
121 stream.write( count );
122 for ( U32 i = 0; i < count; i++ )
123 stream.write( allDatablocks[i]->lookupName );
124
125 Vector<const DecalData*>::iterator dataIter;
126
127 // Write out the DecalInstance list.
128 count = allDecals.size();
129 stream.write( count );
130 for ( U32 i = 0; i < count; i++ )
131 {
132 DecalInstance *inst = allDecals[i];
133
134 dataIter = T3D::find( allDatablocks.begin(), allDatablocks.end(), inst->mDataBlock );
135 U8 dataIndex = dataIter - allDatablocks.begin();
136
137 stream.write( dataIndex );
138 mathWrite( stream, inst->mPosition );
139 mathWrite( stream, inst->mNormal );
140 mathWrite( stream, inst->mTangent );
141 stream.write( inst->mTextureRectIdx );
142 stream.write( inst->mSize );
143 stream.write( inst->mRenderPriority );
144 }
145
146 // Clear the dirty flag.
147 mIsDirty = false;
148

Callers 15

packDataMethod · 0.45
_createDataFileMethod · 0.45
saveDecalsMethod · 0.45
importImageAssetMethod · 0.45
importMaterialAssetMethod · 0.45
importShapeAssetMethod · 0.45
importSoundAssetMethod · 0.45
getAssetByFilenameMethod · 0.45
getAssetIdByFilenameMethod · 0.45
packUpdateMethod · 0.45

Calls 7

mathWriteFunction · 0.85
push_back_uniqueMethod · 0.80
findFunction · 0.50
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected