Quellcode durchsuchen

Separated Update and Render in the Core. ATTENTION: YOU MUST NOW CALL updateAndRender() instead of Update() or call Update() and Render() manually. Made 2d physics non-framerate dependant, fixed collision detection in 2d physics, fixed z angle not returning correctly from Matrix4, updated IDE and examples to use the new method. Made new file window slightly bigger, fixed UIButton firing click even on on any key press

Ivan Safrin vor 12 Jahren
Ursprung
Commit
56e6d494ff
55 geänderte Dateien mit 178 neuen und 125 gelöschten Zeilen
  1. 4 1
      Core/Contents/Include/PolyCocoaCore.h
  2. 3 0
      Core/Contents/Include/PolyCore.h
  3. 2 1
      Core/Contents/Include/PolyCoreServices.h
  4. 1 1
      Core/Contents/Include/PolyMatrix4.h
  5. 4 1
      Core/Contents/Include/PolySceneManager.h
  6. 1 0
      Core/Contents/Include/PolyScreenManager.h
  7. 15 9
      Core/Contents/Source/PolyCocoaCore.mm
  8. 7 1
      Core/Contents/Source/PolyCore.cpp
  9. 24 27
      Core/Contents/Source/PolyCoreServices.cpp
  10. 4 2
      Core/Contents/Source/PolyScene.cpp
  11. 10 3
      Core/Contents/Source/PolySceneManager.cpp
  12. 1 4
      Core/Contents/Source/PolyScreen.cpp
  13. 9 21
      Core/Contents/Source/PolyScreenManager.cpp
  14. 2 2
      Core/Contents/Source/PolyScreenMesh.cpp
  15. 1 1
      Examples/C++/Contents/2DAudio/HelloPolycodeApp.cpp
  16. 1 1
      Examples/C++/Contents/2DParticles/HelloPolycodeApp.cpp
  17. 1 1
      Examples/C++/Contents/2DPhysics_Basic/HelloPolycodeApp.cpp
  18. 1 1
      Examples/C++/Contents/2DPhysics_CollisionOnly/HelloPolycodeApp.cpp
  19. 1 1
      Examples/C++/Contents/2DPhysics_Contacts/HelloPolycodeApp.cpp
  20. 1 1
      Examples/C++/Contents/2DPhysics_Joints/HelloPolycodeApp.cpp
  21. 1 1
      Examples/C++/Contents/2DPhysics_PointCollision/HelloPolycodeApp.cpp
  22. 1 1
      Examples/C++/Contents/2DShapes/HelloPolycodeApp.cpp
  23. 1 1
      Examples/C++/Contents/2DTransforms/HelloPolycodeApp.cpp
  24. 1 1
      Examples/C++/Contents/3DAudio/HelloPolycodeApp.cpp
  25. 1 1
      Examples/C++/Contents/3DBasics/HelloPolycodeApp.cpp
  26. 1 1
      Examples/C++/Contents/3DMeshParticles/HelloPolycodeApp.cpp
  27. 1 1
      Examples/C++/Contents/3DParticles/HelloPolycodeApp.cpp
  28. 1 1
      Examples/C++/Contents/3DPhysics_Basic/HelloPolycodeApp.cpp
  29. 1 1
      Examples/C++/Contents/3DPhysics_Character/HelloPolycodeApp.cpp
  30. 1 1
      Examples/C++/Contents/3DPhysics_CollisionOnly/HelloPolycodeApp.cpp
  31. 1 1
      Examples/C++/Contents/3DPhysics_Contacts/HelloPolycodeApp.cpp
  32. 1 1
      Examples/C++/Contents/3DPhysics_RayTest/HelloPolycodeApp.cpp
  33. 1 1
      Examples/C++/Contents/3DPhysics_Vehicle/HelloPolycodeApp.cpp
  34. 1 1
      Examples/C++/Contents/AdvancedLighting/HelloPolycodeApp.cpp
  35. 1 1
      Examples/C++/Contents/BasicImage/HelloPolycodeApp.cpp
  36. 1 1
      Examples/C++/Contents/BasicLighting/HelloPolycodeApp.cpp
  37. 1 1
      Examples/C++/Contents/BasicText/HelloPolycodeApp.cpp
  38. 1 1
      Examples/C++/Contents/EventHandling/HelloPolycodeApp.cpp
  39. 1 1
      Examples/C++/Contents/KeyboardInput/HelloPolycodeApp.cpp
  40. 1 1
      Examples/C++/Contents/MouseInput/HelloPolycodeApp.cpp
  41. 1 1
      Examples/C++/Contents/Networking_Client/HelloPolycodeApp.cpp
  42. 1 1
      Examples/C++/Contents/Networking_Server/HelloPolycodeApp.cpp
  43. 1 1
      Examples/C++/Contents/PlayingSounds/HelloPolycodeApp.cpp
  44. 1 1
      Examples/C++/Contents/ScreenEntities/HelloPolycodeApp.cpp
  45. 1 1
      Examples/C++/Contents/ScreenSprites/HelloPolycodeApp.cpp
  46. 1 1
      Examples/C++/Contents/SkeletalAnimation/HelloPolycodeApp.cpp
  47. 1 1
      Examples/C++/Contents/UpdateLoop/HelloPolycodeApp.cpp
  48. 6 6
      IDE/Contents/Source/NewFileWindow.cpp
  49. 1 1
      IDE/Contents/Source/PolycodeIDEApp.cpp
  50. 4 0
      Modules/Contents/2DPhysics/Include/PolyPhysicsScreen.h
  51. 30 6
      Modules/Contents/2DPhysics/Source/PolyPhysicsScreen.cpp
  52. 9 3
      Modules/Contents/2DPhysics/Source/PolyPhysicsScreenEntity.cpp
  53. 2 1
      Modules/Contents/3DPhysics/Source/PolyCollisionScene.cpp
  54. 3 1
      Modules/Contents/UI/Source/PolyUIButton.cpp
  55. 3 1
      Player/Contents/Source/PolycodePlayer.cpp

