Fixing SFXPlaylist (writeFloat vs writeSignedFloat)

Expanding and utilizing the engine via C++.
  • 1
  • 2
14 posts Page 1 of 2
newaged
Posts: 31
Joined: Sat Feb 14, 2015 12:27 am
by newaged » Sat Jan 30, 2016 1:01 am
SFXPlaylist's pack function outputs too much data for the bitstream to handle, so I am reducing the amount of data it sends. Some of its default values are -1, so I was wondering if writesignedfloat has any downsides when compared to writefloat. Secondary topic, is assigning 10 bits for general data too much or too little?
Azaezel
Posts: 409
Joined: Tue Feb 03, 2015 9:50 pm
 
by Azaezel » Sat Jan 30, 2016 9:18 am
https://github.com/GarageGames/Torque3D ... t.cpp#L375 wow, that is nasty... Would say you could reduce more than a little overhead on all but the corneriest of cornercases by killing that fixed 16 off and tracking the max amount of filled-in slots.

For the signed/unsigned thing, general rule of thumb is go ahead and leave it signed throughout the majority of the codebase. Might as well stay consistent there.

On the bitlength end, to use an example with more than a few variants: https://github.com/GarageGames/Torque3D ... e.cpp#L351 general range is 7(also used for things like packing player aiming angles to give you another point of reference for fidelity) up to typically around 12-14 for a cap-out when folks have specified. Not really seeing anything listed requiring ultra-sensitive didgits there though, so could see trending on the lower end.
newaged
Posts: 31
Joined: Sat Feb 14, 2015 12:27 am
by newaged » Sat Jan 30, 2016 11:26 am
Went along with the lower precision idea for a bit, but my basic coding skills weren't enough to make something stable. I decided to use a bunch of flags until I get better at C++.
The code changes for anyone who wants them.

Code: Select all

