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

Method read

Engine/source/ts/tsShape.cpp:1931–2021  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1929//-------------------------------------------------
1930
1931bool TSShape::read(Stream * s)
1932{
1933 // read version - read handles endian-flip
1934 s->read(&smReadVersion);
1935 mExporterVersion = smReadVersion >> 16;
1936 smReadVersion &= 0xFF;
1937 if (smReadVersion>smVersion)
1938 {
1939 // error -- don't support future versions yet :>
1940 Con::errorf(ConsoleLogEntry::General,
1941 "Error: attempt to load a version %i dts-shape, can currently only load version %i and before.",
1942 smReadVersion,smVersion);
1943 return false;
1944 }
1945 mReadVersion = smReadVersion;
1946
1947 S32 * memBuffer32;
1948 S16 * memBuffer16;
1949 S8 * memBuffer8;
1950 S32 count32, count16, count8;
1951 if (mReadVersion<19)
1952 {
1953 Con::errorf("... Shape with old version.");
1954 return false;
1955 }
1956 else
1957 {
1958 S32 i;
1959 U32 sizeMemBuffer, startU16, startU8;
1960
1961 // in dwords. - read handles endian-flip
1962 s->read(&sizeMemBuffer);
1963 s->read(&startU16);
1964 s->read(&startU8);
1965
1966 if (s->getStatus()!=Stream::Ok)
1967 {
1968 Con::errorf(ConsoleLogEntry::General, "Error: bad shape file.");
1969 return false;
1970 }
1971
1972 S32 * tmp = new S32[sizeMemBuffer];
1973 s->read(sizeof(S32)*sizeMemBuffer,(U8*)tmp);
1974 memBuffer32 = tmp;
1975 memBuffer16 = (S16*)(tmp+startU16);
1976 memBuffer8 = (S8*)(tmp+startU8);
1977
1978 count32 = startU16;
1979 count16 = startU8-startU16;
1980 count8 = sizeMemBuffer-startU8;
1981
1982 // read sequences
1983 S32 numSequences;
1984 s->read(&numSequences);
1985 sequences.setSize(numSequences);
1986 for (i=0; i<numSequences; i++)
1987 {
1988 sequences[i].read(s);

Callers 7

createMethod · 0.45
loadColladaShapeFunction · 0.45
assimpLoadShapeFunction · 0.45
loadMethod · 0.45
_loadMethod · 0.45
_loadLegacyMethod · 0.45
unpackUpdateMethod · 0.45

Calls 8

setReadMethod · 0.80
doAllocMethod · 0.80
errorfFunction · 0.50
initFunction · 0.50
getStatusMethod · 0.45
setSizeMethod · 0.45
getSizeMethod · 0.45
getBufferMethod · 0.45

Tested by

no test coverage detected