+ 4 - 1
Core/Contents/Include/PolyCocoaCore.h

@@ -107,7 +107,10 @@ namespace Polycode {
 		
 		void enableMouse(bool newval);
 		unsigned int getTicks();		
-		bool Update();		
+		bool Update();
+		
+		void Render();
+								
 		void setVideoMode(int xRes, int yRes, bool fullScreen, bool vSync, int aaLevel, int anisotropyLevel);		
 		void resizeTo(int xRes, int yRes);
 		void createThread(Threaded *target);		

+ 3 - 0
Core/Contents/Include/PolyCore.h

@@ -89,6 +89,9 @@ namespace Polycode {
 		
 		virtual bool Update() = 0;
 
+		virtual void Render() = 0;
+		
+		bool updateAndRender();
 		
 		/**
 		* Show or hide cursor.

+ 2 - 1
Core/Contents/Include/PolyCoreServices.h

@@ -64,7 +64,8 @@ namespace Polycode {
 			*/			
 			Renderer *getRenderer();
 			
-			void Update(int elapsed, bool updateRenderer);
+			void Update(int elapsed);
+			void Render();
 			
 			void setCore(Core *core);
 		

+ 1 - 1
Core/Contents/Include/PolyMatrix4.h

@@ -265,7 +265,7 @@ namespace Polycode {
 				
 				*ax = -fabs(angle_x);
 				*ay = fabs(angle_y);
-				*az = fabs(angle_z);
+				*az = -fabs(angle_z);
 
 			}
 		

+ 4 - 1
Core/Contents/Include/PolySceneManager.h

@@ -37,7 +37,10 @@ namespace Polycode {
 		
 		void addScene(Scene *newScene);
 		void Update();
-		void UpdateVirtual();
+		void Render();
+		
+		void renderVirtual();
+				
 		void removeScene(Scene *scene);	
 		void registerRenderTexture(SceneRenderTexture *renderTexture);
 		void unregisterRenderTexture(SceneRenderTexture *renderTexture);

+ 1 - 0
Core/Contents/Include/PolyScreenManager.h

@@ -44,6 +44,7 @@ namespace Polycode {
 		void removeScreen(Screen *screen);
 		void addScreen(Screen* screen);
 		void Update();
+		void Render();
 		
 		void handleEvent(Event *event);
 		

+ 15 - 9
Core/Contents/Source/PolyCocoaCore.mm

@@ -529,29 +529,35 @@ vector<String> CocoaCore::openFilePicker(vector<CoreFileExtension> extensions, b
 	return retVector;
 }
 
-bool CocoaCore::Update() {
-	if(!running)
-		return false;
-	
+void CocoaCore::Render() {
 	lockMutex(CoreServices::getRenderMutex());	
 	checkEvents();
 	
 	if(!paused) {	
 		renderer->BeginRender();
 	}
-	
-	updateCore();
-		
+
+	services->Render();
+
 	if(!paused) {		
 		renderer->EndRender();
 		[context flushBuffer];
 	}
 	
-	unlockMutex(CoreServices::getRenderMutex());	
-	doSleep();	
+	unlockMutex(CoreServices::getRenderMutex());
+}
+
+bool CocoaCore::Update() {
+	if(!running)
+		return false;
+	doSleep();
+		
+	updateCore();		
 	return running;
 }
 
+
+
 static void hatValueToXY(CFIndex value, CFIndex range, int * outX, int * outY) {
 	if (value == range) {
 		*outX = *outY = 0;

+ 7 - 1
Core/Contents/Source/PolyCore.cpp

@@ -182,6 +182,12 @@ namespace Polycode {
 			unlockMutex(threadedEventMutex);			
 		}
 	}
+	
+	bool Core::updateAndRender() {
+		bool ret = Update();
+		Render();
+		return ret;
+	}
 							
 	void Core::updateCore() {
 		frames++;
@@ -191,7 +197,7 @@ namespace Polycode {
 		if(elapsed > 1000)
 			elapsed = 1000;
 			
-		services->Update(elapsed, !paused);
+		services->Update(elapsed);
 		
 		if(frameTicks-lastFPSTicks >= 1000) {
 			fps = frames;

+ 24 - 27
Core/Contents/Source/PolyCoreServices.cpp

@@ -209,39 +209,36 @@ Renderer *CoreServices::getRenderer() {
 	return renderer;
 }
 
-void CoreServices::Update(int elapsed, bool updateRenderer) {
-	
-	for(int i=0; i < updateModules.size(); i++) {
-		updateModules[i]->Update(elapsed);
-	}
+void CoreServices::Render() {
+	if(renderer->doClearBuffer)		
+		renderer->clearScreen();
+
+	renderer->setPerspectiveMode();
+	sceneManager->renderVirtual();
+	if(renderer->doClearBuffer)
+		renderer->clearScreen();					
 
-	timerManager->Update();
-	
-	tweenManager->Update();
-	
-	if(updateRenderer) {
-		
-	materialManager->Update(elapsed);	
 	if(drawScreensFirst) {
-		if(renderer->doClearBuffer)
-			renderer->clearScreen();	
-		renderer->setPerspectiveMode();
-		sceneManager->UpdateVirtual();
-		if(renderer->doClearBuffer)		
-			renderer->clearScreen();					
-		screenManager->Update();
+		screenManager->Render();
 		renderer->setPerspectiveMode();
-		sceneManager->Update();	
+		sceneManager->Render();	
 	} else {
-		renderer->setPerspectiveMode();
-		sceneManager->UpdateVirtual();
-		if(renderer->doClearBuffer)		
-			renderer->clearScreen();		
-		sceneManager->Update();
-		screenManager->Update();	
+		sceneManager->Render();
+		screenManager->Render();	
 	}
+}
+
+void CoreServices::Update(int elapsed) {
 	
-	}	
+	for(int i=0; i < updateModules.size(); i++) {
+		updateModules[i]->Update(elapsed);
+	}
+
+	timerManager->Update();	
+	tweenManager->Update();	
+	materialManager->Update(elapsed);		
+	sceneManager->Update();
+	screenManager->Update();	
 }
 
 SoundManager *CoreServices::getSoundManager() {

+ 4 - 2
Core/Contents/Source/PolyScene.cpp

@@ -94,7 +94,10 @@ bool Scene::isEnabled() {
 }
 
 void Scene::Update() {
-
+	for(int i=0; i<entities.size();i++) {
+		entities[i]->doUpdates();		
+		entities[i]->updateEntityMatrix();
+	}
 }
 
 Scene::~Scene() {
@@ -169,7 +172,6 @@ void Scene::Render(Camera *targetCamera) {
 	
 	// prepare lights...
 	for(int i=0; i<entities.size();i++) {
-		entities[i]->doUpdates();		
 		entities[i]->updateEntityMatrix();
 	}	
 	

+ 10 - 3
Core/Contents/Source/PolySceneManager.cpp

@@ -70,7 +70,7 @@ void SceneManager::addScene(Scene *newScene) {
 void SceneManager::updateRenderTextures(Scene *scene) {
 }
 
-void SceneManager::UpdateVirtual() {
+void SceneManager::renderVirtual() {
 	for(int i=0;i<renderTextures.size();i++) {
 		CoreServices::getInstance()->getRenderer()->setViewportSize(renderTextures[i]->getTargetTexture()->getWidth(), renderTextures[i]->getTargetTexture()->getHeight());
 		CoreServices::getInstance()->getRenderer()->loadIdentity();
@@ -93,12 +93,11 @@ void SceneManager::UpdateVirtual() {
 
 }
 
-void SceneManager::Update() {
+void SceneManager::Render() {
 	for(int i=0;i<scenes.size();i++) {
 		if(scenes[i]->isEnabled() && !scenes[i]->isVirtual()) {
 			CoreServices::getInstance()->getRenderer()->loadIdentity();
 			Scene *scene = scenes[i];
-			scene->Update();
 			if(scene->getActiveCamera()->hasFilterShader()) {
 				scene->getActiveCamera()->drawFilter();
 			} else {
@@ -107,3 +106,11 @@ void SceneManager::Update() {
 		}
 	}
 }
+
+void SceneManager::Update() {
+	for(int i=0;i<scenes.size();i++) {
+		if(scenes[i]->isEnabled()) {
+			scenes[i]->Update();
+		}
+	}
+}

+ 1 - 4
Core/Contents/Source/PolyScreen.cpp

@@ -198,15 +198,12 @@ void Screen::Shutdown() {
 }
 
 void Screen::Update() {
-
+	rootEntity.doUpdates();
 }
 
 void Screen::Render() {
-	Update();
 	renderer->loadIdentity();
 	renderer->translate2D(offset.x, offset.y);
-
-	rootEntity.doUpdates();
 	rootEntity.updateEntityMatrix();
 	rootEntity.transformAndRender();	
 }

+ 9 - 21
Core/Contents/Source/PolyScreenManager.cpp

@@ -57,27 +57,7 @@ void ScreenManager::handleEvent(Event *event) {
 //	}
 }
 
-/*
-Screen *ScreenManager::createScreen(int screenType) {
-
-	Screen *screen;
-	switch(screenType) {
-		case REGULAR_SCREEN:
-			screen = new Screen();
-		break;
-		case PHYSICS_SCREEN:
-			screen = new PhysicsScreen();
-		break;
-	}
-	
-	screen->setRenderer(CoreServices::getInstance()->getRenderer());
-	screens.push_back(screen);
-	return screen;
-}
-*/
-
-void ScreenManager::Update() {
-
+void ScreenManager::Render() {
 	Renderer *renderer = CoreServices::getInstance()->getRenderer();
 	for(int i=0;i<screens.size();i++) {
 		if(screens[i]->enabled) {
@@ -97,3 +77,11 @@ void ScreenManager::Update() {
 		}
 	}
 }
+
+void ScreenManager::Update() {
+	for(int i=0;i<screens.size();i++) {
+		if(screens[i]->enabled) {
+			screens[i]->Update();
+		}
+	}
+}

+ 2 - 2
Core/Contents/Source/PolyScreenMesh.cpp

@@ -77,11 +77,11 @@ void ScreenMesh::setTexture(Texture *texture) {
 }
 
 void ScreenMesh::loadTexture(const String& fileName) {
-	texture = CoreServices::getInstance()->getMaterialManager()->createTextureFromFile(fileName, true, false);
+	texture = CoreServices::getInstance()->getMaterialManager()->createTextureFromFile(fileName, false, true);
 }
 
 void ScreenMesh::loadTexture(Image *image) {
-	texture = CoreServices::getInstance()->getMaterialManager()->createTextureFromImage(image, true, false);
+	texture = CoreServices::getInstance()->getMaterialManager()->createTextureFromImage(image, false, true);
 }
 
 void ScreenMesh::Render() {	

+ 1 - 1
Examples/C++/Contents/2DAudio/HelloPolycodeApp.cpp

@@ -40,5 +40,5 @@ bool HelloPolycodeApp::Update() {
 	sourceEntity->setPosition(300 + (sin(positionValue) * 300), 250 + cos(positionValue) * 100); 
 	listenerEntity->setPosition(300 + (sin(listenerPositionValue) * 300), 250); 
 		
-    return core->Update();
+    return core->updateAndRender();
 }

+ 1 - 1
Examples/C++/Contents/2DParticles/HelloPolycodeApp.cpp

@@ -54,6 +54,6 @@ HelloPolycodeApp::~HelloPolycodeApp() {
 }
 
 bool HelloPolycodeApp::Update() {
-    return core->Update();
+    return core->updateAndRender();
 }
 

+ 1 - 1
Examples/C++/Contents/2DPhysics_Basic/HelloPolycodeApp.cpp

@@ -24,5 +24,5 @@ HelloPolycodeApp::~HelloPolycodeApp() {
 }
 
 bool HelloPolycodeApp::Update() {
-    return core->Update();
+    return core->updateAndRender();
 }

+ 1 - 1
Examples/C++/Contents/2DPhysics_CollisionOnly/HelloPolycodeApp.cpp

@@ -51,5 +51,5 @@ bool HelloPolycodeApp::Update() {
 	Vector2 mouse = core->getInput()->getMousePosition();
 	checkShape->setPosition(mouse.x, mouse.y);
 	checkShape->setRotation(checkShape->getRotation() + (core->getElapsed() * 100));
-    return core->Update();
+    return core->updateAndRender();
 }

+ 1 - 1
Examples/C++/Contents/2DPhysics_Contacts/HelloPolycodeApp.cpp

@@ -40,5 +40,5 @@ HelloPolycodeApp::~HelloPolycodeApp() {
 }
 
 bool HelloPolycodeApp::Update() {
-    return core->Update();
+    return core->updateAndRender();
 }

+ 1 - 1
Examples/C++/Contents/2DPhysics_Joints/HelloPolycodeApp.cpp

@@ -46,5 +46,5 @@ HelloPolycodeApp::~HelloPolycodeApp() {
 }
 
 bool HelloPolycodeApp::Update() {
-    return core->Update();
+    return core->updateAndRender();
 }

+ 1 - 1
Examples/C++/Contents/2DPhysics_PointCollision/HelloPolycodeApp.cpp

@@ -33,5 +33,5 @@ bool HelloPolycodeApp::Update() {
 		entity->setColor(1.0, 0.0, 0.0, 1.0);
 		lastEntity = entity;
 	}
-    return core->Update();
+    return core->updateAndRender();
 }

+ 1 - 1
Examples/C++/Contents/2DShapes/HelloPolycodeApp.cpp

@@ -31,5 +31,5 @@ HelloPolycodeApp::HelloPolycodeApp(PolycodeView *view) : EventHandler() {
 }
 
 bool HelloPolycodeApp::Update() {
-    return core->Update();
+    return core->updateAndRender();
 }

+ 1 - 1
Examples/C++/Contents/2DTransforms/HelloPolycodeApp.cpp

@@ -22,5 +22,5 @@ HelloPolycodeApp::~HelloPolycodeApp() {
 }
 
 bool HelloPolycodeApp::Update() {
-    return core->Update();
+    return core->updateAndRender();
 }

+ 1 - 1
Examples/C++/Contents/3DAudio/HelloPolycodeApp.cpp

@@ -39,5 +39,5 @@ bool HelloPolycodeApp::Update() {
 	sourceEntity->Roll(core->getElapsed() * 120);
 	sourceEntity->Pitch(core->getElapsed()* 120);	
 		
-    return core->Update();
+    return core->updateAndRender();
 }

+ 1 - 1
Examples/C++/Contents/3DBasics/HelloPolycodeApp.cpp

@@ -26,5 +26,5 @@ HelloPolycodeApp::~HelloPolycodeApp() {
 }
 
 bool HelloPolycodeApp::Update() {
-    return core->Update();
+    return core->updateAndRender();
 }

+ 1 - 1
Examples/C++/Contents/3DMeshParticles/HelloPolycodeApp.cpp

@@ -75,5 +75,5 @@ HelloPolycodeApp::~HelloPolycodeApp() {
 }
 
 bool HelloPolycodeApp::Update() {
-    return core->Update();
+    return core->updateAndRender();
 }

+ 1 - 1
Examples/C++/Contents/3DParticles/HelloPolycodeApp.cpp

@@ -68,5 +68,5 @@ HelloPolycodeApp::~HelloPolycodeApp() {
 }
 
 bool HelloPolycodeApp::Update() {
-    return core->Update();
+    return core->updateAndRender();
 }

+ 1 - 1
Examples/C++/Contents/3DPhysics_Basic/HelloPolycodeApp.cpp

@@ -31,5 +31,5 @@ HelloPolycodeApp::~HelloPolycodeApp() {
 }
 
 bool HelloPolycodeApp::Update() {
-    return core->Update();
+    return core->updateAndRender();
 }

+ 1 - 1
Examples/C++/Contents/3DPhysics_Character/HelloPolycodeApp.cpp

@@ -121,5 +121,5 @@ bool HelloPolycodeApp::Update() {
 	}
 	
 	
-    return core->Update();
+    return core->updateAndRender();
 }

+ 1 - 1
Examples/C++/Contents/3DPhysics_CollisionOnly/HelloPolycodeApp.cpp

@@ -46,5 +46,5 @@ bool HelloPolycodeApp::Update() {
 		bigBox->setColor(0.0,1.0,1.0,0.5);	
 	}
 	
-    return core->Update();
+    return core->updateAndRender();
 }

+ 1 - 1
Examples/C++/Contents/3DPhysics_Contacts/HelloPolycodeApp.cpp

@@ -35,5 +35,5 @@ void HelloPolycodeApp::handleEvent(Event *event) {
 }
 
 bool HelloPolycodeApp::Update() {
-    return core->Update();
+    return core->updateAndRender();
 }

+ 1 - 1
Examples/C++/Contents/3DPhysics_RayTest/HelloPolycodeApp.cpp

@@ -67,5 +67,5 @@ void HelloPolycodeApp::handleEvent(Event *e) {
 
 bool HelloPolycodeApp::Update() {
 	Number elapsed = core->getElapsed();
-    return core->Update();
+    return core->updateAndRender();
 }

+ 1 - 1
Examples/C++/Contents/3DPhysics_Vehicle/HelloPolycodeApp.cpp

@@ -171,5 +171,5 @@ bool HelloPolycodeApp::Update() {
 	} else {
 		testBox->setColor(0.0,1.0,1.0,0.5);	
 	}
-    return core->Update();
+    return core->updateAndRender();
 }

+ 1 - 1
Examples/C++/Contents/AdvancedLighting/HelloPolycodeApp.cpp

@@ -63,5 +63,5 @@ HelloPolycodeApp::~HelloPolycodeApp() {
 }
 
 bool HelloPolycodeApp::Update() {
-    return core->Update();
+    return core->updateAndRender();
 }

+ 1 - 1
Examples/C++/Contents/BasicImage/HelloPolycodeApp.cpp

@@ -16,5 +16,5 @@ HelloPolycodeApp::~HelloPolycodeApp() {
 }
 
 bool HelloPolycodeApp::Update() {
-    return core->Update();
+    return core->updateAndRender();
 }

+ 1 - 1
Examples/C++/Contents/BasicLighting/HelloPolycodeApp.cpp

@@ -30,5 +30,5 @@ HelloPolycodeApp::~HelloPolycodeApp() {
 }
 
 bool HelloPolycodeApp::Update() {
-    return core->Update();
+    return core->updateAndRender();
 }

+ 1 - 1
Examples/C++/Contents/BasicText/HelloPolycodeApp.cpp

@@ -16,5 +16,5 @@ HelloPolycodeApp::~HelloPolycodeApp() {
 }
 
 bool HelloPolycodeApp::Update() {
-    return core->Update();
+    return core->updateAndRender();
 }

+ 1 - 1
Examples/C++/Contents/EventHandling/HelloPolycodeApp.cpp

@@ -25,5 +25,5 @@ void HelloPolycodeApp::handleEvent(Event *e) {
 }
 
 bool HelloPolycodeApp::Update() {
-    return core->Update();
+    return core->updateAndRender();
 }

+ 1 - 1
Examples/C++/Contents/KeyboardInput/HelloPolycodeApp.cpp

@@ -55,5 +55,5 @@ bool HelloPolycodeApp::Update() {
 	Number elapsed = core->getElapsed();
 	image->setRotation(image->getRotation() + elapsed * rotationSpeed);
 	
-    return core->Update();
+    return core->updateAndRender();
 }

+ 1 - 1
Examples/C++/Contents/MouseInput/HelloPolycodeApp.cpp

@@ -41,5 +41,5 @@ void HelloPolycodeApp::handleEvent(Event *e) {
 }
 
 bool HelloPolycodeApp::Update() {
-    return core->Update();
+    return core->updateAndRender();
 }

+ 1 - 1
Examples/C++/Contents/Networking_Client/HelloPolycodeApp.cpp

@@ -146,5 +146,5 @@ void HelloPolycodeApp::handleEvent(Event *event) {
 
 bool HelloPolycodeApp::Update() {
 
-    return core->Update();
+    return core->updateAndRender();
 }

+ 1 - 1
Examples/C++/Contents/Networking_Server/HelloPolycodeApp.cpp

@@ -156,5 +156,5 @@ void HelloPolycodeApp::handleEvent(Event *event) {
 bool HelloPolycodeApp::Update() {
 	updateWorld(core->getElapsed());
 	infoLabel->setText("Example server. ["+String::IntToString(players.size())+" Players]");
-    return core->Update();
+    return core->updateAndRender();
 }

+ 1 - 1
Examples/C++/Contents/PlayingSounds/HelloPolycodeApp.cpp

@@ -31,5 +31,5 @@ void HelloPolycodeApp::handleEvent(Event *e) {
 }
 
 bool HelloPolycodeApp::Update() {
-    return core->Update();
+    return core->updateAndRender();
 }

+ 1 - 1
Examples/C++/Contents/ScreenEntities/HelloPolycodeApp.cpp

@@ -40,6 +40,6 @@ bool HelloPolycodeApp::Update() {
 	planet->setPosition(cosf(planetRotation)*150, sinf(planetRotation)*150);
 	moon->setPosition(cosf(moonRotation)*50, sinf(moonRotation)*50);
 		
-    return core->Update();
+    return core->updateAndRender();
 }
 

+ 1 - 1
Examples/C++/Contents/ScreenSprites/HelloPolycodeApp.cpp

@@ -21,5 +21,5 @@ HelloPolycodeApp::~HelloPolycodeApp() {
 }
 
 bool HelloPolycodeApp::Update() {
-    return core->Update();
+    return core->updateAndRender();
 }

+ 1 - 1
Examples/C++/Contents/SkeletalAnimation/HelloPolycodeApp.cpp

@@ -26,5 +26,5 @@ HelloPolycodeApp::~HelloPolycodeApp() {
 }
 
 bool HelloPolycodeApp::Update() {
-    return core->Update();
+    return core->updateAndRender();
 }

+ 1 - 1
Examples/C++/Contents/UpdateLoop/HelloPolycodeApp.cpp

@@ -18,5 +18,5 @@ HelloPolycodeApp::~HelloPolycodeApp() {
 bool HelloPolycodeApp::Update() {
 	Number elapsed = core->getElapsed();
 	image->setRotation(image->getRotation()+(elapsed*100));
-    return core->Update();
+    return core->updateAndRender();
 }

+ 6 - 6
IDE/Contents/Source/NewFileWindow.cpp

@@ -22,7 +22,7 @@
  
 #include "NewFileWindow.h"
 
-NewFileWindow::NewFileWindow() : UIWindow(L"Create New File", 480, 280) {
+NewFileWindow::NewFileWindow() : UIWindow(L"Create New File", 580, 280) {
 	defaultTemplateTree = NULL;
 	
 	Config *conf = CoreServices::getInstance()->getConfig();	
@@ -31,7 +31,7 @@ NewFileWindow::NewFileWindow() : UIWindow(L"Create New File", 480, 280) {
 	
 	closeOnEscape = true;	
 	
-	templateContainer = new UITreeContainer("boxIcon.png", L"File Templates", 200, 300-topPadding-padding-padding);	
+	templateContainer = new UITreeContainer("boxIcon.png", L"File Templates", 250, 300-topPadding-padding-padding);	
 	
 	FileTemplateUserData *data = new FileTemplateUserData();
 	data->type = 0;
@@ -64,9 +64,9 @@ NewFileWindow::NewFileWindow() : UIWindow(L"Create New File", 480, 280) {
 	label2->setText("NEW FILE NAME (NO EXTENSION)");
 		
 	addChild(label2);
-	label2->setPosition(padding+220, templateContainer->getPosition().y-5);			
+	label2->setPosition(padding+270, templateContainer->getPosition().y-5);			
 	
-	fileNameInput = new UITextInput(false, 500-padding-210-padding-padding, 12);	
+	fileNameInput = new UITextInput(false, 550-padding-210-padding-padding, 12);	
 	addChild(fileNameInput);
 	fileNameInput->setPosition(label2->getPosition().x, label2->getPosition().y+30);
 	
@@ -74,12 +74,12 @@ NewFileWindow::NewFileWindow() : UIWindow(L"Create New File", 480, 280) {
 	cancelButton = new UIButton(L"Cancel", 100);
 	cancelButton->addEventListener(this, UIEvent::CLICK_EVENT);
 	addChild(cancelButton);
-	cancelButton->setPosition(500-100-padding-100-10, 265);
+	cancelButton->setPosition(600-100-padding-100-10, 265);
 			
 	okButton = new UIButton(L"Create File", 100);
 	okButton->addEventListener(this, UIEvent::CLICK_EVENT);
 	addChild(okButton);
-	okButton->setPosition(500-100-padding, 265);	
+	okButton->setPosition(600-100-padding, 265);	
 }
 
 NewFileWindow::~NewFileWindow() {

+ 1 - 1
IDE/Contents/Source/PolycodeIDEApp.cpp

@@ -822,6 +822,6 @@ bool PolycodeIDEApp::Update() {
 	}
 
 
-	return core->Update();
+	return core->updateAndRender();
 }
 

+ 4 - 0
Modules/Contents/2DPhysics/Include/PolyPhysicsScreen.h

@@ -381,6 +381,8 @@ public:
 	*/
 	bool testEntityCollision(ScreenEntity *ent1, ScreenEntity *ent2);
 	
+	bool isEntityColliding(ScreenEntity *ent1);
+	
 	void Shutdown();
 	
 	/**
@@ -394,6 +396,8 @@ public:
 
     
 protected:
+
+	Number cyclesLeftOver;
 	
     Number worldScale;
     

+ 30 - 6
Modules/Contents/2DPhysics/Source/PolyPhysicsScreen.cpp

@@ -24,6 +24,8 @@ THE SOFTWARE.
 #include "PolyPhysicsScreen.h"
 #include "PolyScreenEntity.h"
 #include "PolyPhysicsScreenEntity.h"
+#include "PolyCoreServices.h"
+#include "PolyCore.h"
 
 using namespace Polycode;
 
@@ -157,6 +159,21 @@ void PhysicsScreen::EndContact (b2Contact *contact) {
 	dispatchEvent(newEvent, PhysicsScreenEvent::EVENT_END_SHAPE_COLLISION);
 }
 
+bool PhysicsScreen::isEntityColliding(ScreenEntity *ent1) {
+	PhysicsScreenEntity *pEnt1 = getPhysicsByScreenEntity(ent1);
+	if(pEnt1 == NULL)
+		return false;
+
+	for(int i=0; i < contacts.size(); i++) {
+		ScreenEntity *cEnt1 = ((PhysicsScreenEntity*)contacts[i]->GetFixtureA()->GetBody()->GetUserData())->getScreenEntity();
+		ScreenEntity *cEnt2 = ((PhysicsScreenEntity*)contacts[i]->GetFixtureB()->GetBody()->GetUserData())->getScreenEntity();
+		if(cEnt1 == ent1 || cEnt2 == ent1) {
+			return true;
+		}
+	}
+	return false;
+}
+
 bool PhysicsScreen::testEntityCollision(ScreenEntity *ent1, ScreenEntity *ent2) {
 	PhysicsScreenEntity *pEnt1 = getPhysicsByScreenEntity(ent1);
 	PhysicsScreenEntity *pEnt2 = getPhysicsByScreenEntity(ent2);	
@@ -164,8 +181,8 @@ bool PhysicsScreen::testEntityCollision(ScreenEntity *ent1, ScreenEntity *ent2)
 		return false;
 	
 	for(int i=0; i < contacts.size(); i++) {
-		ScreenEntity *cEnt1 = (ScreenEntity*)contacts[i]->GetFixtureA()->GetUserData();
-		ScreenEntity *cEnt2 = (ScreenEntity*)contacts[i]->GetFixtureB()->GetUserData();
+		ScreenEntity *cEnt1 = ((PhysicsScreenEntity*)contacts[i]->GetFixtureA()->GetBody()->GetUserData())->getScreenEntity();
+		ScreenEntity *cEnt2 = ((PhysicsScreenEntity*)contacts[i]->GetFixtureB()->GetBody()->GetUserData())->getScreenEntity();
 		
 	        
 		if((cEnt1 == ent1 && cEnt2 == ent2) || (cEnt1 == ent2 && cEnt2 == ent1)) {
@@ -185,6 +202,7 @@ PhysicsScreen::PhysicsScreen(Number worldScale, Number freq, int velIterations,
 
 void PhysicsScreen::init(Number worldScale, Number physicsTimeStep, int velIterations, int posIterations, Vector2 physicsGravity) {
 	
+	cyclesLeftOver = 0.0;
 	this->worldScale = worldScale;
 	
 	timeStep = physicsTimeStep;
@@ -519,9 +537,15 @@ void PhysicsScreen::handleEvent(Event *event) {
 
 void PhysicsScreen::Update() {
     
-	for(int i=0; i<physicsChildren.size();i++) {
-		physicsChildren[i]->Update();
+	Number elapsed = CoreServices::getInstance()->getCore()->getElapsed() + cyclesLeftOver;
+	
+	while(elapsed > timeStep) {
+		elapsed -= timeStep;
+		for(int i=0; i<physicsChildren.size();i++) {
+			physicsChildren[i]->Update();
+		}
+		world->Step(timeStep, velocityIterations,positionIterations);
 	}
-    
-	world->Step(timeStep, velocityIterations,positionIterations);	
+	cyclesLeftOver = elapsed;
+	Screen::Update();
 }

+ 9 - 3
Modules/Contents/2DPhysics/Source/PolyPhysicsScreenEntity.cpp

@@ -230,11 +230,17 @@ void PhysicsScreenEntity::setTransform(Vector2 pos, Number angle) {
 
 void PhysicsScreenEntity::Update() {
 	if(collisionOnly) {
+		Matrix4 matrix = screenEntity->getConcatenatedMatrix();
+		Vector3 pos = matrix.getPosition();		
 		b2Vec2 newPos;
-		newPos.x = screenEntity->position.x/worldScale;;
-		newPos.y = screenEntity->position.y/worldScale;;
+		newPos.x = pos.x/worldScale;
+		newPos.y = pos.y/worldScale;   
+		
+		Number rx,ry,rz;
+		matrix.getEulerAngles(&rx, &ry, &rz);
+		
 		body->SetAwake(true);
-		body->SetTransform(newPos, screenEntity->rotation.roll * TORADIANS);
+		body->SetTransform(newPos, rz * TORADIANS);
 	} else {
 		b2Vec2 position = body->GetPosition();
 		Number angle = body->GetAngle();	

+ 2 - 1
Modules/Contents/3DPhysics/Source/PolyCollisionScene.cpp

@@ -56,7 +56,8 @@ void CollisionScene::Update() {
 	for(int i=0; i < collisionChildren.size(); i++) {
 		if(collisionChildren[i]->enabled)		
 			collisionChildren[i]->lastPosition = collisionChildren[i]->getSceneEntity()->getPosition();
-	}	
+	}
+	Scene::Update();	
 }
 
 void CollisionScene::enableCollision(SceneEntity *entity, bool val) {

+ 3 - 1
Modules/Contents/UI/Source/PolyUIButton.cpp

@@ -110,7 +110,9 @@ void UIButton::handleEvent(Event *event) {
 		switch(event->getEventCode()) {
 			case InputEvent::EVENT_KEYDOWN:
 				if(hasFocus) {
-					dispatchEvent(new UIEvent(), UIEvent::CLICK_EVENT);					
+					if(((InputEvent*)event)->key == KEY_RETURN || ((InputEvent*)event)->key == KEY_SPACE) {
+						dispatchEvent(new UIEvent(), UIEvent::CLICK_EVENT);
+					}
 				}
 			break;
 		}

+ 3 - 1
Player/Contents/Source/PolycodePlayer.cpp

@@ -882,6 +882,7 @@ void PolycodePlayer::handleEvent(Event *event) {
 
 
 bool PolycodePlayer::Update() {
+	bool retVal = core->Update();
 	if(L) {
 		lua_getfield (L, LUA_GLOBALSINDEX, "__customError");
 		errH = lua_gettop(L);	
@@ -899,5 +900,6 @@ bool PolycodePlayer::Update() {
 		}
 		lua_settop(L, 0);
 	}
-	return core->Update();
+	core->Render();
+	return retVal;
 }