SFXPlayList::packData( sfx/sfxPlaylist.cpp line 366) ... FOR_EACH_SLOT stream->write( mSlots.mFadeTimeIn.mValue[ i ] ); FOR_EACH_SLOT stream->write( mSlots.mFadeTimeIn.mVariance[ i ][ 0 ] ); FOR_EACH_SLOT stream->write( mSlots.mFadeTimeIn.mVariance[ i ][ 1 ] ); FOR_EACH_SLOT stream->write( mSlots.mFadeTimeOut.mValue[ i ] ); FOR_EACH_SLOT stream->write( mSlots.mFadeTimeOut.mVariance[ i ][ 0 ] ); FOR_EACH_SLOT stream->write( mSlots.mFadeTimeOut.mVariance[ i ][ 1 ] ); FOR_EACH_SLOT stream->write( mSlots.mDelayTimeIn.mValue[ i ] ); FOR_EACH_SLOT stream->write( mSlots.mDelayTimeIn.mVariance[ i ][ 0 ] ); FOR_EACH_SLOT stream->write( mSlots.mDelayTimeIn.mVariance[ i ][ 1 ] ); FOR_EACH_SLOT stream->write( mSlots.mDelayTimeOut.mValue[ i ] ); FOR_EACH_SLOT stream->write( mSlots.mDelayTimeOut.mVariance[ i ][ 0 ] ); FOR_EACH_SLOT stream->write( mSlots.mDelayTimeOut.mVariance[ i ][ 1 ] ); FOR_EACH_SLOT stream->write( mSlots.mVolumeScale.mValue[ i ] ); FOR_EACH_SLOT stream->write( mSlots.mVolumeScale.mVariance[ i ][ 0 ] ); FOR_EACH_SLOT stream->write( mSlots.mVolumeScale.mVariance[ i ][ 1 ] ); FOR_EACH_SLOT stream->write( mSlots.mPitchScale.mValue[ i ] ); FOR_EACH_SLOT stream->write( mSlots.mPitchScale.mVariance[ i ][ 0 ] ); FOR_EACH_SLOT stream->write( mSlots.mPitchScale.mVariance[ i ][ 1 ] ); FOR_EACH_SLOT stream->write( mSlots.mRepeatCount[ i ] ); ... SFXPlayList::unpackData(line 408) ... FOR_EACH_SLOT stream->read( &mSlots.mFadeTimeIn.mValue[ i ] ); FOR_EACH_SLOT stream->read( &mSlots.mFadeTimeIn.mVariance[ i ][ 0 ] ); FOR_EACH_SLOT stream->read( &mSlots.mFadeTimeIn.mVariance[ i ][ 1 ] ); FOR_EACH_SLOT stream->read( &mSlots.mFadeTimeOut.mValue[ i ] ); FOR_EACH_SLOT stream->read( &mSlots.mFadeTimeOut.mVariance[ i ][ 0 ] ); FOR_EACH_SLOT stream->read( &mSlots.mFadeTimeOut.mVariance[ i ][ 1 ] ); FOR_EACH_SLOT stream->read( &mSlots.mDelayTimeIn.mValue[ i ] ); FOR_EACH_SLOT stream->read( &mSlots.mDelayTimeIn.mVariance[ i ][ 0 ] ); FOR_EACH_SLOT stream->read( &mSlots.mDelayTimeIn.mVariance[ i ][ 1 ] ); FOR_EACH_SLOT stream->read( &mSlots.mDelayTimeOut.mValue[ i ] ); FOR_EACH_SLOT stream->read( &mSlots.mDelayTimeOut.mVariance[ i ][ 0 ] ); FOR_EACH_SLOT stream->read( &mSlots.mDelayTimeOut.mVariance[ i ][ 1 ] ); FOR_EACH_SLOT stream->read( &mSlots.mVolumeScale.mValue[ i ] ); FOR_EACH_SLOT stream->read( &mSlots.mVolumeScale.mVariance[ i ][ 0 ] ); FOR_EACH_SLOT stream->read( &mSlots.mVolumeScale.mVariance[ i ][ 1 ] ); FOR_EACH_SLOT stream->read( &mSlots.mPitchScale.mValue[ i ] ); FOR_EACH_SLOT stream->read( &mSlots.mPitchScale.mVariance[ i ][ 0 ] ); FOR_EACH_SLOT stream->read( &mSlots.mPitchScale.mVariance[ i ][ 1 ] ); FOR_EACH_SLOT stream->read( &mSlots.mRepeatCount[ i ] );
change that to this

Code: Select all

