mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2025-10-30 08:11:25 +00:00
fix the weird shader bug finally and a few reported MP bugs
This commit is contained in:
parent
0c7286cf62
commit
42b1c634f4
5 changed files with 93 additions and 20 deletions
|
|
@ -466,11 +466,59 @@ class DifBuilder {
|
|||
colliderSurface.originalIndices = [];
|
||||
colliderSurface.originalSurfaceIndex = surfaceindex;
|
||||
|
||||
var pc0 = geo.points[geo.windings[surface.windingStart + 1]];
|
||||
var pc1 = geo.points[geo.windings[surface.windingStart + 0]];
|
||||
var pc2 = geo.points[geo.windings[surface.windingStart + 2]];
|
||||
|
||||
// Pick the three non-collinear points
|
||||
var texPlanes = geo.texGenEQs[surface.texGenIndex];
|
||||
|
||||
var startIdx = 0;
|
||||
while (true) {
|
||||
var pc0 = geo.points[geo.windings[surface.windingStart + startIdx + 1]];
|
||||
var pc1 = geo.points[geo.windings[surface.windingStart + startIdx]];
|
||||
var pc2 = geo.points[geo.windings[surface.windingStart + startIdx + 2]];
|
||||
|
||||
var tc0 = new Vector(texPlanes.planeX.x * pc0.x
|
||||
+ texPlanes.planeX.y * pc0.y
|
||||
+ texPlanes.planeX.z * pc0.z
|
||||
+ texPlanes.planeX.d,
|
||||
texPlanes.planeY.x * pc0.x
|
||||
+ texPlanes.planeY.y * pc0.y
|
||||
+ texPlanes.planeY.z * pc0.z
|
||||
+ texPlanes.planeY.d, 0, 0);
|
||||
var tc1 = new Vector(texPlanes.planeX.x * pc1.x
|
||||
+ texPlanes.planeX.y * pc1.y
|
||||
+ texPlanes.planeX.z * pc1.z
|
||||
+ texPlanes.planeX.d,
|
||||
texPlanes.planeY.x * pc1.x
|
||||
+ texPlanes.planeY.y * pc1.y
|
||||
+ texPlanes.planeY.z * pc1.z
|
||||
+ texPlanes.planeY.d, 0, 0);
|
||||
var tc2 = new Vector(texPlanes.planeX.x * pc2.x
|
||||
+ texPlanes.planeX.y * pc2.y
|
||||
+ texPlanes.planeX.z * pc2.z
|
||||
+ texPlanes.planeX.d,
|
||||
texPlanes.planeY.x * pc2.x
|
||||
+ texPlanes.planeY.y * pc2.y
|
||||
+ texPlanes.planeY.z * pc2.z
|
||||
+ texPlanes.planeY.d, 0, 0);
|
||||
|
||||
var edge1 = new Vector(pc1.x - pc0.x, tc1.x - tc0.x, tc1.y - tc0.y);
|
||||
var edge2 = new Vector(pc2.x - pc0.x, tc2.x - tc0.x, tc2.y - tc0.y);
|
||||
var cp = edge1.cross(edge2);
|
||||
|
||||
if (cp.lengthSq() > 1e-12) {
|
||||
break;
|
||||
}
|
||||
|
||||
startIdx += 3;
|
||||
if (startIdx >= surface.windingCount) {
|
||||
startIdx = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var pc0 = geo.points[geo.windings[surface.windingStart + startIdx + 1]];
|
||||
var pc1 = geo.points[geo.windings[surface.windingStart + startIdx]];
|
||||
var pc2 = geo.points[geo.windings[surface.windingStart + startIdx + 2]];
|
||||
|
||||
var tc0 = new Vector(texPlanes.planeX.x * pc0.x
|
||||
+ texPlanes.planeX.y * pc0.y
|
||||
+ texPlanes.planeX.z * pc0.z
|
||||
|
|
|
|||
|
|
@ -76,6 +76,7 @@ class GuiMLTextListCtrl extends GuiControl {
|
|||
textObjs.push(tobj);
|
||||
|
||||
if (this.scrollable) {
|
||||
if (this.flow != null) {
|
||||
if (this.flow.contains(tobj))
|
||||
this.flow.removeChild(tobj);
|
||||
|
||||
|
|
@ -84,6 +85,7 @@ class GuiMLTextListCtrl extends GuiControl {
|
|||
this.flow.getProperties(tobj).isAbsolute = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.texts = texts;
|
||||
this._prevSelected = -1;
|
||||
if (this.onSelectedFunc != null)
|
||||
|
|
|
|||
|
|
@ -152,8 +152,6 @@ class MultiplayerLevelSelectGui extends GuiImage {
|
|||
playerWnd.extent = new Vector(640, 480);
|
||||
innerCtrl.addChild(playerWnd);
|
||||
|
||||
custSelected = false;
|
||||
|
||||
var playerListArr = [];
|
||||
if (Net.isHost) {
|
||||
playerListArr.push({
|
||||
|
|
@ -240,7 +238,7 @@ class MultiplayerLevelSelectGui extends GuiImage {
|
|||
customList.extent = new Vector(550, 2880);
|
||||
customList.scrollable = true;
|
||||
customList.onSelectedFunc = (idx) -> {
|
||||
NetCommands.setLobbyCustLevelName(MPCustoms.missionList[idx].title);
|
||||
NetCommands.setLobbyCustLevelName(MPCustoms.missionList[idx].path);
|
||||
custSelected = true;
|
||||
custSelectedIdx = idx;
|
||||
custPath = MPCustoms.missionList[idx].path;
|
||||
|
|
@ -427,13 +425,24 @@ class MultiplayerLevelSelectGui extends GuiImage {
|
|||
};
|
||||
|
||||
setLevelStr = (str) -> {
|
||||
levelSelectOpts.optionText.text.text = str;
|
||||
var cust = MPCustoms.missionList.filter(x -> x.path == str)[0];
|
||||
levelSelectOpts.optionText.text.text = cust.title;
|
||||
custSelected = true;
|
||||
custPath = str;
|
||||
if (Net.isHost) {
|
||||
updateLobbyNames();
|
||||
} else
|
||||
updatePlayerCountFn(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
var customIsSelected = custSelected == true;
|
||||
levelSelectOpts.setCurrentOption(currentSelectionStatic);
|
||||
setLevel(currentSelectionStatic);
|
||||
innerCtrl.addChild(levelSelectOpts);
|
||||
|
||||
if (customIsSelected) {
|
||||
setLevelStr(custPath);
|
||||
}
|
||||
}
|
||||
|
||||
override function onResize(width:Int, height:Int) {
|
||||
|
|
|
|||
|
|
@ -190,6 +190,10 @@ class Net {
|
|||
|
||||
var closing = false;
|
||||
|
||||
isMP = true;
|
||||
isHost = false;
|
||||
isClient = true;
|
||||
|
||||
var closeFunc = (msg:String, forceShow:Bool) -> {
|
||||
if (closing)
|
||||
return;
|
||||
|
|
@ -204,6 +208,9 @@ class Net {
|
|||
var loadGui = new MultiplayerLoadingGui(msg);
|
||||
MarbleGame.canvas.setContent(loadGui);
|
||||
loadGui.setErrorStatus(msg);
|
||||
} else {
|
||||
var loadGui = cast(MarbleGame.canvas.content, MultiplayerLoadingGui);
|
||||
loadGui.setErrorStatus(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -297,7 +304,7 @@ class Net {
|
|||
}
|
||||
|
||||
var onDatachannelClose = (dc:RTCDataChannel) -> {
|
||||
closeFunc("Server closed", true);
|
||||
closeFunc("Disconnected", true);
|
||||
}
|
||||
|
||||
var onDatachannelError = (msg:String) -> {
|
||||
|
|
@ -329,10 +336,6 @@ class Net {
|
|||
clientDatachannelUnreliable.onError = (msg) -> {
|
||||
onDatachannelError(msg);
|
||||
}
|
||||
|
||||
isMP = true;
|
||||
isHost = false;
|
||||
isClient = true;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -356,6 +359,7 @@ class Net {
|
|||
Net.lobbyHostReady = false;
|
||||
Net.lobbyClientReady = false;
|
||||
Net.hostReady = false;
|
||||
MultiplayerLevelSelectGui.custSelected = false;
|
||||
}
|
||||
if (Net.isHost) {
|
||||
NetCommands.serverClosed();
|
||||
|
|
@ -375,6 +379,7 @@ class Net {
|
|||
Net.lobbyHostReady = false;
|
||||
Net.lobbyClientReady = false;
|
||||
Net.hostReady = false;
|
||||
MultiplayerLevelSelectGui.custSelected = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -562,7 +567,11 @@ class Net {
|
|||
|
||||
static function onClientHandshakeComplete(conn:ClientConnection) {
|
||||
// Send our current mission to connecting client
|
||||
if (MultiplayerLevelSelectGui.custSelected) {
|
||||
NetCommands.setLobbyCustLevelNameClient(conn, MultiplayerLevelSelectGui.custPath);
|
||||
} else {
|
||||
NetCommands.setLobbyLevelIndexClient(conn, MultiplayerLevelSelectGui.currentSelectionStatic);
|
||||
}
|
||||
|
||||
if (serverInfo.state == "PLAYING") { // We initiated the game, directly add in the marble
|
||||
if (MultiplayerLevelSelectGui.custSelected) {
|
||||
|
|
|
|||
|
|
@ -25,6 +25,9 @@ class NetCommands {
|
|||
@:rpc(server) public static function setLobbyCustLevelName(str:String) {
|
||||
if (MultiplayerLevelSelectGui.setLevelFn != null) {
|
||||
MultiplayerLevelSelectGui.setLevelStr(str);
|
||||
} else {
|
||||
MultiplayerLevelSelectGui.custSelected = true;
|
||||
MultiplayerLevelSelectGui.custPath = str;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -113,7 +116,8 @@ class NetCommands {
|
|||
|
||||
@:rpc(client) public static function clientIsReady(clientId:Int) {
|
||||
if (Net.isHost) {
|
||||
if (Net.serverInfo.state == "WAITING" && MarbleGame.instance.world != null) {
|
||||
if (Net.serverInfo.state == "WAITING") {
|
||||
Console.log('Client ${clientId} is ready!');
|
||||
if (clientId != -1)
|
||||
Net.clientIdMap[clientId].ready();
|
||||
else
|
||||
|
|
@ -127,6 +131,7 @@ class NetCommands {
|
|||
}
|
||||
if (allReady && Net.hostReady) {
|
||||
if (MarbleGame.instance.world != null) {
|
||||
Console.log('All are ready, starting');
|
||||
MarbleGame.instance.world.allClientsReady();
|
||||
}
|
||||
Net.serverInfo.state = "PLAYING";
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue