Merge branch 'development' into fix467_exportCollada

This commit is contained in:
Areloch 2016-12-09 21:09:12 -06:00 committed by GitHub
commit 06f32342ab
50 changed files with 2069 additions and 700 deletions

View file

@ -162,6 +162,13 @@ DefineConsoleFunction( setNetPort, bool, (int port, bool bind), (true), "(int po
return Net::openPort((S32)port, bind); return Net::openPort((S32)port, bind);
} }
DefineConsoleFunction(isAddressTypeAvailable, bool, (int addressType), , "(protocol id)"
"@brief Determines if a specified address type can be reached.\n\n"
"@ingroup Networking")
{
return Net::isAddressTypeAvailable((NetAddress::Type)addressType);
}
DefineConsoleFunction( closeNetPort, void, (), , "()" DefineConsoleFunction( closeNetPort, void, (), , "()"
"@brief Closes the current network port\n\n" "@brief Closes the current network port\n\n"
"@ingroup Networking") "@ingroup Networking")

View file

@ -320,7 +320,7 @@ void StandardMainLoop::init()
Sampler::init(); Sampler::init();
// Hook in for UDP notification // Hook in for UDP notification
Net::smPacketReceive.notify(GNet, &NetInterface::processPacketReceiveEvent); Net::getPacketReceiveEvent().notify(GNet, &NetInterface::processPacketReceiveEvent);
#ifdef TORQUE_DEBUG_GUARD #ifdef TORQUE_DEBUG_GUARD
Memory::flagCurrentAllocs( Memory::FLAG_Static ); Memory::flagCurrentAllocs( Memory::FLAG_Static );
@ -604,15 +604,11 @@ bool StandardMainLoop::doMainLoop()
lastFocus = newFocus; lastFocus = newFocus;
} }
#ifndef TORQUE_OS_MAC
// under the web plugin do not sleep the process when the child window loses focus as this will cripple the browser perfomance // under the web plugin do not sleep the process when the child window loses focus as this will cripple the browser perfomance
if (!Platform::getWebDeployment()) if (!Platform::getWebDeployment())
tm->setBackground(!newFocus); tm->setBackground(!newFocus);
else else
tm->setBackground(false); tm->setBackground(false);
#else
tm->setBackground(false);
#endif
} }
else else
{ {

View file

@ -177,7 +177,7 @@ static Vector<Ping> gQueryList(__FILE__, __LINE__);
struct PacketStatus struct PacketStatus
{ {
U8 index; U16 index;
S32 key; S32 key;
U32 time; U32 time;
U32 tryCount; U32 tryCount;
@ -191,6 +191,9 @@ struct PacketStatus
time = _time; time = _time;
tryCount = gPacketRetryCount; tryCount = gPacketRetryCount;
} }
inline U8 getOldIndex() { return (U8)index; }
inline U16 getIndex() { return index; }
}; };
static Vector<PacketStatus> gPacketStatusList(__FILE__, __LINE__); static Vector<PacketStatus> gPacketStatusList(__FILE__, __LINE__);
@ -212,6 +215,7 @@ struct ServerFilter
OnlineQuery = 0, // Authenticated with master OnlineQuery = 0, // Authenticated with master
OfflineQuery = BIT(0), // On our own OfflineQuery = BIT(0), // On our own
NoStringCompress = BIT(1), NoStringCompress = BIT(1),
NewStyleResponse = BIT(2), // Include IPV6 servers
}; };
enum // Filter flags: enum // Filter flags:
@ -223,6 +227,14 @@ struct ServerFilter
NotXenon = BIT(6) NotXenon = BIT(6)
}; };
enum // Region mask flags
{
RegionIsIPV4Address = BIT(30),
RegionIsIPV6Address = BIT(31),
RegionAddressMask = RegionIsIPV4Address | RegionIsIPV6Address
};
//Rearranging the fields according to their sizes //Rearranging the fields according to their sizes
char* gameType; char* gameType;
char* missionType; char* missionType;
@ -241,7 +253,7 @@ struct ServerFilter
ServerFilter() ServerFilter()
{ {
type = Normal; type = Normal;
queryFlags = 0; queryFlags = NewStyleResponse;
gameType = NULL; gameType = NULL;
missionType = NULL; missionType = NULL;
minPlayers = 0; minPlayers = 0;
@ -401,10 +413,17 @@ void queryLanServers(U32 port, U8 flags, const char* gameType, const char* missi
NetAddress addr; NetAddress addr;
char addrText[256]; char addrText[256];
// IPV4
dSprintf( addrText, sizeof( addrText ), "IP:BROADCAST:%d", port ); dSprintf( addrText, sizeof( addrText ), "IP:BROADCAST:%d", port );
Net::stringToAddress( addrText, &addr ); Net::stringToAddress( addrText, &addr );
pushPingBroadcast( &addr ); pushPingBroadcast( &addr );
// IPV6
dSprintf(addrText, sizeof(addrText), "IP6:MULTICAST:%d", port);
Net::stringToAddress(addrText, &addr);
pushPingBroadcast(&addr);
Con::executef("onServerQueryStatus", "start", "Querying LAN servers", "0"); Con::executef("onServerQueryStatus", "start", "Querying LAN servers", "0");
processPingsAndQueries( gPingSession ); processPingsAndQueries( gPingSession );
} }
@ -502,7 +521,7 @@ void queryMasterServer(U8 flags, const char* gameType, const char* missionType,
dStrcpy( sActiveFilter.missionType, missionType ); dStrcpy( sActiveFilter.missionType, missionType );
} }
sActiveFilter.queryFlags = flags; sActiveFilter.queryFlags = flags | ServerFilter::NewStyleResponse;
sActiveFilter.minPlayers = minPlayers; sActiveFilter.minPlayers = minPlayers;
sActiveFilter.maxPlayers = maxPlayers; sActiveFilter.maxPlayers = maxPlayers;
sActiveFilter.maxBots = maxBots; sActiveFilter.maxBots = maxBots;
@ -519,6 +538,7 @@ void queryMasterServer(U8 flags, const char* gameType, const char* missionType,
sActiveFilter.type = ServerFilter::Buddy; sActiveFilter.type = ServerFilter::Buddy;
sActiveFilter.buddyCount = buddyCount; sActiveFilter.buddyCount = buddyCount;
sActiveFilter.buddyList = (U32*) dRealloc( sActiveFilter.buddyList, buddyCount * 4 ); sActiveFilter.buddyList = (U32*) dRealloc( sActiveFilter.buddyList, buddyCount * 4 );
sActiveFilter.queryFlags = ServerFilter::NewStyleResponse;
dMemcpy( sActiveFilter.buddyList, buddyList, buddyCount * 4 ); dMemcpy( sActiveFilter.buddyList, buddyList, buddyCount * 4 );
clearServerList(); clearServerList();
} }
@ -775,7 +795,7 @@ Vector<MasterInfo>* getMasterServerList()
U32 region = 1; // needs to default to something > 0 U32 region = 1; // needs to default to something > 0
dSscanf(master,"%d:",&region); dSscanf(master,"%d:",&region);
const char* madd = dStrchr(master,':') + 1; const char* madd = dStrchr(master,':') + 1;
if (region && Net::stringToAddress(madd,&address)) { if (region && Net::stringToAddress(madd,&address) == Net::NoError) {
masterList.increment(); masterList.increment();
MasterInfo& info = masterList.last(); MasterInfo& info = masterList.last();
info.address = address; info.address = address;
@ -1171,10 +1191,13 @@ static void processMasterServerQuery( U32 session )
// Send a request to the master server for the server list: // Send a request to the master server for the server list:
BitStream *out = BitStream::getPacketStream(); BitStream *out = BitStream::getPacketStream();
out->clearStringBuffer(); out->clearStringBuffer();
out->write( U8( NetInterface::MasterServerListRequest ) ); out->write( U8( NetInterface::MasterServerListRequest ) );
out->write( U8( sActiveFilter.queryFlags) ); out->write( U8( sActiveFilter.queryFlags) );
out->write( ( gMasterServerPing.session << 16 ) | ( gMasterServerPing.key & 0xFFFF ) ); out->write( ( gMasterServerPing.session << 16 ) | ( gMasterServerPing.key & 0xFFFF ) );
out->write( U8( 255 ) ); out->write( U8( 255 ) );
writeCString( out, sActiveFilter.gameType ); writeCString( out, sActiveFilter.gameType );
writeCString( out, sActiveFilter.missionType ); writeCString( out, sActiveFilter.missionType );
out->write( sActiveFilter.minPlayers ); out->write( sActiveFilter.minPlayers );
@ -1359,23 +1382,35 @@ static void processServerListPackets( U32 session )
if ( !p.tryCount ) if ( !p.tryCount )
{ {
// Packet timed out :( // Packet timed out :(
Con::printf( "Server list packet #%d timed out.", p.index + 1 ); Con::printf( "Server list packet #%d timed out.", p.getIndex() + 1 );
gPacketStatusList.erase( i ); gPacketStatusList.erase( i );
} }
else else
{ {
// Try again... // Try again...
Con::printf( "Rerequesting server list packet #%d...", p.index + 1 ); Con::printf( "Rerequesting server list packet #%d...", p.getIndex() + 1 );
p.tryCount--; p.tryCount--;
p.time = currentTime; p.time = currentTime;
p.key = gKey++; p.key = gKey++;
BitStream *out = BitStream::getPacketStream(); BitStream *out = BitStream::getPacketStream();
bool extendedPacket = (sActiveFilter.queryFlags & ServerFilter::NewStyleResponse) != 0;
out->clearStringBuffer(); out->clearStringBuffer();
out->write( U8( NetInterface::MasterServerListRequest ) );
if ( extendedPacket )
out->write( U8( NetInterface::MasterServerExtendedListRequest ) );
else
out->write( U8( NetInterface::MasterServerListRequest ) );
out->write( U8( sActiveFilter.queryFlags ) ); // flags out->write( U8( sActiveFilter.queryFlags ) ); // flags
out->write( ( session << 16) | ( p.key & 0xFFFF ) ); out->write( ( session << 16) | ( p.key & 0xFFFF ) );
out->write( p.index ); // packet index
if ( extendedPacket )
out->write( p.getOldIndex() ); // packet index
else
out->write( p.getIndex() ); // packet index
out->write( U8( 0 ) ); // game type out->write( U8( 0 ) ); // game type
out->write( U8( 0 ) ); // mission type out->write( U8( 0 ) ); // mission type
out->write( U8( 0 ) ); // minPlayers out->write( U8( 0 ) ); // minPlayers
@ -1569,6 +1604,98 @@ static void handleMasterServerListResponse( BitStream* stream, U32 key, U8 /*fla
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static void handleExtendedMasterServerListResponse(BitStream* stream, U32 key, U8 /*flags*/)
{
U16 packetIndex, packetTotal;
U32 i;
U16 serverCount, port;
U8 netNum[16];
char addressBuffer[256];
NetAddress addr;
stream->read(&packetIndex);
// Validate the packet key:
U32 packetKey = gMasterServerPing.key;
if (gGotFirstListPacket)
{
for (i = 0; i < gPacketStatusList.size(); i++)
{
if (gPacketStatusList[i].index == packetIndex)
{
packetKey = gPacketStatusList[i].key;
break;
}
}
}
U32 testKey = (gPingSession << 16) | (packetKey & 0xFFFF);
if (testKey != key)
return;
stream->read(&packetTotal);
stream->read(&serverCount);
Con::printf("Received server list packet %d of %d from the master server (%d servers).", (packetIndex + 1), packetTotal, serverCount);
// Enter all of the servers in this packet into the ping list:
for (i = 0; i < serverCount; i++)
{
U8 type;
stream->read(&type);
dMemset(&addr, '\0', sizeof(NetAddress));
if (type == 0)
{
// IPV4
addr.type = NetAddress::IPAddress;
stream->read(4, &addr.address.ipv4.netNum[0]);
stream->read(&addr.port);
}
else
{
// IPV6
addr.type = NetAddress::IPV6Address;
stream->read(16, &addr.address.ipv6.netNum[0]);
stream->read(&addr.port);
}
pushPingRequest(&addr);
}
// If this is the first list packet we have received, fill the packet status list
// and start processing:
if (!gGotFirstListPacket)
{
gGotFirstListPacket = true;
gMasterServerQueryAddress = gMasterServerPing.address;
U32 currentTime = Platform::getVirtualMilliseconds();
for (i = 0; i < packetTotal; i++)
{
if (i != packetIndex)
{
PacketStatus* p = new PacketStatus(i, gMasterServerPing.key, currentTime);
gPacketStatusList.push_back(*p);
}
}
processServerListPackets(gPingSession);
}
else
{
// Remove the packet we just received from the status list:
for (i = 0; i < gPacketStatusList.size(); i++)
{
if (gPacketStatusList[i].index == packetIndex)
{
gPacketStatusList.erase(i);
break;
}
}
}
}
//-----------------------------------------------------------------------------
static void handleGameMasterInfoRequest( const NetAddress* address, U32 key, U8 flags ) static void handleGameMasterInfoRequest( const NetAddress* address, U32 key, U8 flags )
{ {
if ( GNet->doesAllowConnections() ) if ( GNet->doesAllowConnections() )
@ -1585,7 +1712,7 @@ static void handleGameMasterInfoRequest( const NetAddress* address, U32 key, U8
for(U32 i = 0; i < masterList->size(); i++) for(U32 i = 0; i < masterList->size(); i++)
{ {
masterAddr = &(*masterList)[i].address; masterAddr = &(*masterList)[i].address;
if (*(U32*)(masterAddr->netNum) == *(U32*)(address->netNum)) if (masterAddr->isSameAddress(*address))
{ {
fromMaster = true; fromMaster = true;
break; break;
@ -2098,6 +2225,10 @@ void DemoNetInterface::handleInfoPacket( const NetAddress* address, U8 packetTyp
case GameMasterInfoRequest: case GameMasterInfoRequest:
handleGameMasterInfoRequest( address, key, flags ); handleGameMasterInfoRequest( address, key, flags );
break; break;
case MasterServerExtendedListResponse:
handleExtendedMasterServerListResponse(stream, key, flags);
break;
} }
} }

View file

@ -170,8 +170,8 @@ IMPLEMENT_CALLBACK(TCPObject, onDisconnect, void, (),(),
TCPObject *TCPObject::find(NetSocket tag) TCPObject *TCPObject::find(NetSocket tag)
{ {
for(TCPObject *walk = table[U32(tag) & TableMask]; walk; walk = walk->mNext) for(TCPObject *walk = table[tag.getHash() & TableMask]; walk; walk = walk->mNext)
if(walk->mTag == tag) if(walk->mTag.getHash() == tag.getHash())
return walk; return walk;
return NULL; return NULL;
} }
@ -180,13 +180,13 @@ void TCPObject::addToTable(NetSocket newTag)
{ {
removeFromTable(); removeFromTable();
mTag = newTag; mTag = newTag;
mNext = table[U32(mTag) & TableMask]; mNext = table[mTag.getHash() & TableMask];
table[U32(mTag) & TableMask] = this; table[mTag.getHash() & TableMask] = this;
} }
void TCPObject::removeFromTable() void TCPObject::removeFromTable()
{ {
for(TCPObject **walk = &table[U32(mTag) & TableMask]; *walk; walk = &((*walk)->mNext)) for(TCPObject **walk = &table[mTag.getHash() & TableMask]; *walk; walk = &((*walk)->mNext))
{ {
if(*walk == this) if(*walk == this)
{ {
@ -207,7 +207,7 @@ TCPObject::TCPObject()
mBuffer = NULL; mBuffer = NULL;
mBufferSize = 0; mBufferSize = 0;
mPort = 0; mPort = 0;
mTag = InvalidSocket; mTag = NetSocket::INVALID;
mNext = NULL; mNext = NULL;
mState = Disconnected; mState = Disconnected;
@ -215,9 +215,9 @@ TCPObject::TCPObject()
if(gTCPCount == 1) if(gTCPCount == 1)
{ {
Net::smConnectionAccept.notify(processConnectedAcceptEvent); Net::getConnectionAcceptedEvent().notify(processConnectedAcceptEvent);
Net::smConnectionReceive.notify(processConnectedReceiveEvent); Net::getConnectionReceiveEvent().notify(processConnectedReceiveEvent);
Net::smConnectionNotify.notify(processConnectedNotifyEvent); Net::getConnectionNotifyEvent().notify(processConnectedNotifyEvent);
} }
} }
@ -230,9 +230,9 @@ TCPObject::~TCPObject()
if(gTCPCount == 0) if(gTCPCount == 0)
{ {
Net::smConnectionAccept.remove(processConnectedAcceptEvent); Net::getConnectionAcceptedEvent().remove(processConnectedAcceptEvent);
Net::smConnectionReceive.remove(processConnectedReceiveEvent); Net::getConnectionReceiveEvent().remove(processConnectedReceiveEvent);
Net::smConnectionNotify.remove(processConnectedNotifyEvent); Net::getConnectionNotifyEvent().remove(processConnectedNotifyEvent);
} }
} }
@ -242,7 +242,7 @@ bool TCPObject::processArguments(S32 argc, ConsoleValueRef *argv)
return true; return true;
else if(argc == 1) else if(argc == 1)
{ {
addToTable(U32(dAtoi(argv[0]))); addToTable(NetSocket::fromHandle(dAtoi(argv[0])));
return true; return true;
} }
return false; return false;
@ -406,7 +406,7 @@ void TCPObject::onDisconnect()
void TCPObject::listen(U16 port) void TCPObject::listen(U16 port)
{ {
mState = Listening; mState = Listening;
U32 newTag = Net::openListenPort(port); NetSocket newTag = Net::openListenPort(port);
addToTable(newTag); addToTable(newTag);
} }
@ -418,7 +418,7 @@ void TCPObject::connect(const char *address)
void TCPObject::disconnect() void TCPObject::disconnect()
{ {
if( mTag != InvalidSocket ) { if( mTag != NetSocket::INVALID ) {
Net::closeConnectTo(mTag); Net::closeConnectTo(mTag);
} }
removeFromTable(); removeFromTable();
@ -592,7 +592,7 @@ void processConnectedAcceptEvent(NetSocket listeningPort, NetSocket newConnectio
if(!tcpo) if(!tcpo)
return; return;
tcpo->onConnectionRequest(&originatingAddress, newConnection); tcpo->onConnectionRequest(&originatingAddress, (U32)newConnection.getHandle());
} }
void processConnectedNotifyEvent( NetSocket sock, U32 state ) void processConnectedNotifyEvent( NetSocket sock, U32 state )

View file

@ -44,7 +44,7 @@
#define TORQUE_GAME_ENGINE 3900 #define TORQUE_GAME_ENGINE 3900
/// Human readable engine version string. /// Human readable engine version string.
#define TORQUE_GAME_ENGINE_VERSION_STRING "3.10.0" #define TORQUE_GAME_ENGINE_VERSION_STRING "3.9.0"
/// Gets the engine version number. The version number is specified as a global in version.cc /// Gets the engine version number. The version number is specified as a global in version.cc
U32 getVersionNumber(); U32 getVersionNumber();

View file

@ -84,7 +84,7 @@ TelnetConsole::TelnetConsole()
{ {
Con::addConsumer(telnetCallback); Con::addConsumer(telnetCallback);
mAcceptSocket = InvalidSocket; mAcceptSocket = NetSocket::INVALID;
mAcceptPort = -1; mAcceptPort = -1;
mClientList = NULL; mClientList = NULL;
mRemoteEchoEnabled = false; mRemoteEchoEnabled = false;
@ -93,13 +93,13 @@ TelnetConsole::TelnetConsole()
TelnetConsole::~TelnetConsole() TelnetConsole::~TelnetConsole()
{ {
Con::removeConsumer(telnetCallback); Con::removeConsumer(telnetCallback);
if(mAcceptSocket != InvalidSocket) if(mAcceptSocket != NetSocket::INVALID)
Net::closeSocket(mAcceptSocket); Net::closeSocket(mAcceptSocket);
TelnetClient *walk = mClientList, *temp; TelnetClient *walk = mClientList, *temp;
while(walk) while(walk)
{ {
temp = walk->nextClient; temp = walk->nextClient;
if(walk->socket != InvalidSocket) if(walk->socket != NetSocket::INVALID)
Net::closeSocket(walk->socket); Net::closeSocket(walk->socket);
delete walk; delete walk;
walk = temp; walk = temp;
@ -113,16 +113,20 @@ void TelnetConsole::setTelnetParameters(S32 port, const char *telnetPassword, co
mRemoteEchoEnabled = remoteEcho; mRemoteEchoEnabled = remoteEcho;
if(mAcceptSocket != InvalidSocket) if(mAcceptSocket != NetSocket::INVALID)
{ {
Net::closeSocket(mAcceptSocket); Net::closeSocket(mAcceptSocket);
mAcceptSocket = InvalidSocket; mAcceptSocket = NetSocket::INVALID;
} }
mAcceptPort = port; mAcceptPort = port;
if(mAcceptPort != -1 && mAcceptPort != 0) if(mAcceptPort != -1 && mAcceptPort != 0)
{ {
NetAddress address;
Net::getIdealListenAddress(&address);
address.port = mAcceptPort;
mAcceptSocket = Net::openSocket(); mAcceptSocket = Net::openSocket();
Net::bind(mAcceptSocket, mAcceptPort); Net::bindAddress(address, mAcceptSocket);
Net::listen(mAcceptSocket, 4); Net::listen(mAcceptSocket, 4);
Net::setBlocking(mAcceptSocket, false); Net::setBlocking(mAcceptSocket, false);
@ -151,16 +155,17 @@ void TelnetConsole::process()
{ {
NetAddress address; NetAddress address;
if(mAcceptSocket != InvalidSocket) if(mAcceptSocket != NetSocket::INVALID)
{ {
// ok, see if we have any new connections: // ok, see if we have any new connections:
NetSocket newConnection; NetSocket newConnection;
newConnection = Net::accept(mAcceptSocket, &address); newConnection = Net::accept(mAcceptSocket, &address);
if(newConnection != InvalidSocket) if(newConnection != NetSocket::INVALID)
{ {
Con::printf ("Telnet connection from %i.%i.%i.%i", char buffer[256];
address.netNum[0], address.netNum[1], address.netNum[2], address.netNum[3]); Net::addressToString(&address, buffer);
Con::printf("Telnet connection from %s", buffer);
TelnetClient *cl = new TelnetClient; TelnetClient *cl = new TelnetClient;
cl->socket = newConnection; cl->socket = newConnection;
@ -201,7 +206,7 @@ void TelnetConsole::process()
if((err != Net::NoError && err != Net::WouldBlock) || numBytes == 0) if((err != Net::NoError && err != Net::WouldBlock) || numBytes == 0)
{ {
Net::closeSocket(client->socket); Net::closeSocket(client->socket);
client->socket = InvalidSocket; client->socket = NetSocket::INVALID;
continue; continue;
} }
@ -274,7 +279,7 @@ void TelnetConsole::process()
if(client->state == DisconnectThisDude) if(client->state == DisconnectThisDude)
{ {
Net::closeSocket(client->socket); Net::closeSocket(client->socket);
client->socket = InvalidSocket; client->socket = NetSocket::INVALID;
} }
} }
} }
@ -312,7 +317,7 @@ void TelnetConsole::process()
TelnetClient *cl; TelnetClient *cl;
while((cl = *walk) != NULL) while((cl = *walk) != NULL)
{ {
if(cl->socket == InvalidSocket) if(cl->socket == NetSocket::INVALID)
{ {
*walk = cl->nextClient; *walk = cl->nextClient;
delete cl; delete cl;

View file

@ -151,8 +151,8 @@ TelnetDebugger::TelnetDebugger()
Con::addConsumer(debuggerConsumer); Con::addConsumer(debuggerConsumer);
mAcceptPort = -1; mAcceptPort = -1;
mAcceptSocket = InvalidSocket; mAcceptSocket = NetSocket::INVALID;
mDebugSocket = InvalidSocket; mDebugSocket = NetSocket::INVALID;
mState = NotConnected; mState = NotConnected;
mCurPos = 0; mCurPos = 0;
@ -189,9 +189,9 @@ TelnetDebugger::~TelnetDebugger()
{ {
Con::removeConsumer(debuggerConsumer); Con::removeConsumer(debuggerConsumer);
if(mAcceptSocket != InvalidSocket) if(mAcceptSocket != NetSocket::INVALID)
Net::closeSocket(mAcceptSocket); Net::closeSocket(mAcceptSocket);
if(mDebugSocket != InvalidSocket) if(mDebugSocket != NetSocket::INVALID)
Net::closeSocket(mDebugSocket); Net::closeSocket(mDebugSocket);
} }
@ -217,10 +217,10 @@ void TelnetDebugger::send(const char *str)
void TelnetDebugger::disconnect() void TelnetDebugger::disconnect()
{ {
if ( mDebugSocket != InvalidSocket ) if ( mDebugSocket != NetSocket::INVALID )
{ {
Net::closeSocket(mDebugSocket); Net::closeSocket(mDebugSocket);
mDebugSocket = InvalidSocket; mDebugSocket = NetSocket::INVALID;
} }
removeAllBreakpoints(); removeAllBreakpoints();
@ -236,16 +236,20 @@ void TelnetDebugger::setDebugParameters(S32 port, const char *password, bool wai
// if(port == mAcceptPort) // if(port == mAcceptPort)
// return; // return;
if(mAcceptSocket != InvalidSocket) if(mAcceptSocket != NetSocket::INVALID)
{ {
Net::closeSocket(mAcceptSocket); Net::closeSocket(mAcceptSocket);
mAcceptSocket = InvalidSocket; mAcceptSocket = NetSocket::INVALID;
} }
mAcceptPort = port; mAcceptPort = port;
if(mAcceptPort != -1 && mAcceptPort != 0) if(mAcceptPort != -1 && mAcceptPort != 0)
{ {
NetAddress address;
Net::getIdealListenAddress(&address);
address.port = mAcceptPort;
mAcceptSocket = Net::openSocket(); mAcceptSocket = Net::openSocket();
Net::bind(mAcceptSocket, mAcceptPort); Net::bindAddress(address, mAcceptSocket);
Net::listen(mAcceptSocket, 4); Net::listen(mAcceptSocket, 4);
Net::setBlocking(mAcceptSocket, false); Net::setBlocking(mAcceptSocket, false);
@ -279,32 +283,33 @@ void TelnetDebugger::process()
{ {
NetAddress address; NetAddress address;
if(mAcceptSocket != InvalidSocket) if(mAcceptSocket != NetSocket::INVALID)
{ {
// ok, see if we have any new connections: // ok, see if we have any new connections:
NetSocket newConnection; NetSocket newConnection;
newConnection = Net::accept(mAcceptSocket, &address); newConnection = Net::accept(mAcceptSocket, &address);
if(newConnection != InvalidSocket && mDebugSocket == InvalidSocket) if(newConnection != NetSocket::INVALID && mDebugSocket == NetSocket::INVALID)
{ {
Con::printf ("Debugger connection from %i.%i.%i.%i", char buffer[256];
address.netNum[0], address.netNum[1], address.netNum[2], address.netNum[3]); Net::addressToString(&address, buffer);
Con::printf("Debugger connection from %s", buffer);
mState = PasswordTry; mState = PasswordTry;
mDebugSocket = newConnection; mDebugSocket = newConnection;
Net::setBlocking(newConnection, false); Net::setBlocking(newConnection, false);
} }
else if(newConnection != InvalidSocket) else if(newConnection != NetSocket::INVALID)
Net::closeSocket(newConnection); Net::closeSocket(newConnection);
} }
// see if we have any input to process... // see if we have any input to process...
if(mDebugSocket == InvalidSocket) if(mDebugSocket == NetSocket::INVALID)
return; return;
checkDebugRecv(); checkDebugRecv();
if(mDebugSocket == InvalidSocket) if(mDebugSocket == NetSocket::INVALID)
removeAllBreakpoints(); removeAllBreakpoints();
} }
@ -434,7 +439,7 @@ void TelnetDebugger::breakProcess()
{ {
Platform::sleep(10); Platform::sleep(10);
checkDebugRecv(); checkDebugRecv();
if(mDebugSocket == InvalidSocket) if(mDebugSocket == NetSocket::INVALID)
{ {
mProgramPaused = false; mProgramPaused = false;
removeAllBreakpoints(); removeAllBreakpoints();

View file

@ -300,16 +300,7 @@ bool Stream::write(const NetAddress &na)
{ {
bool success = write(na.type); bool success = write(na.type);
success &= write(na.port); success &= write(na.port);
success &= write(na.netNum[0]); success &= write(sizeof(na.address), &na.address);
success &= write(na.netNum[1]);
success &= write(na.netNum[2]);
success &= write(na.netNum[3]);
success &= write(na.nodeNum[0]);
success &= write(na.nodeNum[1]);
success &= write(na.nodeNum[2]);
success &= write(na.nodeNum[3]);
success &= write(na.nodeNum[4]);
success &= write(na.nodeNum[5]);
return success; return success;
} }
@ -317,16 +308,20 @@ bool Stream::read(NetAddress *na)
{ {
bool success = read(&na->type); bool success = read(&na->type);
success &= read(&na->port); success &= read(&na->port);
success &= read(&na->netNum[0]); success &= read(sizeof(na->address), &na->address);
success &= read(&na->netNum[1]); return success;
success &= read(&na->netNum[2]); }
success &= read(&na->netNum[3]);
success &= read(&na->nodeNum[0]); bool Stream::write(const NetSocket &so)
success &= read(&na->nodeNum[1]); {
success &= read(&na->nodeNum[2]); return write(so.getHandle());
success &= read(&na->nodeNum[3]); }
success &= read(&na->nodeNum[4]);
success &= read(&na->nodeNum[5]); bool Stream::read(NetSocket* so)
{
S32 handle = -1;
bool success = read(&handle);
*so = NetSocket::fromHandle(handle);
return success; return success;
} }

View file

@ -45,6 +45,7 @@ class ColorF;
struct NetAddress; struct NetAddress;
class RawData; class RawData;
class String; class String;
class NetSocket;
namespace Torque { namespace Torque {
class ByteBuffer; class ByteBuffer;
@ -165,6 +166,11 @@ public:
/// Read a network address from the stream. /// Read a network address from the stream.
bool read(NetAddress*); bool read(NetAddress*);
/// Write a network socket to the stream.
bool write(const NetSocket &);
/// Read a network socket from the stream.
bool read(NetSocket*);
/// Write some raw data onto the stream. /// Write some raw data onto the stream.
bool write(const RawData &); bool write(const RawData &);
/// Read some raw data from the stream. /// Read some raw data from the stream.

View file

@ -400,6 +400,32 @@ ConsoleDocClass( GuiInspectorTypeCheckBox,
GuiControl* GuiInspectorTypeCheckBox::constructEditControl() GuiControl* GuiInspectorTypeCheckBox::constructEditControl()
{ {
if ( mField->flag.test(AbstractClassRep::FieldFlags::FIELD_ComponentInspectors) )
{
// This checkbox (bool field) is meant to be treated as a button.
GuiControl* retCtrl = new GuiButtonCtrl();
// If we couldn't construct the control, bail!
if( retCtrl == NULL )
return retCtrl;
GuiButtonCtrl *button = dynamic_cast<GuiButtonCtrl*>(retCtrl);
// Let's make it look pretty.
retCtrl->setDataField( StringTable->insert("profile"), NULL, "InspectorTypeButtonProfile" );
retCtrl->setField( "text", "Click Here" );
retCtrl->setScriptValue( getData() );
_registerEditControl( retCtrl );
// Configure it to update our value when the popup is closed
char szBuffer[512];
dSprintf( szBuffer, 512, "%d.apply(%d.getValue());",getId(), button->getId() );
button->setField("Command", szBuffer );
return retCtrl;
} else {
GuiControl* retCtrl = new GuiCheckBoxCtrl(); GuiControl* retCtrl = new GuiCheckBoxCtrl();
GuiCheckBoxCtrl *check = dynamic_cast<GuiCheckBoxCtrl*>(retCtrl); GuiCheckBoxCtrl *check = dynamic_cast<GuiCheckBoxCtrl*>(retCtrl);
@ -420,6 +446,7 @@ GuiControl* GuiInspectorTypeCheckBox::constructEditControl()
check->setField("Command", szBuffer ); check->setField("Command", szBuffer );
return retCtrl; return retCtrl;
}
} }

View file

@ -304,13 +304,16 @@ bool LightShadowMap::setTextureStage( U32 currTexFlag, LightingShaderConstants*
return false; return false;
} }
void LightShadowMap::render( RenderPassManager* renderPass, void LightShadowMap::render(RenderPassManager* renderPass,
const SceneRenderState *diffuseState, const SceneRenderState *diffuseState,
bool _dynamic) bool _dynamic, bool _forceUpdate)
{ {
// control how often shadow maps are refreshed if (!_forceUpdate)
if (!_dynamic && (mStaticRefreshTimer->getElapsedMs() < getLightInfo()->getStaticRefreshFreq())) {
return; // control how often shadow maps are refreshed
if (!_dynamic && (mStaticRefreshTimer->getElapsedMs() < getLightInfo()->getStaticRefreshFreq()))
return;
}
mStaticRefreshTimer->reset(); mStaticRefreshTimer->reset();
/* TODO: find out why this is causing issue with translucent objects /* TODO: find out why this is causing issue with translucent objects

View file

@ -163,7 +163,7 @@ public:
void render( RenderPassManager* renderPass, void render( RenderPassManager* renderPass,
const SceneRenderState *diffuseState, const SceneRenderState *diffuseState,
bool _dynamic); bool _dynamic, bool _forceUpdate);
U32 getLastUpdate() const { return mLastUpdate; } U32 getLastUpdate() const { return mLastUpdate; }

View file

@ -78,6 +78,16 @@ AFTER_MODULE_INIT( Sim )
Con::NotifyDelegate shadowCallback( &ShadowMapManager::updateShadowDisable ); Con::NotifyDelegate shadowCallback( &ShadowMapManager::updateShadowDisable );
Con::addVariableNotify( "$pref::Shadows::disable", shadowCallback ); Con::addVariableNotify( "$pref::Shadows::disable", shadowCallback );
Con::addVariableNotify( "$Shadows::disable", shadowCallback ); Con::addVariableNotify( "$Shadows::disable", shadowCallback );
Con::addVariable("$pref::Shadows::teleportDist",
TypeF32, &ShadowMapPass::smShadowsTeleportDist,
"Minimum distance moved per frame to determine that we are teleporting.\n");
Con::addVariableNotify("$pref::Shadows::teleportDist", shadowCallback);
Con::addVariable("$pref::Shadows::turnRate",
TypeF32, &ShadowMapPass::smShadowsTurnRate,
"Minimum angle moved per frame to determine that we are turning quickly.\n");
Con::addVariableNotify("$pref::Shadows::turnRate", shadowCallback);
} }
Signal<void(void)> ShadowMapManager::smShadowDeactivateSignal; Signal<void(void)> ShadowMapManager::smShadowDeactivateSignal;

View file

@ -39,6 +39,7 @@
#include "gfx/gfxDebugEvent.h" #include "gfx/gfxDebugEvent.h"
#include "platform/platformTimer.h" #include "platform/platformTimer.h"
#include "T3D/gameBase/gameConnection.h"
const String ShadowMapPass::PassTypeName("ShadowMap"); const String ShadowMapPass::PassTypeName("ShadowMap");
@ -55,11 +56,10 @@ bool ShadowMapPass::smDisableShadows = false;
bool ShadowMapPass::smDisableShadowsEditor = false; bool ShadowMapPass::smDisableShadowsEditor = false;
bool ShadowMapPass::smDisableShadowsPref = false; bool ShadowMapPass::smDisableShadowsPref = false;
/// milliseconds before static redraw /// distance moved per frame before forcing a shadow update
S32 ShadowMapPass::smStaticShadowUpdateFreq = 32; F32 ShadowMapPass::smShadowsTeleportDist = 4;
/// milliseconds before dynamic redraw /// angle turned per frame before forcing a shadow update
S32 ShadowMapPass::smDynamicShadowUpdateFreq = 16; F32 ShadowMapPass::smShadowsTurnRate = 1;
/// We have a default 8ms render budget for shadow rendering. /// We have a default 8ms render budget for shadow rendering.
U32 ShadowMapPass::smRenderBudgetMs = 8; U32 ShadowMapPass::smRenderBudgetMs = 8;
@ -89,7 +89,8 @@ ShadowMapPass::ShadowMapPass(LightManager* lightManager, ShadowMapManager* shado
mDynamicShadowRPM->addManager( new RenderImposterMgr( 0.6f, 0.6f ) ); mDynamicShadowRPM->addManager( new RenderImposterMgr( 0.6f, 0.6f ) );
mActiveLights = 0; mActiveLights = 0;
mPrevCamPos = Point3F::Zero;
mPrevCamRot = Point3F::Zero;
mTimer = PlatformTimer::create(); mTimer = PlatformTimer::create();
Con::addVariable( "$ShadowStats::activeMaps", TypeS32, &smActiveShadowMaps, Con::addVariable( "$ShadowStats::activeMaps", TypeS32, &smActiveShadowMaps,
@ -214,6 +215,28 @@ void ShadowMapPass::render( SceneManager *sceneManager,
mTimer->getElapsedMs(); mTimer->getElapsedMs();
mTimer->reset(); mTimer->reset();
// Must have a connection and control object
GameConnection* conn = GameConnection::getConnectionToServer();
if (!conn)
return;
GameBase * control = dynamic_cast<GameBase*>(conn->getControlObject());
if (!control)
return;
bool forceUpdate = false;
//force an update if we're jumping around (respawning, ect)
MatrixF curCamMatrix = control->getTransform();
if (((curCamMatrix.getPosition() - mPrevCamPos).lenSquared() > mPow(smShadowsTeleportDist, 2)) || //update if we're teleporting
((curCamMatrix.getForwardVector() - mPrevCamRot).lenSquared() > mPow(smShadowsTurnRate*M_PI_F / 180, 2)) || //update if we're turning too fast
(control->getCameraFov()) != mPrevCamFov) //update if we're zooming or unzooming
forceUpdate = true;
mPrevCamRot = curCamMatrix.getForwardVector();
mPrevCamPos = curCamMatrix.getPosition();
mPrevCamFov = control->getCameraFov();
// 2 Shadow Maps per Light. This may fail. // 2 Shadow Maps per Light. This may fail.
for ( U32 i = 0; i < shadowMaps.size(); i += 2 ) for ( U32 i = 0; i < shadowMaps.size(); i += 2 )
{ {
@ -226,8 +249,8 @@ void ShadowMapPass::render( SceneManager *sceneManager,
mShadowManager->setLightShadowMap(lsm); mShadowManager->setLightShadowMap(lsm);
mShadowManager->setLightDynamicShadowMap( dlsm ); mShadowManager->setLightDynamicShadowMap( dlsm );
lsm->render(mShadowRPM, diffuseState, false); lsm->render(mShadowRPM, diffuseState, false, forceUpdate);
dlsm->render(mDynamicShadowRPM, diffuseState, true); dlsm->render(mDynamicShadowRPM, diffuseState, true, forceUpdate);
++smUpdatedShadowMaps; ++smUpdatedShadowMaps;
} }

View file

@ -84,10 +84,10 @@ public:
static bool smDisableShadowsEditor; static bool smDisableShadowsEditor;
static bool smDisableShadowsPref; static bool smDisableShadowsPref;
/// milliseconds before static redraw /// distance moved per frame before forcing a shadow update
static S32 smStaticShadowUpdateFreq; static F32 smShadowsTeleportDist;
/// milliseconds before dynamic redraw /// angle turned per frame before forcing a shadow update
static S32 smDynamicShadowUpdateFreq; static F32 smShadowsTurnRate;
private: private:
@ -112,6 +112,9 @@ private:
SimObjectPtr<DynamicShadowRenderPassManager> mDynamicShadowRPM; SimObjectPtr<DynamicShadowRenderPassManager> mDynamicShadowRPM;
LightManager* mLightManager; LightManager* mLightManager;
ShadowMapManager* mShadowManager; ShadowMapManager* mShadowManager;
Point3F mPrevCamPos;
Point3F mPrevCamRot;
F32 mPrevCamFov;
}; };
class ShadowRenderPassManager : public RenderPassManager class ShadowRenderPassManager : public RenderPassManager

View file

@ -25,6 +25,8 @@
#include "console/console.h" #include "console/console.h"
#include "math/mMathFn.h" #include "math/mMathFn.h"
#include "math/mRandom.h" #include "math/mRandom.h"
#include "math/mMath.h"
#include "math/mathUtils.h"
#include "console/engineAPI.h" #include "console/engineAPI.h"
@ -341,3 +343,33 @@ DefineConsoleFunction( mIsPow2, bool, ( S32 v ),,
{ {
return isPow2( v ); return isPow2( v );
} }
DefineConsoleFunction( mRandomDir, Point3F, (Point3F axis, F32 angleMin, F32 angleMax),,
"Returns a randomized direction based on a starting axis and the min/max angles.\n"
"@param axis Main axis to deviate the direction from."
"@param angleMin minimum amount of deviation from the axis."
"@param angleMax maximum amount of deviation from the axis."
"@returns Randomized direction vector."
"@ingroup Math")
{
return MathUtils::randomDir(axis, angleMin, angleMax);
}
DefineConsoleFunction( mRandomPointInSphere, Point3F, (F32 radius), ,
"Returns a randomized point inside a sphere of a given radius.\n"
"@param radius The radius of the sphere to find a point in."
"@returns Randomized point inside a sphere."
"@ingroup Math")
{
return MathUtils::randomPointInSphere(radius);
}
DefineConsoleFunction( mGetAngleBetweenVectors, F32, (VectorF vecA, VectorF vecB), ,
"Returns angle between two vectors.\n"
"@param vecA First input vector."
"@param vecB Second input vector."
"@returns Angle between both vectors in radians."
"@ingroup Math")
{
return MathUtils::getAngleBetweenVectors(vecA, vecB);
}

View file

@ -22,6 +22,7 @@
#include "math/mRotation.h" #include "math/mRotation.h"
#include "console/console.h" #include "console/console.h"
#include "console/engineAPI.h" #include "console/engineAPI.h"
#include "math/mathUtils.h"
#ifdef TORQUE_TESTS_ENABLED #ifdef TORQUE_TESTS_ENABLED
#include "testing/unitTesting.h" #include "testing/unitTesting.h"
@ -187,6 +188,15 @@ void RotationF::lookAt(const Point3F& _origin, const Point3F& _target, const Poi
set(mat); set(mat);
} }
VectorF RotationF::getDirection()
{
VectorF dir;
EulerF angles = asEulerF();
MathUtils::getVectorFromAngles(dir, angles.z, angles.x);
return dir;
}
//======================================================== //========================================================
EulerF RotationF::asEulerF(UnitFormat _format) const EulerF RotationF::asEulerF(UnitFormat _format) const
{ {
@ -346,3 +356,12 @@ DefineConsoleStaticMethod(rotation, LookAt, RotationF, (Point3F origin, Point3F
result.lookAt(origin, target, up); result.lookAt(origin, target, up);
return result; return result;
} }
DefineConsoleStaticMethod(rotation, getDirection, Point3F, (RotationF rot),,
"Takes the angles of the provided rotation and returns a direction vector.\n"
"@param rot Our rotation."
"@returns v Direction vector result."
"@ingroup Math")
{
return rot.getDirection();
}

View file

@ -132,6 +132,7 @@ public:
// //
void interpolate(const RotationF& _pt1, const RotationF& _pt2, F32 _factor); void interpolate(const RotationF& _pt1, const RotationF& _pt2, F32 _factor);
void lookAt(const Point3F& _origin, const Point3F& _target, const Point3F& _up = Point3F(0, 0, 1)); void lookAt(const Point3F& _origin, const Point3F& _target, const Point3F& _up = Point3F(0, 0, 1));
VectorF getDirection();
F32 len() const; F32 len() const;

View file

@ -1032,6 +1032,18 @@ DefineConsoleFunction( VectorLerp, VectorF, ( VectorF a, VectorF b, F32 t ),,
return c; return c;
} }
DefineConsoleFunction(VectorReflect, VectorF, (VectorF vec, VectorF normal), ,
"Compute the reflection of a vector based on a normal.\n"
"@param a The vector.\n"
"@param b The normal.\n"
"@return The reflected vector.\n\n"
"@ingroup Vectors")
{
normal.normalize();
return MathUtils::reflect(vec, normal);
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
DefineConsoleFunction( MatrixCreate, TransformF, ( VectorF position, AngAxisF orientation ),, DefineConsoleFunction( MatrixCreate, TransformF, ( VectorF position, AngAxisF orientation ),,

View file

@ -361,6 +361,16 @@ void getVectorFromAngles( VectorF &vec, F32 yawAng, F32 pitchAng )
vec = pnt; vec = pnt;
} }
F32 getAngleBetweenVectors(VectorF vecA, VectorF vecB)
{
F32 dot = mDot(vecA, vecB);
F32 lenSq1 = vecA.lenSquared();
F32 lenSq2 = vecB.lenSquared();
F32 angle = mAcos(dot / mSqrt(lenSq1 * lenSq2));
return angle;
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void transformBoundingBox(const Box3F &sbox, const MatrixF &mat, const Point3F scale, Box3F &dbox) void transformBoundingBox(const Box3F &sbox, const MatrixF &mat, const Point3F scale, Box3F &dbox)

View file

@ -155,6 +155,13 @@ namespace MathUtils
/// <b>ASSUMES Z AXIS IS UP</b> /// <b>ASSUMES Z AXIS IS UP</b>
void getVectorFromAngles( VectorF &vec, F32 yawAng, F32 pitchAng ); void getVectorFromAngles( VectorF &vec, F32 yawAng, F32 pitchAng );
/// Returns the angle between two given vectors
///
/// Angles is in RADIANS
///
F32 getAngleBetweenVectors(VectorF vecA, VectorF vecB);
/// Simple reflection equation - pass in a vector and a normal to reflect off of /// Simple reflection equation - pass in a vector and a normal to reflect off of
inline Point3F reflect( Point3F &inVec, Point3F &norm ) inline Point3F reflect( Point3F &inVec, Point3F &norm )
{ {

View file

@ -838,7 +838,7 @@ void NavMesh::buildNextTile()
ctx->stopTimer(RC_TIMER_TOTAL); ctx->stopTimer(RC_TIMER_TOTAL);
if(getEventManager()) if(getEventManager())
{ {
String str = String::ToString("%d %.3f", getId(), ctx->getAccumulatedTime(RC_TIMER_TOTAL) / 1000.0f); String str = String::ToString("%d", getId());
getEventManager()->postEvent("NavMeshUpdate", str.c_str()); getEventManager()->postEvent("NavMeshUpdate", str.c_str());
setMaskBits(LoadFlag); setMaskBits(LoadFlag);
} }

File diff suppressed because it is too large Load diff

View file

@ -31,6 +31,8 @@
#define MAXPACKETSIZE 1500 #define MAXPACKETSIZE 1500
#endif #endif
#define TORQUE_NET_DEFAULT_MULTICAST_ADDRESS "ff04::7467::656E::6574::776B"
typedef S32 NetConnectionId; typedef S32 NetConnectionId;
/// Generic network address /// Generic network address
@ -41,18 +43,130 @@ struct NetAddress
S32 type; ///< Type of address (IPAddress currently) S32 type; ///< Type of address (IPAddress currently)
/// Acceptable NetAddress types. /// Acceptable NetAddress types.
enum enum Type
{ {
IPAddress, IPAddress,
IPV6Address,
IPBroadcastAddress,
IPV6MulticastAddress
}; };
U8 netNum[4]; ///< For IP: sin_addr<br> union
U8 nodeNum[6]; ///< For IP: Not used.<br> {
U16 port; ///< For IP: sin_port<br> struct {
U8 netNum[4];
} ipv4;
struct {
U8 netNum[16];
U32 netFlow;
U32 netScope;
} ipv6;
struct {
U8 netNum[16];
U8 netFlow[4];
U8 netScope[4];
} ipv6_raw;
} address;
U16 port;
bool isSameAddress(const NetAddress &other) const
{
if (type != other.type)
return false;
switch (type)
{
case NetAddress::IPAddress:
return (dMemcmp(other.address.ipv4.netNum, address.ipv4.netNum, 4) == 0);
break;
case NetAddress::IPV6Address:
return (dMemcmp(other.address.ipv6.netNum, address.ipv6.netNum, 16) == 0);
break;
case NetAddress::IPBroadcastAddress:
return true;
break;
case NetAddress::IPV6MulticastAddress:
return true;
break;
}
return false;
}
bool isSameAddressAndPort(const NetAddress &other) const
{
if (type != other.type)
return false;
switch (type)
{
case NetAddress::IPAddress:
return (dMemcmp(other.address.ipv4.netNum, address.ipv4.netNum, 4) == 0) && other.port == port;
break;
case NetAddress::IPV6Address:
return (dMemcmp(other.address.ipv6.netNum, address.ipv6.netNum, 16) == 0) && other.port == port;
break;
case NetAddress::IPBroadcastAddress:
return true;
break;
case NetAddress::IPV6MulticastAddress:
return true;
break;
}
return false;
}
bool isEqual(const NetAddress &other) const
{
if (type != other.type)
return false;
switch (type)
{
case NetAddress::IPAddress:
return other.port == port && (dMemcmp(other.address.ipv4.netNum, address.ipv4.netNum, 4) == 0);
break;
case NetAddress::IPV6Address:
return other.port == port && other.address.ipv6.netFlow == address.ipv6.netFlow && other.address.ipv6.netScope == address.ipv6.netScope && (dMemcmp(other.address.ipv6.netNum, address.ipv6.netNum, 16) == 0);
break;
case NetAddress::IPBroadcastAddress:
return other.port == port;
break;
case NetAddress::IPV6MulticastAddress:
return other.port == port;
break;
}
return false;
}
U32 getHash() const;
}; };
typedef S32 NetSocket; class NetSocket
const NetSocket InvalidSocket = -1; {
protected:
S32 mHandle;
public:
NetSocket() : mHandle(-1) { ; }
inline void setHandle(S32 handleId) { mHandle = handleId; }
inline S32 getHandle() const { return mHandle; }
inline U32 getHash() const { return mHandle; }
bool operator==(const NetSocket &other) const { return mHandle == other.mHandle; }
bool operator!=(const NetSocket &other) const { return mHandle != other.mHandle; }
static NetSocket fromHandle(S32 handleId) { NetSocket ret; ret.mHandle = handleId; return ret; }
static NetSocket INVALID;
};
/// void event(NetSocket sock, U32 state) /// void event(NetSocket sock, U32 state)
typedef JournaledSignal<void(NetSocket,U32)> ConnectionNotifyEvent; typedef JournaledSignal<void(NetSocket,U32)> ConnectionNotifyEvent;
@ -76,7 +190,8 @@ struct Net
InvalidPacketProtocol, InvalidPacketProtocol,
WouldBlock, WouldBlock,
NotASocket, NotASocket,
UnknownError UnknownError,
NeedHostLookup
}; };
enum ConnectionState { enum ConnectionState {
@ -87,18 +202,16 @@ struct Net
Disconnected Disconnected
}; };
enum Protocol
{
UDPProtocol,
TCPProtocol
};
static const S32 MaxPacketDataSize = MAXPACKETSIZE; static const S32 MaxPacketDataSize = MAXPACKETSIZE;
static ConnectionNotifyEvent smConnectionNotify; static ConnectionNotifyEvent& getConnectionNotifyEvent();
static ConnectionAcceptedEvent smConnectionAccept; static ConnectionAcceptedEvent& getConnectionAcceptedEvent();
static ConnectionReceiveEvent smConnectionReceive; static ConnectionReceiveEvent& getConnectionReceiveEvent();
static PacketReceiveEvent smPacketReceive; static PacketReceiveEvent& getPacketReceiveEvent();
static bool smMulticastEnabled;
static bool smIpv4Enabled;
static bool smIpv6Enabled;
static bool init(); static bool init();
static void shutdown(); static void shutdown();
@ -116,34 +229,46 @@ struct Net
// Reliable net functions (TCP) // Reliable net functions (TCP)
// all incoming messages come in on the Connected* events // all incoming messages come in on the Connected* events
static NetSocket openListenPort(U16 port); static NetSocket openListenPort(U16 port, NetAddress::Type = NetAddress::IPAddress);
static NetSocket openConnectTo(const char *stringAddress); // does the DNS resolve etc. static NetSocket openConnectTo(const char *stringAddress); // does the DNS resolve etc.
static void closeConnectTo(NetSocket socket); static void closeConnectTo(NetSocket socket);
static Error sendtoSocket(NetSocket socket, const U8 *buffer, S32 bufferSize); static Error sendtoSocket(NetSocket socket, const U8 *buffer, S32 bufferSize, S32 *bytesWritten=NULL);
static bool compareAddresses(const NetAddress *a1, const NetAddress *a2); static bool compareAddresses(const NetAddress *a1, const NetAddress *a2);
static bool stringToAddress(const char *addressString, NetAddress *address); static Net::Error stringToAddress(const char *addressString, NetAddress *address, bool hostLookup=true, int family=0);
static void addressToString(const NetAddress *address, char addressString[256]); static void addressToString(const NetAddress *address, char addressString[256]);
// lower level socked based network functions // lower level socked based network functions
static NetSocket openSocket(); static NetSocket openSocket();
static Error closeSocket(NetSocket socket); static Error closeSocket(NetSocket socket);
static Error send(NetSocket socket, const U8 *buffer, S32 bufferSize); static Error send(NetSocket socket, const U8 *buffer, S32 bufferSize, S32 *outBytesWritten=NULL);
static Error recv(NetSocket socket, U8 *buffer, S32 bufferSize, S32 *bytesRead); static Error recv(NetSocket socket, U8 *buffer, S32 bufferSize, S32 *bytesRead);
static Error connect(NetSocket socket, const NetAddress *address); static Error connect(NetSocket socket, const NetAddress *address);
static Error listen(NetSocket socket, S32 maxConcurrentListens); static Error listen(NetSocket socket, S32 maxConcurrentListens);
static NetSocket accept(NetSocket acceptSocket, NetAddress *remoteAddress); static NetSocket accept(NetSocket acceptSocket, NetAddress *remoteAddress);
static Error bind(NetSocket socket, U16 port); static Error bindAddress(const NetAddress &address, NetSocket socket, bool useUDP=false);
static Error setBufferSize(NetSocket socket, S32 bufferSize); static Error setBufferSize(NetSocket socket, S32 bufferSize);
static Error setBroadcast(NetSocket socket, bool broadcastEnable); static Error setBroadcast(NetSocket socket, bool broadcastEnable);
static Error setBlocking(NetSocket socket, bool blockingIO); static Error setBlocking(NetSocket socket, bool blockingIO);
/// Gets the desired default listen address for a specified address type
static Net::Error getListenAddress(const NetAddress::Type type, NetAddress *address, bool forceDefaults=false);
static void getIdealListenAddress(NetAddress *address);
// Multicast for ipv6 local net browsing
static void enableMulticast();
static void disableMulticast();
static bool isMulticastEnabled();
// Protocol state
static bool isAddressTypeAvailable(NetAddress::Type addressType);
private: private:
static void process(); static void process();
static void processListenSocket(NetSocket socket);
}; };

View file

@ -53,7 +53,7 @@ struct NetAsync::NameLookupRequest
NameLookupRequest() NameLookupRequest()
{ {
sock = InvalidSocket; sock = NetSocket::INVALID;
remoteAddr[0] = 0; remoteAddr[0] = 0;
out_h_addr[0] = 0; out_h_addr[0] = 0;
out_h_length = -1; out_h_length = -1;
@ -81,9 +81,12 @@ protected:
virtual void execute() virtual void execute()
{ {
#ifndef TORQUE_OS_XENON #ifndef TORQUE_OS_XENON
NetAddress address;
Net::Error error = Net::stringToAddress(mRequest.remoteAddr, &address, true);
// do it // do it
struct hostent* hostent = gethostbyname(mRequest.remoteAddr); if (error != Net::NoError)
if (hostent == NULL)
{ {
// oh well! leave the lookup data unmodified (h_length) should // oh well! leave the lookup data unmodified (h_length) should
// still be -1 from initialization // still be -1 from initialization
@ -94,9 +97,9 @@ protected:
// copy the stuff we need from the hostent // copy the stuff we need from the hostent
dMemset(mRequest.out_h_addr, 0, dMemset(mRequest.out_h_addr, 0,
sizeof(mRequest.out_h_addr)); sizeof(mRequest.out_h_addr));
dMemcpy(mRequest.out_h_addr, hostent->h_addr, hostent->h_length); dMemcpy(mRequest.out_h_addr, &address, sizeof(address));
mRequest.out_h_length = hostent->h_length; mRequest.out_h_length = sizeof(address);
mRequest.complete = true; mRequest.complete = true;
} }
#else #else
@ -159,7 +162,7 @@ void NetAsync::queueLookup(const char* remoteAddr, NetSocket socket)
ThreadPool::GLOBAL().queueWorkItem( workItem ); ThreadPool::GLOBAL().queueWorkItem( workItem );
} }
bool NetAsync::checkLookup(NetSocket socket, char* out_h_addr, bool NetAsync::checkLookup(NetSocket socket, void* out_h_addr,
S32* out_h_length, S32 out_h_addr_size) S32* out_h_length, S32 out_h_addr_size)
{ {
bool found = false; bool found = false;

View file

@ -54,7 +54,7 @@ class NetAsync
// out_h_length will be set appropriately. if out_h_length is -1, then // out_h_length will be set appropriately. if out_h_length is -1, then
// name could not be resolved. otherwise, it provides the number of // name could not be resolved. otherwise, it provides the number of
// address bytes copied into out_h_addr. // address bytes copied into out_h_addr.
bool checkLookup(NetSocket socket, char* out_h_addr, int* out_h_length, S32 out_h_addr_size); bool checkLookup(NetSocket socket, void* out_h_addr, int* out_h_length, S32 out_h_addr_size);
}; };
// the global net async object // the global net async object

View file

@ -52,7 +52,7 @@ struct TcpHandle
else else
{ {
Process::requestShutdown(); Process::requestShutdown();
mSocket = NULL; mSocket = NetSocket::INVALID;
ASSERT_EQ(Net::Disconnected, state) ASSERT_EQ(Net::Disconnected, state)
<< "Ended with a network error!"; << "Ended with a network error!";
} }
@ -72,7 +72,7 @@ TEST(Net, TCPRequest)
{ {
TcpHandle handler; TcpHandle handler;
handler.mSocket = InvalidSocket; handler.mSocket = NetSocket::INVALID;
handler.mDataReceived = 0; handler.mDataReceived = 0;
// Hook into the signals. // Hook into the signals.
@ -119,7 +119,7 @@ struct JournalHandle
else else
{ {
Process::requestShutdown(); Process::requestShutdown();
mSocket = NULL; mSocket = NetSocket::INVALID;
ASSERT_EQ(Net::Disconnected, state) ASSERT_EQ(Net::Disconnected, state)
<< "Ended with a network error!"; << "Ended with a network error!";
} }
@ -135,7 +135,7 @@ struct JournalHandle
void makeRequest() void makeRequest()
{ {
mSocket = InvalidSocket; mSocket = NetSocket::INVALID;
mDataReceived = 0; mDataReceived = 0;
// Hook into the signals. // Hook into the signals.

View file

@ -296,11 +296,12 @@ void Marker::initGFXResources()
smVertexBuffer.set(GFX, 4, GFXBufferTypeStatic); smVertexBuffer.set(GFX, 4, GFXBufferTypeStatic);
GFXVertexPCT* verts = smVertexBuffer.lock(); GFXVertexPCT* verts = smVertexBuffer.lock();
verts[0].point = wedgePoints[0] * 0.25f; verts[0].point = wedgePoints[0] * 1.25f;
verts[1].point = wedgePoints[1] * 0.25f; verts[1].point = wedgePoints[1] * 1.25f;
verts[2].point = wedgePoints[2] * 0.25f; verts[2].point = wedgePoints[2] * 1.25f;
verts[3].point = wedgePoints[3] * 0.25f; verts[3].point = wedgePoints[3] * 1.25f;
verts[0].color = verts[1].color = verts[2].color = verts[3].color = GFXVertexColor(ColorI(0, 255, 0, 255)); verts[1].color = GFXVertexColor(ColorI(255, 0, 0, 255));
verts[0].color = verts[2].color = verts[3].color = GFXVertexColor(ColorI(0, 0, 255, 255));
smVertexBuffer.unlock(); smVertexBuffer.unlock();
smPrimitiveBuffer.set(GFX, 24, 12, GFXBufferTypeStatic); smPrimitiveBuffer.set(GFX, 24, 12, GFXBufferTypeStatic);
@ -417,7 +418,7 @@ bool Marker::onAdd()
if(!Parent::onAdd()) if(!Parent::onAdd())
return false; return false;
mObjBox = Box3F(Point3F(-.25, -.25, -.25), Point3F(.25, .25, .25)); mObjBox = Box3F(Point3F(-1.25, -1.25, -1.25), Point3F(1.25, 1.25, 1.25));
resetWorldBox(); resetWorldBox();
if(gEditingMission) if(gEditingMission)

View file

@ -291,14 +291,6 @@ void ParallaxFeatGLSL::processVert( Vector<ShaderComponent*> &componentList,
meta->addStatement( new GenOp( " @ = tMul( @, float3( @.xyz - @ ) );\r\n", meta->addStatement( new GenOp( " @ = tMul( @, float3( @.xyz - @ ) );\r\n",
outNegViewTS, objToTangentSpace, inPos, eyePos ) ); outNegViewTS, objToTangentSpace, inPos, eyePos ) );
// TODO: I'm at a loss at why i need to flip the binormal/y coord
// to get a good view vector for parallax. Lighting works properly
// with the TS matrix as is... but parallax does not.
//
// Someone figure this out!
//
meta->addStatement( new GenOp( " @.y = -@.y;\r\n", outNegViewTS, outNegViewTS ) );
// If we have texture anim matrix the tangent // If we have texture anim matrix the tangent
// space view vector may need to be rotated. // space view vector may need to be rotated.
Var *texMat = (Var*)LangElement::find( "texMat" ); Var *texMat = (Var*)LangElement::find( "texMat" );

View file

@ -67,8 +67,6 @@ LangElement * ShaderFeatureGLSL::setupTexSpaceMat( Vector<ShaderComponent*> &, /
{ {
if(dStricmp((char*)T->type, "vec4") == 0) if(dStricmp((char*)T->type, "vec4") == 0)
meta->addStatement( new GenOp( " tSetMatrixRow(@, 1, cross( @, normalize(@) ) * @.w);\r\n", *texSpaceMat, T, N, T ) ); meta->addStatement( new GenOp( " tSetMatrixRow(@, 1, cross( @, normalize(@) ) * @.w);\r\n", *texSpaceMat, T, N, T ) );
else if(tangentW)
meta->addStatement( new GenOp( " tSetMatrixRow(@, 1, cross( @, normalize(@) ) * @);\r\n", *texSpaceMat, T, N, tangentW ) );
else else
meta->addStatement( new GenOp( " tSetMatrixRow(@, 1, cross( @, normalize(@) ));\r\n", *texSpaceMat, T, N ) ); meta->addStatement( new GenOp( " tSetMatrixRow(@, 1, cross( @, normalize(@) ));\r\n", *texSpaceMat, T, N ) );
} }

View file

@ -323,14 +323,6 @@ void ParallaxFeatHLSL::processVert( Vector<ShaderComponent*> &componentList,
meta->addStatement( new GenOp( " @ = mul( @, float3( @.xyz - @ ) );\r\n", meta->addStatement( new GenOp( " @ = mul( @, float3( @.xyz - @ ) );\r\n",
outNegViewTS, objToTangentSpace, inPos, eyePos ) ); outNegViewTS, objToTangentSpace, inPos, eyePos ) );
// TODO: I'm at a loss at why i need to flip the binormal/y coord
// to get a good view vector for parallax. Lighting works properly
// with the TS matrix as is... but parallax does not.
//
// Someone figure this out!
//
meta->addStatement( new GenOp( " @.y = -@.y;\r\n", outNegViewTS, outNegViewTS ) );
// If we have texture anim matrix the tangent // If we have texture anim matrix the tangent
// space view vector may need to be rotated. // space view vector may need to be rotated.
Var *texMat = (Var*)LangElement::find( "texMat" ); Var *texMat = (Var*)LangElement::find( "texMat" );

View file

@ -67,8 +67,6 @@ LangElement * ShaderFeatureHLSL::setupTexSpaceMat( Vector<ShaderComponent*> &, /
{ {
if(dStricmp((char*)T->type, "float4") == 0) if(dStricmp((char*)T->type, "float4") == 0)
meta->addStatement( new GenOp( " @[1] = cross( @, normalize(@) ) * @.w;\r\n", *texSpaceMat, T, N, T ) ); meta->addStatement( new GenOp( " @[1] = cross( @, normalize(@) ) * @.w;\r\n", *texSpaceMat, T, N, T ) );
else if(tangentW)
meta->addStatement( new GenOp( " @[1] = cross( @, normalize(@) ) * @;\r\n", *texSpaceMat, T, N, tangentW ) );
else else
meta->addStatement( new GenOp( " @[1] = cross( @, normalize(@) );\r\n", *texSpaceMat, T, N ) ); meta->addStatement( new GenOp( " @[1] = cross( @, normalize(@) );\r\n", *texSpaceMat, T, N ) );
} }

View file

@ -157,7 +157,7 @@ bool NetConnection::mFilesWereDownloaded = false;
static inline U32 HashNetAddress(const NetAddress *addr) static inline U32 HashNetAddress(const NetAddress *addr)
{ {
return *((U32 *)addr->netNum) % NetConnection::HashTableSize; return addr->getHash() % NetConnection::HashTableSize;
} }
NetConnection *NetConnection::lookup(const NetAddress *addr) NetConnection *NetConnection::lookup(const NetAddress *addr)
@ -1421,7 +1421,7 @@ DefineEngineMethod( NetConnection, connect, void, (const char* remoteAddress),,
) )
{ {
NetAddress addr; NetAddress addr;
if(!Net::stringToAddress(remoteAddress, &addr)) if (Net::stringToAddress(remoteAddress, &addr) != Net::NoError)
{ {
Con::errorf("NetConnection::connect: invalid address - %s", remoteAddress); Con::errorf("NetConnection::connect: invalid address - %s", remoteAddress);
return; return;

View file

@ -41,7 +41,7 @@ NetInterface::NetInterface()
GNet = this; GNet = this;
mLastTimeoutCheckTime = 0; mLastTimeoutCheckTime = 0;
mAllowConnections = true; mAllowConnections = false;
} }
@ -109,7 +109,7 @@ void NetInterface::processPacketReceiveEvent(NetAddress srcAddress, RawData pack
pStream.read(&packetType); pStream.read(&packetType);
NetAddress *addr = &srcAddress; NetAddress *addr = &srcAddress;
if(packetType <= GameHeartbeat) if(packetType <= GameHeartbeat || packetType == MasterServerExtendedListResponse)
handleInfoPacket(addr, packetType, &pStream); handleInfoPacket(addr, packetType, &pStream);
#ifdef GGC_PLUGIN #ifdef GGC_PLUGIN
else if (packetType == GGCPacket) else if (packetType == GGCPacket)
@ -556,10 +556,7 @@ void NetInterface::computeNetMD5(const NetAddress *address, U32 connectSequence,
U32 in[16]; U32 in[16];
in[0] = address->type; in[0] = address->type;
in[1] = (U32(address->netNum[0]) << 24) | in[1] = address->getHash();
(U32(address->netNum[1]) << 16) |
(U32(address->netNum[2]) << 8) |
(U32(address->netNum[3]));
in[2] = address->port; in[2] = address->port;
in[3] = connectSequence; in[3] = connectSequence;
for(U32 i = 0; i < 12; i++) for(U32 i = 0; i < 12; i++)

View file

@ -46,7 +46,7 @@ public:
GameInfoRequest = 18, GameInfoRequest = 18,
GameInfoResponse = 20, GameInfoResponse = 20,
GameHeartbeat = 22, GameHeartbeat = 22,
GGCPacket = 24, GGCPacket = 24,
ConnectChallengeRequest = 26, ConnectChallengeRequest = 26,
ConnectChallengeReject = 28, ConnectChallengeReject = 28,
ConnectChallengeResponse = 30, ConnectChallengeResponse = 30,
@ -54,6 +54,9 @@ public:
ConnectReject = 34, ConnectReject = 34,
ConnectAccept = 36, ConnectAccept = 36,
Disconnect = 38, Disconnect = 38,
MasterServerExtendedListResponse = 40,
MasterServerChallenge = 42,
MasterServerExtendedListRequest = 44,
}; };
protected: protected:

View file

@ -152,11 +152,17 @@ void TerrainCellMaterial::_updateDefaultAnisotropy()
} // for ( U32 m=0; m < pass.materials.size(); m++ ) } // for ( U32 m=0; m < pass.materials.size(); m++ )
// Set the updated stateblock. // Set the updated stateblock.
desc.setCullMode( GFXCullCCW );
pass.stateBlock = GFX->createStateBlock( desc ); pass.stateBlock = GFX->createStateBlock( desc );
//reflection
desc.setCullMode( GFXCullCW );
pass.reflectionStateBlock = GFX->createStateBlock(desc);
// Create the wireframe state blocks. // Create the wireframe state blocks.
GFXStateBlockDesc wireframe( desc ); GFXStateBlockDesc wireframe( desc );
wireframe.fillMode = GFXFillWireframe; wireframe.fillMode = GFXFillWireframe;
wireframe.setCullMode( GFXCullCCW );
pass.wireframeStateBlock = GFX->createStateBlock( wireframe ); pass.wireframeStateBlock = GFX->createStateBlock( wireframe );
} // for ( U32 p=0; i < (*iter)->mPasses.size(); p++ ) } // for ( U32 p=0; i < (*iter)->mPasses.size(); p++ )
@ -668,15 +674,17 @@ bool TerrainCellMaterial::_createPass( Vector<MaterialInfo*> *materials,
if ( prePassMat ) if ( prePassMat )
desc.addDesc( RenderPrePassMgr::getOpaqueStenciWriteDesc( false ) ); desc.addDesc( RenderPrePassMgr::getOpaqueStenciWriteDesc( false ) );
// Shut off culling for prepass materials (reflection support). desc.setCullMode( GFXCullCCW );
if ( prePassMat ) pass->stateBlock = GFX->createStateBlock(desc);
desc.setCullMode( GFXCullNone );
pass->stateBlock = GFX->createStateBlock( desc ); //reflection stateblock
desc.setCullMode( GFXCullCW );
pass->reflectionStateBlock = GFX->createStateBlock(desc);
// Create the wireframe state blocks. // Create the wireframe state blocks.
GFXStateBlockDesc wireframe( desc ); GFXStateBlockDesc wireframe( desc );
wireframe.fillMode = GFXFillWireframe; wireframe.fillMode = GFXFillWireframe;
wireframe.setCullMode( GFXCullCCW );
pass->wireframeStateBlock = GFX->createStateBlock( wireframe ); pass->wireframeStateBlock = GFX->createStateBlock( wireframe );
return true; return true;
@ -776,6 +784,8 @@ bool TerrainCellMaterial::setupPass( const SceneRenderState *state,
if ( sceneData.wireframe ) if ( sceneData.wireframe )
GFX->setStateBlock( pass.wireframeStateBlock ); GFX->setStateBlock( pass.wireframeStateBlock );
else if ( state->isReflectPass( ))
GFX->setStateBlock( pass.reflectionStateBlock );
else else
GFX->setStateBlock( pass.stateBlock ); GFX->setStateBlock( pass.stateBlock );

View file

@ -108,6 +108,7 @@ protected:
GFXStateBlockRef stateBlock; GFXStateBlockRef stateBlock;
GFXStateBlockRef wireframeStateBlock; GFXStateBlockRef wireframeStateBlock;
GFXStateBlockRef reflectionStateBlock;
GFXShaderConstHandle *modelViewProjConst; GFXShaderConstHandle *modelViewProjConst;
GFXShaderConstHandle *worldViewOnly; GFXShaderConstHandle *worldViewOnly;

View file

@ -39,16 +39,19 @@ bool Platform::displaySplashWindow( String path )
gSplashImage = SDL_LoadBMP(path); gSplashImage = SDL_LoadBMP(path);
//now the pop-up window //now the pop-up window
gSplashWindow = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, if (gSplashImage)
gSplashImage->w, gSplashImage->h, SDL_WINDOW_BORDERLESS | SDL_WINDOW_SHOWN); {
gSplashWindow = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
gSplashImage->w, gSplashImage->h, SDL_WINDOW_BORDERLESS | SDL_WINDOW_SHOWN);
gSplashRenderer = SDL_CreateRenderer(gSplashWindow, -1, SDL_RENDERER_ACCELERATED); gSplashRenderer = SDL_CreateRenderer(gSplashWindow, -1, SDL_RENDERER_ACCELERATED);
gSplashTexture = SDL_CreateTextureFromSurface(gSplashRenderer, gSplashImage); gSplashTexture = SDL_CreateTextureFromSurface(gSplashRenderer, gSplashImage);
SDL_RenderCopy(gSplashRenderer, gSplashTexture, NULL, NULL); SDL_RenderCopy(gSplashRenderer, gSplashTexture, NULL, NULL);
SDL_RenderPresent(gSplashRenderer); SDL_RenderPresent(gSplashRenderer);
}
return true; return true;
} }

View file

@ -342,7 +342,7 @@ bool PlatformWindowSDL::isFocused()
if( flags & SDL_WINDOW_INPUT_FOCUS || flags & SDL_WINDOW_INPUT_GRABBED || flags & SDL_WINDOW_MOUSE_FOCUS ) if( flags & SDL_WINDOW_INPUT_FOCUS || flags & SDL_WINDOW_INPUT_GRABBED || flags & SDL_WINDOW_MOUSE_FOCUS )
return true; return true;
return true; return false;
} }
bool PlatformWindowSDL::isMinimized() bool PlatformWindowSDL::isMinimized()

View file

@ -81,7 +81,7 @@
addProjectLibInput('ADVAPI32.LIB'); addProjectLibInput('ADVAPI32.LIB');
addProjectLibInput('GDI32.LIB'); addProjectLibInput('GDI32.LIB');
addProjectLibInput('WINMM.LIB'); addProjectLibInput('WINMM.LIB');
addProjectLibInput('WSOCK32.LIB'); addProjectLibInput('WS2_32.LIB.LIB');
addProjectLibInput('vfw32.lib'); addProjectLibInput('vfw32.lib');
addProjectLibInput('Imm32.lib'); addProjectLibInput('Imm32.lib');
addProjectLibInput('d3d9.lib'); addProjectLibInput('d3d9.lib');

View file

@ -81,7 +81,7 @@
addProjectLibInput('ADVAPI32.LIB'); addProjectLibInput('ADVAPI32.LIB');
addProjectLibInput('GDI32.LIB'); addProjectLibInput('GDI32.LIB');
addProjectLibInput('WINMM.LIB'); addProjectLibInput('WINMM.LIB');
addProjectLibInput('WSOCK32.LIB'); addProjectLibInput('WS2_32.LIB');
addProjectLibInput('vfw32.lib'); addProjectLibInput('vfw32.lib');
addProjectLibInput('Imm32.lib'); addProjectLibInput('Imm32.lib');
addProjectLibInput('d3d9.lib'); addProjectLibInput('d3d9.lib');

View file

@ -138,13 +138,13 @@ mat3x3 quatToMat( vec4 quat )
/// ///
vec2 parallaxOffset( sampler2D texMap, vec2 texCoord, vec3 negViewTS, float depthScale ) vec2 parallaxOffset( sampler2D texMap, vec2 texCoord, vec3 negViewTS, float depthScale )
{ {
float depth = texture( texMap, texCoord ).a; float depth = texture( texMap, texCoord ).a/(PARALLAX_REFINE_STEPS*2);
vec2 offset = negViewTS.xy * vec2( depth * depthScale ); vec2 offset = negViewTS.xy * vec2( depth * depthScale )/vec2(PARALLAX_REFINE_STEPS*2);
for ( int i=0; i < PARALLAX_REFINE_STEPS; i++ ) for ( int i=0; i < PARALLAX_REFINE_STEPS; i++ )
{ {
depth = ( depth + texture( texMap, texCoord + offset ).a ) * 0.5; depth = ( depth + texture( texMap, texCoord + offset ).a )/(PARALLAX_REFINE_STEPS*2);
offset = negViewTS.xy * vec2( depth * depthScale ); offset = negViewTS.xy * vec2( depth * depthScale )/vec2(PARALLAX_REFINE_STEPS*2);
} }
return offset; return offset;
@ -153,13 +153,13 @@ vec2 parallaxOffset( sampler2D texMap, vec2 texCoord, vec3 negViewTS, float dept
/// Same as parallaxOffset but for dxtnm where depth is stored in the red channel instead of the alpha /// Same as parallaxOffset but for dxtnm where depth is stored in the red channel instead of the alpha
vec2 parallaxOffsetDxtnm(sampler2D texMap, vec2 texCoord, vec3 negViewTS, float depthScale) vec2 parallaxOffsetDxtnm(sampler2D texMap, vec2 texCoord, vec3 negViewTS, float depthScale)
{ {
float depth = texture(texMap, texCoord).r; float depth = texture(texMap, texCoord).r/(PARALLAX_REFINE_STEPS*2);
vec2 offset = negViewTS.xy * vec2(depth * depthScale); vec2 offset = negViewTS.xy * vec2(depth * depthScale)/vec2(PARALLAX_REFINE_STEPS*2);
for (int i = 0; i < PARALLAX_REFINE_STEPS; i++) for (int i = 0; i < PARALLAX_REFINE_STEPS; i++)
{ {
depth = (depth + texture(texMap, texCoord + offset).r) * 0.5; depth = (depth + texture(texMap, texCoord + offset).r)/(PARALLAX_REFINE_STEPS*2);
offset = negViewTS.xy * vec2(depth * depthScale); offset = negViewTS.xy * vec2(depth * depthScale)/vec2(PARALLAX_REFINE_STEPS*2);
} }
return offset; return offset;

View file

@ -140,13 +140,13 @@ float3x3 quatToMat( float4 quat )
/// ///
float2 parallaxOffset(TORQUE_SAMPLER2D(texMap), float2 texCoord, float3 negViewTS, float depthScale) float2 parallaxOffset(TORQUE_SAMPLER2D(texMap), float2 texCoord, float3 negViewTS, float depthScale)
{ {
float depth = TORQUE_TEX2D(texMap, texCoord).a; float depth = TORQUE_TEX2D(texMap, texCoord).a/(PARALLAX_REFINE_STEPS*2);
float2 offset = negViewTS.xy * (depth * depthScale); float2 offset = negViewTS.xy * (depth * depthScale)/(PARALLAX_REFINE_STEPS);
for (int i = 0; i < PARALLAX_REFINE_STEPS; i++) for (int i = 0; i < PARALLAX_REFINE_STEPS; i++)
{ {
depth = (depth + TORQUE_TEX2D(texMap, texCoord + offset).a) * 0.5; depth = (depth + TORQUE_TEX2D(texMap, texCoord + offset).a)/(PARALLAX_REFINE_STEPS*2);
offset = negViewTS.xy * (depth * depthScale); offset = negViewTS.xy * (depth * depthScale)/(PARALLAX_REFINE_STEPS);
} }
return offset; return offset;
@ -155,13 +155,13 @@ float2 parallaxOffset(TORQUE_SAMPLER2D(texMap), float2 texCoord, float3 negViewT
/// Same as parallaxOffset but for dxtnm where depth is stored in the red channel instead of the alpha /// Same as parallaxOffset but for dxtnm where depth is stored in the red channel instead of the alpha
float2 parallaxOffsetDxtnm(TORQUE_SAMPLER2D(texMap), float2 texCoord, float3 negViewTS, float depthScale) float2 parallaxOffsetDxtnm(TORQUE_SAMPLER2D(texMap), float2 texCoord, float3 negViewTS, float depthScale)
{ {
float depth = TORQUE_TEX2D(texMap, texCoord).r; float depth = TORQUE_TEX2D(texMap, texCoord).r/(PARALLAX_REFINE_STEPS*2);
float2 offset = negViewTS.xy * (depth * depthScale); float2 offset = negViewTS.xy * (depth * depthScale)/(PARALLAX_REFINE_STEPS*2);
for (int i = 0; i < PARALLAX_REFINE_STEPS; i++) for (int i = 0; i < PARALLAX_REFINE_STEPS; i++)
{ {
depth = (depth + TORQUE_TEX2D(texMap, texCoord + offset).r) * 0.5; depth = (depth + TORQUE_TEX2D(texMap, texCoord + offset).r)/(PARALLAX_REFINE_STEPS*2);
offset = negViewTS.xy * (depth * depthScale); offset = negViewTS.xy * (depth * depthScale)/(PARALLAX_REFINE_STEPS*2);
} }
return offset; return offset;

View file

@ -34,6 +34,8 @@
/// What's the name of your application? Used in a variety of places. /// What's the name of your application? Used in a variety of places.
#define TORQUE_APP_NAME "Full" #define TORQUE_APP_NAME "Full"
#define TORQUE_NET_DEFAULT_MULTICAST_ADDRESS "ff04::7467:656E:6574:776B"
/// What version of the application specific source code is this? /// What version of the application specific source code is this?
/// ///
/// Version number is major * 1000 + minor * 100 + revision * 10. /// Version number is major * 1000 + minor * 100 + revision * 10.

View file

@ -365,7 +365,7 @@ if(WIN32)
set(TORQUE_CXX_FLAGS_LIBS "/W0" CACHE TYPE STRING) set(TORQUE_CXX_FLAGS_LIBS "/W0" CACHE TYPE STRING)
mark_as_advanced(TORQUE_CXX_FLAGS_LIBS) mark_as_advanced(TORQUE_CXX_FLAGS_LIBS)
set(TORQUE_CXX_FLAGS_COMMON_DEFAULT "-DUNICODE -D_UNICODE -D_CRT_SECURE_NO_WARNINGS /MP /O2 /Ob2 /Oi /Ot /Oy /GT /Zi /W4 /nologo /GF /EHsc /GS- /Gy- /Qpar- /fp:fast /fp:except- /GR /Zc:wchar_t-" ) set(TORQUE_CXX_FLAGS_COMMON_DEFAULT "-DUNICODE -D_UNICODE -D_CRT_SECURE_NO_WARNINGS /MP /O2 /Ob2 /Oi /Ot /Oy /GT /Zi /W4 /nologo /GF /EHsc /GS- /Gy- /Qpar- /fp:precise /fp:except- /GR /Zc:wchar_t-" )
if( TORQUE_CPU_X32 ) if( TORQUE_CPU_X32 )
set(TORQUE_CXX_FLAGS_COMMON_DEFAULT "${TORQUE_CXX_FLAGS_COMMON_DEFAULT} /arch:SSE2") set(TORQUE_CXX_FLAGS_COMMON_DEFAULT "${TORQUE_CXX_FLAGS_COMMON_DEFAULT} /arch:SSE2")
endif() endif()

View file

@ -616,7 +616,7 @@ endif()
if(WIN32) if(WIN32)
# copy pasted from T3D build system, some might not be needed # copy pasted from T3D build system, some might not be needed
set(TORQUE_EXTERNAL_LIBS "COMCTL32.LIB;COMDLG32.LIB;USER32.LIB;ADVAPI32.LIB;GDI32.LIB;WINMM.LIB;WSOCK32.LIB;vfw32.lib;Imm32.lib;d3d9.lib;d3dx9.lib;DxErr.lib;ole32.lib;shell32.lib;oleaut32.lib;version.lib" CACHE STRING "external libs to link against") set(TORQUE_EXTERNAL_LIBS "COMCTL32.LIB;COMDLG32.LIB;USER32.LIB;ADVAPI32.LIB;GDI32.LIB;WINMM.LIB;WS2_32.LIB;vfw32.lib;Imm32.lib;d3d9.lib;d3dx9.lib;DxErr.lib;ole32.lib;shell32.lib;oleaut32.lib;version.lib" CACHE STRING "external libs to link against")
mark_as_advanced(TORQUE_EXTERNAL_LIBS) mark_as_advanced(TORQUE_EXTERNAL_LIBS)
addLib("${TORQUE_EXTERNAL_LIBS}") addLib("${TORQUE_EXTERNAL_LIBS}")

View file

@ -118,7 +118,7 @@ class NPWebPlugin
addProjectLibInput('ADVAPI32.LIB'); addProjectLibInput('ADVAPI32.LIB');
addProjectLibInput('GDI32.LIB'); addProjectLibInput('GDI32.LIB');
addProjectLibInput('WINMM.LIB'); addProjectLibInput('WINMM.LIB');
addProjectLibInput('WSOCK32.LIB'); addProjectLibInput('WS2_32.LIB');
addProjectLibInput('vfw32.lib'); addProjectLibInput('vfw32.lib');
addProjectLibInput('Imm32.lib'); addProjectLibInput('Imm32.lib');
addProjectLibInput('UnicoWS.lib'); addProjectLibInput('UnicoWS.lib');

View file

@ -173,7 +173,7 @@ class Torque3D
addProjectLibInput('ADVAPI32.LIB'); addProjectLibInput('ADVAPI32.LIB');
addProjectLibInput('GDI32.LIB'); addProjectLibInput('GDI32.LIB');
addProjectLibInput('WINMM.LIB'); addProjectLibInput('WINMM.LIB');
addProjectLibInput('WSOCK32.LIB'); addProjectLibInput('WS2_32.LIB');
addProjectLibInput('vfw32.lib'); addProjectLibInput('vfw32.lib');
addProjectLibInput('Imm32.lib'); addProjectLibInput('Imm32.lib');
addProjectLibInput('d3d9.lib'); addProjectLibInput('d3d9.lib');

View file

@ -183,7 +183,7 @@ else
addProjectLibInput('ADVAPI32.LIB'); addProjectLibInput('ADVAPI32.LIB');
addProjectLibInput('GDI32.LIB'); addProjectLibInput('GDI32.LIB');
addProjectLibInput('WINMM.LIB'); addProjectLibInput('WINMM.LIB');
addProjectLibInput('WSOCK32.LIB'); addProjectLibInput('WS2_32.LIB');
addProjectLibInput('vfw32.lib'); addProjectLibInput('vfw32.lib');
addProjectLibInput('Imm32.lib'); addProjectLibInput('Imm32.lib');
addProjectLibInput('d3d9.lib'); addProjectLibInput('d3d9.lib');