SFXPlayList::packData ... FOR_EACH_SLOT if (stream->writeFlag(mSlots.mFadeTimeIn.mValue[ i ] != -1 )) stream->write( mSlots.mFadeTimeIn.mValue[ i ] ); FOR_EACH_SLOT if (stream->writeFlag( mSlots.mFadeTimeIn.mVariance[ i ][ 0 ] > 0)) stream->write(mSlots.mFadeTimeIn.mVariance[ i ][ 0 ] ); FOR_EACH_SLOT if (stream->writeFlag( mSlots.mFadeTimeIn.mVariance[ i ][ 1 ] > 0)) stream->write(mSlots.mFadeTimeIn.mVariance[ i ][ 1 ] ); FOR_EACH_SLOT if (stream->writeFlag(mSlots.mFadeTimeOut.mValue[ i ] != -1 )) stream->write( mSlots.mFadeTimeOut.mValue[ i ] ); FOR_EACH_SLOT if (stream->writeFlag(mSlots.mFadeTimeOut.mVariance[i][0] > 0)) stream->write(mSlots.mFadeTimeOut.mVariance[i][0]); FOR_EACH_SLOT if (stream->writeFlag(mSlots.mFadeTimeOut.mVariance[i][1] > 0)) stream->write(mSlots.mFadeTimeOut.mVariance[i][1]); FOR_EACH_SLOT if (stream->writeFlag(mSlots.mDelayTimeIn.mValue[ i ] > 0)) stream->write(mSlots.mDelayTimeIn.mValue[ i ] ); FOR_EACH_SLOT if (stream->writeFlag(mSlots.mDelayTimeIn.mVariance[ i ][ 0 ] > 0)) stream->write(mSlots.mDelayTimeIn.mVariance[ i ][ 0 ] ); FOR_EACH_SLOT if (stream->writeFlag(mSlots.mDelayTimeIn.mVariance[ i ][ 1 ] > 0)) stream->write(mSlots.mDelayTimeIn.mVariance[ i ][ 1 ] ); FOR_EACH_SLOT if (stream->writeFlag(mSlots.mDelayTimeOut.mValue[ i ] > 0)) stream->write(mSlots.mDelayTimeOut.mValue[ i ] ); FOR_EACH_SLOT if (stream->writeFlag(mSlots.mDelayTimeOut.mVariance[ i ][ 0 ] > 0)) stream->write(mSlots.mDelayTimeOut.mVariance[ i ][ 0 ] ); FOR_EACH_SLOT if (stream->writeFlag(mSlots.mDelayTimeOut.mVariance[ i ][ 1 ] > 0)) stream->write(mSlots.mDelayTimeOut.mVariance[ i ][ 1 ] ); FOR_EACH_SLOT if (stream->writeFlag(mSlots.mVolumeScale.mValue[ i ] != 1)) stream->write(mSlots.mVolumeScale.mValue[ i ] ); FOR_EACH_SLOT if (stream->writeFlag(mSlots.mVolumeScale.mVariance[ i ][ 0 ] > 0)) stream->write(mSlots.mVolumeScale.mVariance[ i ][ 0 ] ); FOR_EACH_SLOT if (stream->writeFlag(mSlots.mVolumeScale.mVariance[ i ][ 1 ] > 0)) stream->write(mSlots.mVolumeScale.mVariance[ i ][ 1 ] ); FOR_EACH_SLOT if (stream->writeFlag(mSlots.mPitchScale.mValue[ i ] != 1)) stream->write(mSlots.mPitchScale.mValue[ i ] ); FOR_EACH_SLOT if (stream->writeFlag(mSlots.mPitchScale.mVariance[ i ][ 0 ] > 0)) stream->write(mSlots.mPitchScale.mVariance[ i ][ 0 ] ); FOR_EACH_SLOT if (stream->writeFlag(mSlots.mPitchScale.mVariance[ i ][ 1 ] > 0)) stream->write(mSlots.mPitchScale.mVariance[ i ][ 1 ] ); FOR_EACH_SLOT if (stream->writeFlag( mSlots.mRepeatCount[ i ] > 0)) stream->write( mSlots.mRepeatCount[ i ] ); ..... SFXPlayList::unpackData ... FOR_EACH_SLOT if(stream->readFlag()){ stream->read( &mSlots.mFadeTimeIn.mValue[ i ] );} FOR_EACH_SLOT if(stream->readFlag()){ stream->read( &mSlots.mFadeTimeIn.mVariance[ i ][ 0 ] );} FOR_EACH_SLOT if(stream->readFlag()){ stream->read( &mSlots.mFadeTimeIn.mVariance[ i ][ 1 ] );} FOR_EACH_SLOT if(stream->readFlag()){ stream->read( &mSlots.mFadeTimeOut.mValue[ i ] );} FOR_EACH_SLOT if(stream->readFlag()){ stream->read( &mSlots.mFadeTimeOut.mVariance[ i ][ 0 ] );} FOR_EACH_SLOT if(stream->readFlag()){ stream->read( &mSlots.mFadeTimeOut.mVariance[ i ][ 1 ] );} FOR_EACH_SLOT if(stream->readFlag()){ stream->read( &mSlots.mDelayTimeIn.mValue[ i ] );} FOR_EACH_SLOT if(stream->readFlag()){ stream->read( &mSlots.mDelayTimeIn.mVariance[ i ][ 0 ] );} FOR_EACH_SLOT if(stream->readFlag()){ stream->read( &mSlots.mDelayTimeIn.mVariance[ i ][ 1 ] );} FOR_EACH_SLOT if(stream->readFlag()){ stream->read( &mSlots.mDelayTimeOut.mValue[ i ] );} FOR_EACH_SLOT if(stream->readFlag()){ stream->read( &mSlots.mDelayTimeOut.mVariance[ i ][ 0 ] );} FOR_EACH_SLOT if(stream->readFlag()){ stream->read( &mSlots.mDelayTimeOut.mVariance[ i ][ 1 ] );} FOR_EACH_SLOT if(stream->readFlag()){ stream->read( &mSlots.mVolumeScale.mValue[ i ] );} FOR_EACH_SLOT if(stream->readFlag()){ stream->read( &mSlots.mVolumeScale.mVariance[ i ][ 0 ] );} FOR_EACH_SLOT if(stream->readFlag()){ stream->read( &mSlots.mVolumeScale.mVariance[ i ][ 1 ] );} FOR_EACH_SLOT if(stream->readFlag()){ stream->read( &mSlots.mPitchScale.mValue[ i ] );} FOR_EACH_SLOT if(stream->readFlag()){ stream->read( &mSlots.mPitchScale.mVariance[ i ][ 0 ] );} FOR_EACH_SLOT if(stream->readFlag()){ stream->read( &mSlots.mPitchScale.mVariance[ i ][ 1 ] );} FOR_EACH_SLOT if(stream->readFlag()){ stream->read( &mSlots.mRepeatCount[ i ] );}
I do realize I could have just changed the slot count, but it still would have sent out a large amount of mostly blank data.
newaged
Posts: 31
Joined: Sat Feb 14, 2015 12:27 am
by newaged » Sun Jan 31, 2016 9:53 pm
@
User avatar
Azaezel
I should probably mention that the last comment was about lowering the hardcoded value, not about your idea of detecting filled slots. That would work fine if I knew how to do it.

Anyways, I am posting here again because I will probably do github stuff soon. Does anyone have an opinion on this being one of the prs? Its not a pretty solution to the problem, but it doesn't break networking like whats in the engine right now.
Duion
Posts: 1051
Joined: Sun Feb 08, 2015 1:51 am
 
by Duion » Mon Feb 01, 2016 3:14 am
I have no idea about that stuff, but it looks like the thing that causes problems in my game as well.
If it fixes the issue and does not break anything why not? Did you test if it solves the issue?
newaged
Posts: 31
Joined: Sat Feb 14, 2015 12:27 am
by newaged » Mon Feb 01, 2016 5:00 am
@
User avatar
Duion
It fixes the problem in the full template. The problem will still occur if a playlist has enough of its slots changed from their default values.
Duion
Posts: 1051
Joined: Sun Feb 08, 2015 1:51 am
 
by Duion » Mon Feb 01, 2016 12:21 pm
Like changing volume, pitch etc?
Nils
Posts: 159
Joined: Thu Feb 05, 2015 3:32 am
 
by Nils » Mon Feb 01, 2016 2:04 pm
Thanks @
User avatar
newaged
, every improvement on networking is welcome!

Tested it (with DM though) and didn't notice any issues!
newaged
Posts: 31
Joined: Sat Feb 14, 2015 12:27 am
by newaged » Mon Feb 01, 2016 5:02 pm
@
User avatar
Duion
Yep. Delay, fade time, repeat count and the variances of the first 4 mentioned groups as well.
JeffR
Steering Committee
Steering Committee
Posts: 840
Joined: Tue Feb 03, 2015 9:49 pm
 
by JeffR » Mon Feb 01, 2016 8:11 pm
I'd say go ahead and PR it if you think it's a worthy change/improvement. As Timmy said, any improvement is welcome :)
  • 1
  • 2
14 posts Page 1 of 2

Who is online

Users browsing this forum: No registered users and 3 guests