diff --git a/.DS_Store b/.DS_Store index 3845a16..994ffcc 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/Bent.xcodeproj/project.pbxproj b/Bent.xcodeproj/project.pbxproj index 018cf69..6627d00 100644 --- a/Bent.xcodeproj/project.pbxproj +++ b/Bent.xcodeproj/project.pbxproj @@ -393,7 +393,7 @@ CODE_SIGN_STYLE = Automatic; HEADER_SEARCH_PATHS = ""; "HEADER_SEARCH_PATHS[arch=*]" = ( - /ust/local/include, + /usr/local/include, /opt/X11/include, ); "LIBRARY_SEARCH_PATHS[arch=*]" = /usr/local/lib; diff --git a/Bent.xcodeproj/project.xcworkspace/xcuserdata/simondemeule.xcuserdatad/UserInterfaceState.xcuserstate b/Bent.xcodeproj/project.xcworkspace/xcuserdata/simondemeule.xcuserdatad/UserInterfaceState.xcuserstate index d445eb0..1351ebe 100644 Binary files a/Bent.xcodeproj/project.xcworkspace/xcuserdata/simondemeule.xcuserdatad/UserInterfaceState.xcuserstate and b/Bent.xcodeproj/project.xcworkspace/xcuserdata/simondemeule.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Bent.xcodeproj/xcshareddata/xcschemes/project.xcscheme b/Bent.xcodeproj/xcshareddata/xcschemes/project.xcscheme index b1deb30..117075a 100644 --- a/Bent.xcodeproj/xcshareddata/xcschemes/project.xcscheme +++ b/Bent.xcodeproj/xcshareddata/xcschemes/project.xcscheme @@ -27,8 +27,6 @@ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "YES"> - <Testables> - </Testables> <MacroExpansion> <BuildableReference BuildableIdentifier = "primary" @@ -38,8 +36,8 @@ ReferencedContainer = "container:Bent.xcodeproj"> </BuildableReference> </MacroExpansion> - <AdditionalOptions> - </AdditionalOptions> + <Testables> + </Testables> </TestAction> <LaunchAction buildConfiguration = "Debug" @@ -51,7 +49,9 @@ ignoresPersistentStateOnLaunch = "NO" debugDocumentVersioning = "YES" debugServiceExtension = "internal" - allowLocationSimulation = "YES"> + allowLocationSimulation = "YES" + viewDebuggingEnabled = "No" + queueDebuggingEnabled = "No"> <BuildableProductRunnable runnableDebuggingMode = "0"> <BuildableReference @@ -62,8 +62,6 @@ ReferencedContainer = "container:Bent.xcodeproj"> </BuildableReference> </BuildableProductRunnable> - <AdditionalOptions> - </AdditionalOptions> </LaunchAction> <ProfileAction buildConfiguration = "Debug" diff --git a/Bent.xcodeproj/xcuserdata/simondemeule.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/Bent.xcodeproj/xcuserdata/simondemeule.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index 47710fa..f4d6a59 100644 --- a/Bent.xcodeproj/xcuserdata/simondemeule.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/Bent.xcodeproj/xcuserdata/simondemeule.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -1,11 +1,13 @@ <?xml version="1.0" encoding="UTF-8"?> <Bucket + uuid = "8661BC9E-9699-42D8-B41F-81587F4355D0" type = "1" version = "2.0"> <Breakpoints> <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "B1194833-2E26-45F0-BF4E-5655BC9FFF48" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" @@ -22,6 +24,7 @@ <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "27339705-BAF6-451C-969E-E5075A78A2CE" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" @@ -38,6 +41,7 @@ <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "3CE7B300-E0BC-40D8-80F1-3D99FB8D8EB6" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" @@ -54,6 +58,7 @@ <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "8FDB4112-A19D-4D2C-80F2-9DEEBBF0992C" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" @@ -68,6 +73,7 @@ <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "BDA8A142-EF1E-4C3E-A2AC-823458A53E4D" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" @@ -84,6 +90,7 @@ <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "D191E9CE-F36E-4678-AEF9-9718F5255C34" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" @@ -100,6 +107,7 @@ <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "B0EC911A-90D4-424C-9622-317E0B7484AF" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" @@ -116,6 +124,7 @@ <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "B77471F6-6A70-4B4B-9D22-3633E0CD9E3E" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" @@ -132,6 +141,7 @@ <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "B752495B-F3E6-4189-B6BC-3B3692F0FC02" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" @@ -148,6 +158,7 @@ <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "254BCD74-20F1-40D9-9D43-62882552C2FE" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" @@ -161,6 +172,7 @@ landmarkType = "7"> <Locations> <Location + uuid = "254BCD74-20F1-40D9-9D43-62882552C2FE - 3ff0f844d55e879" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" @@ -176,6 +188,7 @@ offsetFromSymbolStart = "141"> </Location> <Location + uuid = "254BCD74-20F1-40D9-9D43-62882552C2FE - 8a472d876f127500" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" @@ -196,6 +209,7 @@ <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "253AE52A-8201-4416-8819-27B2653D7129" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" @@ -212,6 +226,7 @@ <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "BE32327E-4454-4BB2-A957-09A8E747BFEB" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" @@ -228,6 +243,7 @@ <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "4B076078-4C9D-401E-8082-71ABFF9D404A" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" @@ -244,6 +260,7 @@ <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "F1F4D257-E94E-42EE-89DC-423595B2F816" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" @@ -260,6 +277,7 @@ <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "AABE04CF-B3A1-4B56-A907-5B3EA8A73386" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" @@ -276,6 +294,7 @@ <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "284E04D5-2AB0-4BBD-820A-F1D8753F6611" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" @@ -292,6 +311,7 @@ <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "08D5498F-939D-493D-988C-740E4A9C5467" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" @@ -308,6 +328,7 @@ <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "C5810141-D39B-415D-9577-DDF1BB6E6AF9" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" @@ -324,6 +345,7 @@ <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "C2874A32-C33B-4830-BFB9-BD2D5494032E" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" @@ -340,6 +362,7 @@ <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "94720CD6-7B79-4D54-A6B5-214F5849929F" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" @@ -356,19 +379,21 @@ <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "63C521C1-9724-4DCD-ADA3-259F1B2D79B1" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" filePath = "RenderData.cpp" - timestampString = "611119453.781828" + timestampString = "611696172.102031" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "485" - endingLineNumber = "485" - landmarkName = "RenderData::RenderData(std::string workingDirectoryNew, std::string inputFileNameNew, std::string outputFileNameNew)" + startingLineNumber = "520" + endingLineNumber = "520" + landmarkName = "RenderData::RenderData(workingDirectoryNew, inputFileNameNew, outputFileNameNew)" landmarkType = "7"> <Locations> <Location + uuid = "63C521C1-9724-4DCD-ADA3-259F1B2D79B1 - a6121475d9d93d38" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" @@ -384,6 +409,7 @@ offsetFromSymbolStart = "314"> </Location> <Location + uuid = "63C521C1-9724-4DCD-ADA3-259F1B2D79B1 - a6121475d9d93d38" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" @@ -404,6 +430,7 @@ <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "B9F8AAC1-BF34-40A1-9A81-665FE1E9A37A" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" @@ -420,6 +447,7 @@ <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "243DB3FA-D02B-450A-9BD2-08CC9239A00B" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" @@ -436,6 +464,7 @@ <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "7F0FF36A-0BD9-49FB-BCAC-4439425153DC" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" @@ -452,6 +481,7 @@ <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "9F52152D-E5F0-4F8C-9BD3-09B69B94B944" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" @@ -468,6 +498,7 @@ <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "6C921754-276D-4C50-A30F-D0A3507B78B9" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" @@ -484,6 +515,7 @@ <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "36D03E06-8563-4172-AAA1-E73028F2A124" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" @@ -498,22 +530,24 @@ <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "1FF1376A-0455-4D17-9678-4B420D8950E5" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" filePath = "RenderData.cpp" - timestampString = "611119453.7821701" + timestampString = "611696172.102187" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "481" - endingLineNumber = "481" - landmarkName = "RenderData::RenderData(int outputWidthNew, int tileSizeNew, int antiAliasingPassesRootNew, int threadCountNew, int recursionLimitNew, std::string workingDirectoryNew, std::string outputFileNameNew)" + startingLineNumber = "516" + endingLineNumber = "516" + landmarkName = "RenderData::RenderData(outputWidthNew, tileSizeNew, antiAliasingPassesRootNew, threadCountNew, recursionLimitNew, workingDirectoryNew, outputFileNameNew)" landmarkType = "7"> </BreakpointContent> </BreakpointProxy> <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "456CAAC9-3394-4502-AFA9-FF48217803B1" shouldBeEnabled = "Yes" ignoreCount = "0" continueAfterRunningActions = "No" @@ -530,22 +564,24 @@ <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "7C6C4ED0-7330-4940-967C-E19D0B2BD5C2" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" filePath = "BoundingBox.cpp" - timestampString = "611119453.782279" + timestampString = "611696172.102277" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" startingLineNumber = "104" endingLineNumber = "104" - landmarkName = "BoundingBox::distanceEnd(glm::vec3 point)" + landmarkName = "BoundingBox::distanceEnd(point)" landmarkType = "7"> </BreakpointContent> </BreakpointProxy> <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "3CBADD89-D70A-4E96-B405-12D2B3440982" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" @@ -560,6 +596,7 @@ <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "E34849DC-9C12-4A34-834E-C232F8DD760E" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" @@ -574,6 +611,7 @@ <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.SymbolicBreakpoint"> <BreakpointContent + uuid = "076147CF-85D9-4D9F-8DD3-B81F1C7D1B83" shouldBeEnabled = "Yes" ignoreCount = "0" continueAfterRunningActions = "No" @@ -581,6 +619,7 @@ moduleName = ""> <Locations> <Location + uuid = "076147CF-85D9-4D9F-8DD3-B81F1C7D1B83 - 9d096611641b4e7c" shouldBeEnabled = "Yes" ignoreCount = "0" continueAfterRunningActions = "No" @@ -595,19 +634,21 @@ <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "F72460BA-A5CD-4FFE-A1B9-743A016CFBFE" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" filePath = "RenderData.cpp" - timestampString = "611119453.78247" + timestampString = "611696172.102355" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "482" - endingLineNumber = "482" - landmarkName = "RenderData::RenderData(int outputWidthNew, int tileSizeNew, int antiAliasingPassesRootNew, int threadCountNew, int recursionLimitNew, std::string workingDirectoryNew, std::string outputFileNameNew)" + startingLineNumber = "517" + endingLineNumber = "517" + landmarkName = "RenderData::RenderData(outputWidthNew, tileSizeNew, antiAliasingPassesRootNew, threadCountNew, recursionLimitNew, workingDirectoryNew, outputFileNameNew)" landmarkType = "7"> <Locations> <Location + uuid = "F72460BA-A5CD-4FFE-A1B9-743A016CFBFE - a6121475d9d93d38" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" @@ -623,6 +664,7 @@ offsetFromSymbolStart = "380"> </Location> <Location + uuid = "F72460BA-A5CD-4FFE-A1B9-743A016CFBFE - a6121475d9d93d38" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" @@ -643,6 +685,7 @@ <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "334EC48C-D120-4259-A8FD-0E1777ACE7F0" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" @@ -659,31 +702,33 @@ <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "9C22A315-C53A-4212-8E0F-5DB0114DF54F" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" filePath = "MeshPrimitive.cpp" - timestampString = "611119453.7825741" + timestampString = "611696172.1024539" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" startingLineNumber = "124" endingLineNumber = "124" - landmarkName = "MeshPrimitive::intersection(Ray ray)" + landmarkName = "MeshPrimitive::intersection(ray)" landmarkType = "7"> </BreakpointContent> </BreakpointProxy> <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "EB1848C6-7500-4F9F-BE07-A519571EC57F" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" filePath = "RenderData.cpp" - timestampString = "611119453.782719" + timestampString = "611696172.102522" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "363" - endingLineNumber = "363" + startingLineNumber = "360" + endingLineNumber = "360" landmarkName = "RenderData::loadTest()" landmarkType = "7"> </BreakpointContent> @@ -691,115 +736,106 @@ <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "574132AA-A08D-4FB9-839C-88E45FBF7C23" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" filePath = "MeshPrimitive.cpp" - timestampString = "611119453.782801" + timestampString = "611696172.102581" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" startingLineNumber = "115" endingLineNumber = "115" - landmarkName = "MeshPrimitive::intersection(Ray ray)" + landmarkName = "MeshPrimitive::intersection(ray)" landmarkType = "7"> </BreakpointContent> </BreakpointProxy> <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "DB87EA6D-1532-4768-B243-526FB0FB2EE2" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" filePath = "Sphere.cpp" - timestampString = "611119453.782843" + timestampString = "611696172.102656" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" startingLineNumber = "19" endingLineNumber = "19" - landmarkName = "Sphere::Sphere(glm::vec3 originNew, float radiusNew, ShadableAttributes* shadableAttributesNew)" - landmarkType = "7"> - </BreakpointContent> - </BreakpointProxy> - <BreakpointProxy - BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> - <BreakpointContent - shouldBeEnabled = "No" - ignoreCount = "0" - continueAfterRunningActions = "No" - filePath = "RenderCore.cpp" - timestampString = "611119453.782984" - startingColumnNumber = "9223372036854775807" - endingColumnNumber = "9223372036854775807" - startingLineNumber = "40" - endingLineNumber = "40" - landmarkName = "RenderCore::marchFields(std::list<Field*> fields, Ray ray, float step, DistanceMeasure safeZone, int recursionDepth)" + landmarkName = "Sphere::Sphere(originNew, radiusNew, shadableAttributesNew)" landmarkType = "7"> </BreakpointContent> </BreakpointProxy> <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "1B3653BE-297F-481D-BCB2-9970BECA3780" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" filePath = "RenderCore.cpp" - timestampString = "611119453.78318" + timestampString = "611696172.10271" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "135" - endingLineNumber = "135" - landmarkName = "RenderCore::closestIntersectionThroughFields(Ray ray, int recursionDepth)" + startingLineNumber = "72" + endingLineNumber = "72" + landmarkName = "RenderCore::marchFields(fields, ray, step, safeZoneIntersection, safeZoneField, recursionDepth)" landmarkType = "7"> </BreakpointContent> </BreakpointProxy> <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "7711C735-A651-4AA5-870E-F7C16DFF2865" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" filePath = "RenderCore.cpp" - timestampString = "611119453.783275" + timestampString = "611696172.103103" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "145" - endingLineNumber = "145" - landmarkName = "RenderCore::closestIntersectionThroughFields(Ray ray, int recursionDepth)" + startingLineNumber = "213" + endingLineNumber = "213" + landmarkName = "RenderCore::closestIntersectionThroughFields(ray, recursionDepth)" landmarkType = "7"> </BreakpointContent> </BreakpointProxy> <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "867F4341-64BF-4A4D-8530-926D965824F3" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" filePath = "Field.cpp" - timestampString = "611119453.783366" + timestampString = "611696172.103398" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" startingLineNumber = "13" endingLineNumber = "13" - landmarkName = "Field::intersection(Ray ray)" + landmarkName = "Field::intersection(ray)" landmarkType = "7"> </BreakpointContent> </BreakpointProxy> <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "464B1FA0-A550-4DAB-8C9C-2E16BA304F74" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" filePath = "BoundedHierarchy.hpp" - timestampString = "611119453.783506" + timestampString = "611696172.103462" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" startingLineNumber = "182" endingLineNumber = "182" - landmarkName = "closestIntersection(Ray ray)" + landmarkName = "closestIntersection(ray)" landmarkType = "7"> <Locations> <Location + uuid = "464B1FA0-A550-4DAB-8C9C-2E16BA304F74 - b055f51a129c036a" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" @@ -815,6 +851,7 @@ offsetFromSymbolStart = "26"> </Location> <Location + uuid = "464B1FA0-A550-4DAB-8C9C-2E16BA304F74 - c79efa7705a57aaa" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" @@ -835,67 +872,72 @@ <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "2C6AED08-AF34-46AF-8723-82E43A828F9B" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" filePath = "RenderCore.cpp" - timestampString = "611119453.783658" + timestampString = "611696172.10351" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "146" - endingLineNumber = "146" - landmarkName = "RenderCore::closestIntersectionThroughFields(Ray ray, int recursionDepth)" + startingLineNumber = "214" + endingLineNumber = "214" + landmarkName = "RenderCore::closestIntersectionThroughFields(ray, recursionDepth)" landmarkType = "7"> </BreakpointContent> </BreakpointProxy> <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "3C8444D0-4BCA-4D8C-BC1F-F230AB1AF87C" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" filePath = "RenderCore.cpp" - timestampString = "611119453.783748" + timestampString = "611696172.1037869" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "149" - endingLineNumber = "149" - landmarkName = "RenderCore::closestIntersectionThroughFields(Ray ray, int recursionDepth)" + startingLineNumber = "219" + endingLineNumber = "219" + landmarkName = "RenderCore::closestIntersectionThroughFields(ray, recursionDepth)" landmarkType = "7"> </BreakpointContent> </BreakpointProxy> <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "86B82C9D-728E-4CCC-AAA2-302F427A0C60" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" filePath = "RenderCore.cpp" - timestampString = "611119453.783832" + timestampString = "611696172.104066" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "151" - endingLineNumber = "151" - landmarkName = "RenderCore::closestIntersectionThroughFields(Ray ray, int recursionDepth)" + startingLineNumber = "221" + endingLineNumber = "221" + landmarkName = "RenderCore::closestIntersectionThroughFields(ray, recursionDepth)" landmarkType = "7"> </BreakpointContent> </BreakpointProxy> <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "D594E404-B9A0-435E-BC52-48323C7C5B42" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" filePath = "FieldCrossProduct.cpp" - timestampString = "611119453.783917" + timestampString = "611696172.104342" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" startingLineNumber = "22" endingLineNumber = "22" - landmarkName = "FieldCrossProduct::FieldCrossProduct(glm::vec3 originNew, glm::vec3 directionNew, float radiusNew, float strengthNew)" + landmarkName = "FieldCrossProduct::FieldCrossProduct(originNew, directionNew, radiusNew, strengthNew)" landmarkType = "7"> <Locations> <Location + uuid = "D594E404-B9A0-435E-BC52-48323C7C5B42 - e2956f5faae1426b" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" @@ -911,6 +953,7 @@ offsetFromSymbolStart = "495"> </Location> <Location + uuid = "D594E404-B9A0-435E-BC52-48323C7C5B42 - e2956f5faae1426b" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" @@ -931,192 +974,187 @@ <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent - shouldBeEnabled = "No" - ignoreCount = "0" - continueAfterRunningActions = "No" - filePath = "RenderCore.cpp" - timestampString = "611119453.784058" - startingColumnNumber = "9223372036854775807" - endingColumnNumber = "9223372036854775807" - startingLineNumber = "137" - endingLineNumber = "137" - landmarkName = "RenderCore::closestIntersectionThroughFields(Ray ray, int recursionDepth)" - landmarkType = "7"> - </BreakpointContent> - </BreakpointProxy> - <BreakpointProxy - BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> - <BreakpointContent + uuid = "047A3B3F-F4E3-4725-8B6C-400463B16BEA" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" filePath = "BoundedHierarchy.hpp" - timestampString = "611119453.784144" + timestampString = "611696172.104382" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "236" - endingLineNumber = "236" - landmarkName = "encompassingObjects(glm::vec3 point)" + startingLineNumber = "266" + endingLineNumber = "266" + landmarkName = "encompassingObjects(point)" landmarkType = "7"> </BreakpointContent> </BreakpointProxy> <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "FCD806F8-2BCA-40B5-A22F-5496BD0D1890" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" filePath = "BoundedHierarchy.hpp" - timestampString = "611119453.784191" + timestampString = "611696172.104423" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "235" - endingLineNumber = "235" - landmarkName = "encompassingObjects(glm::vec3 point)" + startingLineNumber = "265" + endingLineNumber = "265" + landmarkName = "encompassingObjects(point)" landmarkType = "7"> </BreakpointContent> </BreakpointProxy> <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "37335A65-165D-474E-95EC-BD667F2D6C9D" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" filePath = "RenderCore.cpp" - timestampString = "611119453.784232" + timestampString = "611696172.104489" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "52" - endingLineNumber = "52" - landmarkName = "RenderCore::marchFields(std::list<Field*> fields, Ray ray, float step, DistanceMeasure safeZone, int recursionDepth)" + startingLineNumber = "85" + endingLineNumber = "85" + landmarkName = "RenderCore::marchFields(fields, ray, step, safeZoneIntersection, safeZoneField, recursionDepth)" landmarkType = "7"> </BreakpointContent> </BreakpointProxy> <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "D8E20DAA-29F7-4548-A804-FD5481ECCF20" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" - filePath = "RenderCore.cpp" - timestampString = "611119453.784295" + filePath = "FieldAttractor.cpp" + timestampString = "611696172.1050659" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "65" - endingLineNumber = "65" - landmarkName = "RenderCore::marchFields(std::list<Field*> fields, Ray ray, float step, DistanceMeasure safeZone, int recursionDepth)" + startingLineNumber = "24" + endingLineNumber = "24" + landmarkName = "FieldAttractor::deltaRay(ray)" landmarkType = "7"> </BreakpointContent> </BreakpointProxy> <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "959040A3-B5B2-4A6D-876E-1E149C10C294" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" - filePath = "FieldAttractor.cpp" - timestampString = "611119453.78435" + filePath = "BoundedHierarchy.hpp" + timestampString = "611696172.105108" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "24" - endingLineNumber = "24" - landmarkName = "FieldAttractor::deltaRay(Ray ray, float step)" + startingLineNumber = "277" + endingLineNumber = "277" + landmarkName = "encompassingObjects(point)" landmarkType = "7"> </BreakpointContent> </BreakpointProxy> <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "A451C39C-54AD-4A03-9021-17D66CD63290" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" - filePath = "BoundedHierarchy.hpp" - timestampString = "611119453.784483" + filePath = "BoundedNode.hpp" + timestampString = "611696172.1052099" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "247" - endingLineNumber = "247" - landmarkName = "encompassingObjects(glm::vec3 point)" + startingLineNumber = "270" + endingLineNumber = "270" + landmarkName = "encompassingObjects(point)" landmarkType = "7"> </BreakpointContent> </BreakpointProxy> <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "472C675D-313D-4F9B-954F-60B0575FF119" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" filePath = "BoundedNode.hpp" - timestampString = "611119453.784528" + timestampString = "611696172.105275" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "182" - endingLineNumber = "182" - landmarkName = "encompassingObjects(glm::vec3 point)" + startingLineNumber = "285" + endingLineNumber = "285" + landmarkName = "encompassingObjects(point)" landmarkType = "7"> </BreakpointContent> </BreakpointProxy> <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "BA300482-897D-4405-8351-8504C77A0A60" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" filePath = "BoundedNode.hpp" - timestampString = "611119453.7846659" + timestampString = "611696172.105336" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "197" - endingLineNumber = "197" - landmarkName = "encompassingObjects(glm::vec3 point)" + startingLineNumber = "286" + endingLineNumber = "286" + landmarkName = "encompassingObjects(point)" landmarkType = "7"> </BreakpointContent> </BreakpointProxy> <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "A7277202-7F16-4EF8-8E68-135A226A52AD" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" filePath = "BoundedNode.hpp" - timestampString = "611119453.784713" + timestampString = "611696172.105389" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "198" - endingLineNumber = "198" - landmarkName = "encompassingObjects(glm::vec3 point)" + startingLineNumber = "283" + endingLineNumber = "283" + landmarkName = "encompassingObjects(point)" landmarkType = "7"> </BreakpointContent> </BreakpointProxy> <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "21706920-55C5-48A7-A90E-0A211027B5F2" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" filePath = "BoundedNode.hpp" - timestampString = "611119453.784755" + timestampString = "611696172.1054389" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "195" - endingLineNumber = "195" - landmarkName = "encompassingObjects(glm::vec3 point)" + startingLineNumber = "284" + endingLineNumber = "284" + landmarkName = "encompassingObjects(point)" landmarkType = "7"> </BreakpointContent> </BreakpointProxy> <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent + uuid = "8AF669C4-924F-456C-8DF2-4ACF768798B7" shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" - filePath = "BoundedNode.hpp" - timestampString = "611119453.784795" + filePath = "RenderCore.cpp" + timestampString = "611696172.105492" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "196" - endingLineNumber = "196" - landmarkName = "encompassingObjects(glm::vec3 point)" + startingLineNumber = "190" + endingLineNumber = "190" + landmarkName = "RenderCore::marchFields(fields, ray, step, safeZoneIntersection, safeZoneField, recursionDepth)" landmarkType = "7"> </BreakpointContent> </BreakpointProxy> diff --git a/BoundedHierarchy.hpp b/BoundedHierarchy.hpp index 683d4b3..569051a 100644 --- a/BoundedHierarchy.hpp +++ b/BoundedHierarchy.hpp @@ -209,6 +209,36 @@ class BoundedHierarchy { } } + ObjectIntersection closestIntersectionExcluding(Ray ray, Object* objectExcluded) { + if(root == nullptr) { + // case where hirearchy is empty + ObjectIntersection intersection; + intersection.exists = false; + return intersection; + } else if (root->nodeLeft == nullptr && root->nodeRight == nullptr) { + // case where root is leaf + if(root->boundingBox.intersectionTest(ray)) { + return root->object->intersection(ray); + } else { + ObjectIntersection intersection; + intersection.exists = false; + return intersection; + } + } else { + // case where root is internal + + // BoundedNode's recursive function assumes the passed node is known to intersect the ray. + // this means we have to check the intersection with the root node before calling it. + if(root->boundingBox.intersectionTest(ray)) { + return root->closestIntersectionExcluding(ray, objectExcluded); + } else { + ObjectIntersection intersection; + intersection.exists = false; + return intersection; + } + } + } + DistanceMeasure distance(glm::vec3 point) { if(root == nullptr) { // case where hirearchy is empty @@ -252,4 +282,29 @@ class BoundedHierarchy { } } } + + void encompassingObjects(glm::vec3 point, std::list<Object*> &objects) { + if(root == nullptr) { + // case where hirearchy is empty + return; + } else if (root->nodeLeft == nullptr && root->nodeRight == nullptr) { + // case where root is leaf + if(root->boundingBox.containmentTest(point)) { + objects.push_back(root->object); + return; + } else { + return; + } + } else { + // case where root is internal + + // BoundedNode's recursive function assumes the passed node is known to contain the point. + // this means we have to check containment with the root node before calling it. + if(root->boundingBox.containmentTest(point)) { + return root->encompassingObjects(point, objects); + } else { + return; + } + } + } }; diff --git a/BoundedNode.hpp b/BoundedNode.hpp index 4b726b3..6cf4de3 100644 --- a/BoundedNode.hpp +++ b/BoundedNode.hpp @@ -36,7 +36,7 @@ class BoundedNode : public BoundedObject { ObjectIntersection closestIntersection(Ray ray) { if(object != nullptr) { // base case, node is leaf, call object intersection function - return incrementDepth(object->intersection(ray), 1, 0); + return object->intersection(ray); } else { // recursive case, node is internal @@ -78,11 +78,10 @@ class BoundedNode : public BoundedObject { } ObjectIntersection intersectionClosest = nodeClosest->closestIntersection(ray); - ObjectIntersection intersectionFurthest = nodeFurthest->closestIntersection(ray); if(intersectionClosest.exists) { // the closest intersection exists - if(false) {//intersectionClosest.distance < intersectionBoxFurthest.distance && intersectionBoxClosest.distance != intersectionBoxFurthest.distance) { + if(intersectionClosest.distance < intersectionBoxFurthest.distance && intersectionBoxClosest.distance != intersectionBoxFurthest.distance) { // the intersection in the closest node happens before the start of the furthest bounding box, meaning it occludes it. we don't need to compute the full intersection within the furthest node // this also excludes the case where both intersection box distances are equal return incrementDepth(intersectionClosest, 0, 2); @@ -114,6 +113,95 @@ class BoundedNode : public BoundedObject { } } + ObjectIntersection closestIntersectionExcluding(Ray ray, Object* objectExcluded) { + if(object != nullptr) { + // base case, node is leaf, call object intersection function + ObjectIntersection intersectionObject = object->intersection(ray); + if(intersectionObject.object != objectExcluded) { + // object is not the excluded one + return intersectionObject; + } else { + // object is the excluded one, cancel + ObjectIntersection intersection; + intersection.exists = false; + return intersection; + } + } else { + // recursive case, node is internal + + // check intersection with children bounding box first + BoundedObjectIntersection intersectionBoxLeft = nodeLeft->boundingBox.intersection(ray); + BoundedObjectIntersection intersectionBoxRight = nodeRight->boundingBox.intersection(ray); + + if(!intersectionBoxLeft.exists && !intersectionBoxRight.exists) { + // none exist + ObjectIntersection intersection; + intersection.exists = false; + return incrementDepth(intersection, 0, 2); + } else if(intersectionBoxLeft.exists && !intersectionBoxRight.exists) { + // left exists + return incrementDepth(nodeLeft->closestIntersectionExcluding(ray, objectExcluded), 0, 2); + } else if(!intersectionBoxLeft.exists && intersectionBoxRight.exists) { + // right exists + return incrementDepth(nodeRight->closestIntersectionExcluding(ray, objectExcluded), 0, 2); + } else { + // both exist + BoundedObjectIntersection intersectionBoxClosest; + BoundedObjectIntersection intersectionBoxFurthest; + + BoundedNode* nodeClosest; + BoundedNode* nodeFurthest; + + if(intersectionBoxLeft.distance < intersectionBoxRight.distance) { + intersectionBoxClosest = intersectionBoxLeft; + intersectionBoxFurthest = intersectionBoxRight; + + nodeClosest = nodeLeft; + nodeFurthest = nodeRight; + } else { + intersectionBoxClosest = intersectionBoxRight; + intersectionBoxFurthest = intersectionBoxLeft; + + nodeClosest = nodeRight; + nodeFurthest = nodeLeft; + } + + ObjectIntersection intersectionClosest = nodeClosest->closestIntersectionExcluding(ray, objectExcluded); + + if(intersectionClosest.exists) { + // the closest intersection exists + if(intersectionClosest.distance < intersectionBoxFurthest.distance && intersectionBoxClosest.distance != intersectionBoxFurthest.distance) { + // the intersection in the closest node happens before the start of the furthest bounding box, meaning it occludes it. we don't need to compute the full intersection within the furthest node + // this also excludes the case where both intersection box distances are equal + return incrementDepth(intersectionClosest, 0, 2); + } else { + // the intersection in the furthest node might be in front of the one in the closest node. we must compute it + ObjectIntersection intersectionFurthest = nodeFurthest->closestIntersectionExcluding(ray, objectExcluded); + if(!intersectionFurthest.exists || intersectionClosest.distance < intersectionFurthest.distance) { + // the furthest intersection doesn't exist, or the closest node has the closest intersection + return incrementDepth(intersectionClosest, intersectionFurthest.objectIntersectionDepth, intersectionFurthest.boxIntersectionDepth + 2); + } else { + // the furthest node has the closest intersection + return incrementDepth(intersectionFurthest, intersectionClosest.objectIntersectionDepth, intersectionClosest.boxIntersectionDepth + 2);; + } + } + } else { + // the closest intersection doesn't exist + ObjectIntersection intersectionFurthest = nodeFurthest->closestIntersectionExcluding(ray, objectExcluded); + if(intersectionFurthest.exists) { + // the furthest exists + return incrementDepth(intersectionFurthest, intersectionClosest.objectIntersectionDepth, intersectionClosest.boxIntersectionDepth + 2); + } else { + // the furthest intersection doesn't exist + ObjectIntersection intersection; + intersection.exists = false; + return incrementDepth(intersection, intersectionClosest.objectIntersectionDepth + intersectionFurthest.objectIntersectionDepth, intersectionClosest.boxIntersectionDepth + intersectionFurthest.boxIntersectionDepth + 2); + } + } + } + } + } + DistanceMeasure incrementDepth(DistanceMeasure distance, int objectIncrement, int boxIncrement) { distance.objectDistanceDepth += objectIncrement; distance.boxDistanceDepth += boxIncrement; @@ -199,5 +287,37 @@ class BoundedNode : public BoundedObject { } } + + } + + // this uses lists instead of vectors to speedup merging recursive branches + void encompassingObjects(glm::vec3 point, std::list<Object*> &objects) { + if(object != nullptr) { + // base case, node is leaf, return object + objects.push_back(object); + return; + } else { + // recursive case, node is internal + + bool encompassingLeft = nodeLeft->boundingBox.containmentTest(point); + bool encompassingRight = nodeRight->boundingBox.containmentTest(point); + + if(!encompassingLeft && !encompassingRight) { + // neither encompasses + return; + } else if(encompassingLeft && !encompassingRight) { + // left encompasses + return nodeLeft->encompassingObjects(point, objects); + } else if(!encompassingLeft && encompassingRight) { + // right encompasses + return nodeRight->encompassingObjects(point, objects); + } else { + // both encompass + nodeLeft->encompassingObjects(point, objects); + nodeRight->encompassingObjects(point, objects); + return; + } + + } } }; diff --git a/BoundingBox.cpp b/BoundingBox.cpp index d853156..e4ab28c 100644 --- a/BoundingBox.cpp +++ b/BoundingBox.cpp @@ -126,6 +126,27 @@ DistanceMeasure BoundingBox::distanceEnd(glm::vec3 point) { return distanceMeasure; } +// derived from distance function above +// distance function for biggest inscribed circle in box centered on point +DistanceMeasure BoundingBox::distanceInscribed(glm::vec3 point) { + /* + DistanceMeasure distanceMeasure = distance(point); + distanceMeasure.distance = std::max(- distanceMeasure.distance, 0.0f); + return distanceMeasure; + */ + glm::vec3 pointCenter = 0.5f * (pointPositive + pointNegative); + glm::vec3 boundFromCenter = pointPositive - pointCenter; + glm::vec3 pointFromCenter = point - pointCenter; + glm::vec3 pointFromCornerMirrored = abs(pointFromCenter) - boundFromCenter; + + DistanceMeasure distanceMeasure; + distanceMeasure.origin = point; + distanceMeasure.boxDistanceDepth = 1; + distanceMeasure.distance = - std::min<float>(std::max<float>(pointFromCornerMirrored.x, std::max<float>(pointFromCornerMirrored.y, pointFromCornerMirrored.z)), 0.0); + + return distanceMeasure; +} + float BoundingBox::surfaceArea() { return 2 * (pointPositive.x - pointNegative.x) * (pointPositive.y - pointNegative.y) + 2 * (pointPositive.x - pointNegative.x) * (pointPositive.z - pointNegative.z) + 2 * (pointPositive.y - pointNegative.y) * (pointPositive.z - pointNegative.z); ; diff --git a/BoundingBox.hpp b/BoundingBox.hpp index 2397b47..91e7eb6 100644 --- a/BoundingBox.hpp +++ b/BoundingBox.hpp @@ -38,6 +38,8 @@ class BoundingBox { DistanceMeasure distance(glm::vec3 point); // distance function for furthest point on box DistanceMeasure distanceEnd(glm::vec3 point); + // distance function for biggest inscribed circle in box centered on point + DistanceMeasure distanceInscribed(glm::vec3 point); // surface area function float surfaceArea(); diff --git a/Field.cpp b/Field.cpp index c8ca9a9..acadac6 100644 --- a/Field.cpp +++ b/Field.cpp @@ -16,7 +16,7 @@ FieldIntersection Field::intersection(Ray ray) { // this is necessary because the bounding box intersection function uniquely allows negative distances. we don't want that here. intersectionField.exists = intersectionBox.exists && intersectionBox.distance >= 0; if(intersectionBox.exists) { - intersectionField.field = this; + intersectionField.object = this; intersectionField.distance = intersectionBox.distance; intersectionField.origin = ray.origin + ray.direction * intersectionBox.distance; intersectionField.incident = ray.direction; diff --git a/Field.hpp b/Field.hpp index 0fb1b16..8cf2daf 100644 --- a/Field.hpp +++ b/Field.hpp @@ -21,7 +21,7 @@ class Field : public BoundedObject { FieldIntersection intersection(Ray ray); // ray differential equation function - virtual glm::vec3 deltaRay(Ray ray, float step) = 0; + virtual glm::vec3 deltaRay(Ray ray) = 0; // primitive count for bounded hierarchy construction optimisation int primitiveCount = 1; diff --git a/FieldAttractor.cpp b/FieldAttractor.cpp index 4ba7f1b..2c21d1c 100644 --- a/FieldAttractor.cpp +++ b/FieldAttractor.cpp @@ -20,7 +20,7 @@ strength(strengthNew) primitiveCount = 1; } -glm::vec3 FieldAttractor::deltaRay(Ray ray, float step) { +glm::vec3 FieldAttractor::deltaRay(Ray ray) { float intensity = strength * (0.5 + 0.5 * std::cos(M_PI * std::min(glm::length(ray.origin - origin) / radius, 1.0f))); - return intensity * step * glm::normalize(glm::vec3(origin - ray.origin)); + return intensity * glm::normalize(glm::vec3(origin - ray.origin)); } diff --git a/FieldAttractor.hpp b/FieldAttractor.hpp index a37f7df..d72624c 100644 --- a/FieldAttractor.hpp +++ b/FieldAttractor.hpp @@ -20,5 +20,5 @@ class FieldAttractor : public Field { FieldAttractor(glm::vec3 origin, float radius, float strength); // ray differential equation function - glm::vec3 deltaRay(Ray ray, float step); + glm::vec3 deltaRay(Ray ray); }; diff --git a/FieldCrossProduct.cpp b/FieldCrossProduct.cpp index 0d98ed3..a8cc7c1 100644 --- a/FieldCrossProduct.cpp +++ b/FieldCrossProduct.cpp @@ -21,7 +21,7 @@ FieldCrossProduct::FieldCrossProduct(glm::vec3 originNew, glm::vec3 directionNew primitiveCount = 1; } -glm::vec3 FieldCrossProduct::deltaRay(Ray ray, float step) { +glm::vec3 FieldCrossProduct::deltaRay(Ray ray) { float intensity = strength * (0.5 + 0.5 * std::cos(M_PI * std::min(glm::length(ray.origin - origin) / radius, 1.0f))); - return intensity * step * glm::cross(ray.direction, direction); + return intensity * glm::cross(ray.direction, direction); } diff --git a/FieldCrossProduct.hpp b/FieldCrossProduct.hpp index 113eca9..0a0c1a1 100644 --- a/FieldCrossProduct.hpp +++ b/FieldCrossProduct.hpp @@ -21,5 +21,5 @@ class FieldCrossProduct : public Field { FieldCrossProduct(glm::vec3 origin, glm::vec3 direction, float radius, float strength); // ray differential equation function - glm::vec3 deltaRay(Ray ray, float step); + glm::vec3 deltaRay(Ray ray); }; diff --git a/FieldEmpty.cpp b/FieldEmpty.cpp index df61707..454b853 100644 --- a/FieldEmpty.cpp +++ b/FieldEmpty.cpp @@ -17,6 +17,6 @@ radius(radiusNew) primitiveCount = 1; } -glm::vec3 FieldEmpty::deltaRay(Ray ray, float step) { +glm::vec3 FieldEmpty::deltaRay(Ray ray) { return glm::vec3(0); } diff --git a/FieldEmpty.hpp b/FieldEmpty.hpp index f27efc8..20b2cf0 100644 --- a/FieldEmpty.hpp +++ b/FieldEmpty.hpp @@ -19,5 +19,5 @@ class FieldEmpty : public Field { FieldEmpty(glm::vec3 origin, float radius); // ray differential equation function - glm::vec3 deltaRay(Ray ray, float step); + glm::vec3 deltaRay(Ray ray); }; diff --git a/FieldIntersection.hpp b/FieldIntersection.hpp index 34ba648..0010646 100644 --- a/FieldIntersection.hpp +++ b/FieldIntersection.hpp @@ -24,5 +24,5 @@ struct FieldIntersection : public Intersection { int boxIntersectionDepth = 0; int debugMarker = 0; - Field *field; + Field *object; }; diff --git a/MeshPrimitive.cpp b/MeshPrimitive.cpp index ab28b5c..0829d51 100644 --- a/MeshPrimitive.cpp +++ b/MeshPrimitive.cpp @@ -78,7 +78,7 @@ void MeshPrimitive::updateBoundingBox() { ShadableObjectIntersection MeshPrimitive::intersection(Ray ray) { // calculate intersection with triangle plane float denom = glm::dot(normalTrue, ray.direction); - if(denom > -1e-6) { + if(denom >= 0) { // intersection with plane is a backface or ray is parallel to plane // exit calculation ShadableObjectIntersection intersection; @@ -86,7 +86,7 @@ ShadableObjectIntersection MeshPrimitive::intersection(Ray ray) { return intersection; } float t = glm::dot(corner1 - ray.origin, normalTrue) / denom; - if(t < 1e-3) { + if(t < 0) { // intersection with plane is behind ray // exit calculation ShadableObjectIntersection intersection; @@ -102,7 +102,7 @@ ShadableObjectIntersection MeshPrimitive::intersection(Ray ray) { float area2 = area(corner1, pointIntersection, corner3); float area3 = area(corner1, corner2, pointIntersection); - if(std::abs((area1 + area2 + area3) / areaTotal - 1.0) > 1e-3) { + if(((area1 + area2 + area3) / areaTotal - 1.0) > 1e-6) { // intersection is not in triangle // exit calculation ShadableObjectIntersection intersection; @@ -124,7 +124,8 @@ ShadableObjectIntersection MeshPrimitive::intersection(Ray ray) { intersection.normal = normalInterpolated; intersection.distance = t; intersection.incident = ray.direction; - intersection.shadableObject = this; + intersection.object = this; + intersection.objectIntersectionDepth = 1; return intersection; } diff --git a/RenderCore.cpp b/RenderCore.cpp index ad5ab66..b6928a1 100644 --- a/RenderCore.cpp +++ b/RenderCore.cpp @@ -7,11 +7,35 @@ // #include "RenderCore.hpp" +#include "Sphere.hpp" #include <iostream> +#include <algorithm> +#include <limits> RenderCore::RenderCore(RenderData* renderData) : renderData(renderData) {} +// computes the largest spherical zone in which the set of fields contained is the same +DistanceMeasure RenderCore::distanceSameEncompassing(glm::vec3 point, std::list<Field*> &fields) { + float distance = std::numeric_limits<float>::infinity(); + // check the start of other fields + for(std::vector<Field*>::iterator it = renderData->fields.begin(); it != renderData->fields.end(); ++it) { + float distanceLoop = (**it).boundingBox.distance(point).distance; + if(distanceLoop > 0) { + // this will exclude any field that appears in the given list, since these will contain the point and return a distance smaller or equal to zero + distance = std::min(distance, distanceLoop); + } + } + // check the end of current fields + for(std::list<Field*>::iterator it = fields.begin(); it != fields.end(); ++it) { + distance = std::min(distance, (**it).boundingBox.distanceInscribed(point).distance); + } + DistanceMeasure distanceMeasure; + distanceMeasure.distance = distance; + distanceMeasure.origin = point; + return distanceMeasure; +} + // calculate camera coordinates for given pixel and anti aliasing pass // input: // x -> [0, outputWidth] @@ -37,17 +61,23 @@ glm::vec2 RenderCore::toNormalizedCoordinates(int x, int y, int antiAliasingPass - (y + yOffset - renderData->outputHeight / 2.0) / renderData->outputWidth * 2.0); } -ShadableObjectIntersection RenderCore::marchFields(std::list<Field*> fields, Ray ray, float step, DistanceMeasure safeZone, int recursionDepth) { +// TODO: do this with the adptive Runge-Kutta method instead +// TODO: find a unified, definitive solution to intersection tolerances +// TODO: do more profiling, look for places where pass by reference would be better +// TODO: look into recursion flattening + +ShadableObjectIntersection RenderCore::marchFields(std::list<Field*> &fields, Ray ray, float step, DistanceMeasure safeZoneIntersection, DistanceMeasure safeZoneField, int recursionDepth) { glm::vec3 deltaRay; Ray rayRecursive; float distanceAccumulator = 0; while(recursionDepth-- > 0) { - deltaRay = ray.direction * step; + deltaRay = ray.direction; int numIterated = 0; for(std::list<Field*>::iterator it = fields.begin(); it != fields.end(); ++it) { numIterated++; - deltaRay += (**it).deltaRay(ray, step); + deltaRay += (**it).deltaRay(ray); } + deltaRay *= step; float stepLength = glm::length(deltaRay); // we now know precisely the previous ray's direction ray.direction = deltaRay / stepLength; @@ -55,29 +85,106 @@ ShadableObjectIntersection RenderCore::marchFields(std::list<Field*> fields, Ray rayRecursive.origin = ray.origin + deltaRay; // this is only an approximation of the ray's direction rayRecursive.direction = ray.direction; - // check to see if the ray steps out of the safe zone - if(glm::length(rayRecursive.origin - safeZone.origin) >= safeZone.distance) { - // stepped out of safe zone, check for intersections and recompute it if none are found + + if(false) {// set to false to disable intersection safe zone optimization + // optimized intersection check + + // check to see if the ray steps out of the safe zone for intersections + if(glm::length(rayRecursive.origin - safeZoneIntersection.origin) >= safeZoneIntersection.distance) { + // stepped out of safe zone, check for intersections and recompute it if none are found + ShadableObjectIntersection intersection = renderData->shadableBoundedHierarchy->closestIntersection(ray); + if(intersection.exists && intersection.distance <= stepLength) { + // the ray intersects before it ends the step, return the intersection + intersection.distance += distanceAccumulator; + return intersection; + } else { + // the ray doesn't intersect before it ends the step, compute a new safe zone centered at the next ray's origin + safeZoneIntersection = renderData->shadableBoundedHierarchy->distance(rayRecursive.origin); + } + } + } else { + // un-optimized intersection check + + // check to see if the new ray intersects an object ShadableObjectIntersection intersection = renderData->shadableBoundedHierarchy->closestIntersection(ray); if(intersection.exists && intersection.distance <= stepLength) { // the ray intersects before it ends the step, return the intersection intersection.distance += distanceAccumulator; return intersection; - } else { - // the ray doesn't intersect before it ends the step, compute a new safe zone centered at the next ray's origin - safeZone = renderData->shadableBoundedHierarchy->distance(rayRecursive.origin); } } - // compute next list of fields - fields = renderData->fieldBoundedHierarchy->encompassingObjects(rayRecursive.origin); - if(fields.size() == 0) { - // stepped out of field, cast ray - // this gets stalled on the edge of the field - ShadableObjectIntersection intersection = closestIntersectionThroughFields(rayRecursive, recursionDepth - 1); - intersection.distance += distanceAccumulator; - - return intersection; + + if(false) { // set to false to disable field safe zone optimization + // optimized field check + + // check to see if the ray steps out of the safe zone for fields + if(glm::length(rayRecursive.origin - safeZoneField.origin) >= safeZoneField.distance) { + // stepped out of safe zone, check for fields + //fields = renderData->fieldBoundedHierarchy->encompassingObjects(rayRecursive.origin); + fields.clear(); + renderData->fieldBoundedHierarchy->encompassingObjects(rayRecursive.origin, fields); + if(fields.size() == 0) { + // stepped out of field, cast ray + // this gets stalled on the edge of the field + ShadableObjectIntersection intersection = closestIntersectionThroughFields(rayRecursive, recursionDepth - 1); + intersection.distance += distanceAccumulator; + + return intersection; + } + // didn't step out of field, get new safe zone + safeZoneField = distanceSameEncompassing(rayRecursive.origin, fields); + } + } else { + // un-optimized field check + + // check to se if the set of fields containing the ray have changed + fields.clear(); + renderData->fieldBoundedHierarchy->encompassingObjects(rayRecursive.origin, fields); + if(fields.size() == 0) { + // stepped out of field, cast ray + ShadableObjectIntersection intersection = closestIntersectionThroughFields(rayRecursive, recursionDepth - 1); + intersection.distance += distanceAccumulator; + + return intersection; + } } + + /* + + benchmarks on (1000x562, 2x antialiasing root, 2 reflections, 7x7 sphere grid, two attractors fields, one cross product field, three lights, on i9 2019 15" MacBook Pro) + + |--------|---------------|---------------| + | time | optimized | optimized | + | | field? | intersection? | + |--------|---------------|---------------| + | 34.1s | yes | yes | + | 37.0s | yes | yes | + | 49.7s | no | yes | + | 54.0s | no | yes | + | 83.0s | yes | no | + | 93.5s | yes | no | + | 122.1s | no | no | + | 128.8s | no | no | + |--------|---------------|---------------| + + fully optimized vs not optimized is ~4x faster + + benchmarks on (1000x562, 2x antialiasing root, 2 reflections, 7x7 sphere grid, monkey with 15K tris, one cross product field, three lights, on i9 2019 15" MacBook Pro) + + |--------|---------------|---------------| + | time | optimized | optimized | + | | field? | intersection? | + |--------|---------------|---------------| + | 142.5s | yes | yes | + | 167.6s | no | yes | + | 176.2s | yes | no | + | 206.8s | no | no | + |--------|---------------|---------------| + + fully optimized vs not optimized is ~1.5x faster + + */ + // update the ray to the new one ray = rayRecursive; // increment distance @@ -88,48 +195,6 @@ ShadableObjectIntersection RenderCore::marchFields(std::list<Field*> fields, Ray intersection.exists = false; intersection.debugMarker = 1; return intersection; - - /* - if(recursionDepth < 1) { - // exceeded recursion depth - ShadableObjectIntersection intersection; - intersection.exists = false; - return intersection; - } - // sum field deltas - glm::vec3 deltaRay = ray.direction * step; - for(std::list<Field*>::iterator it = fields.begin(); it != fields.end(); ++it) { - deltaRay += (**it).deltaRay(ray, step); - } - // we know know precisely the previous ray's direction - ray.direction = glm::normalize(deltaRay); - // compute next ray - Ray rayRecursive; - rayRecursive.origin = ray.origin + deltaRay; - // this is only an approximation of the ray's direction - rayRecursive.direction = ray.direction; - if(glm::length(rayRecursive.origin - safeZone.origin) > safeZone.distance) { - // stepped out of safe zone, check for intersections and recompute it if none are found - ShadableObjectIntersection intersection = renderData->shadableBoundedHierarchy->closestIntersection(ray); - if(!intersection.exists || intersection.distance < glm::length(deltaRay)) { - // intersection doesn't exist or is further than the ray delta, continue recursion - safeZone = renderData->shadableBoundedHierarchy->distance(rayRecursive.origin); - } else { - // intersection exists and is closer than recursive ray - return intersection; - } - } - // compute next list of fields - std::list<Field*> fieldsRecursive = renderData->fieldBoundedHierarchy->encompassingObjects(rayRecursive.origin); - if(fieldsRecursive.size() == 0) { - // stepped out of field, cast ray - // this gets stalled on the edge of the field - //return closestIntersectionThroughFields(rayRecursive, recursionDepth - 1); - return closestIntersection(rayRecursive); - } - // do recursion - return marchFields(fieldsRecursive, rayRecursive, step, safeZone, recursionDepth - 1); - */ } ShadableObjectIntersection RenderCore::closestIntersectionThroughFields(Ray ray, int recursionDepth) { @@ -144,12 +209,15 @@ ShadableObjectIntersection RenderCore::closestIntersectionThroughFields(Ray ray, } else { // only field intersection exists, or field intersection is closer than shadable intersection //std::list<Field*> fields = {intersectionField.field}; - std::list<Field*> fields = renderData->fieldBoundedHierarchy->encompassingObjects(intersectionField.origin); + //std::list<Field*> fields = renderData->fieldBoundedHierarchy->encompassingObjects(intersectionField.origin); + std::list<Field*> fields; + renderData->fieldBoundedHierarchy->encompassingObjects(intersectionField.origin, fields); Ray rayRecursive; rayRecursive.direction = ray.direction; rayRecursive.origin = ray.origin + ray.direction * intersectionField.distance; - DistanceMeasure safeZone = renderData->shadableBoundedHierarchy->distance(rayRecursive.origin); - ShadableObjectIntersection intersectionShadableRecursive = marchFields(fields, rayRecursive, 0.01, safeZone, recursionDepth - 1); + DistanceMeasure safeZoneIntersection = renderData->shadableBoundedHierarchy->distance(rayRecursive.origin); + DistanceMeasure safeZoneField = distanceSameEncompassing(rayRecursive.origin, fields); + ShadableObjectIntersection intersectionShadableRecursive = marchFields(fields, rayRecursive, 0.01, safeZoneIntersection, safeZoneField, recursionDepth - 1); intersectionShadableRecursive.distance += intersectionField.distance; return intersectionShadableRecursive; } @@ -160,6 +228,11 @@ ShadableObjectIntersection RenderCore::closestIntersection(Ray ray) { return renderData->shadableBoundedHierarchy->closestIntersection(ray); } +// calculate closest intersection between ray and all objects excluding a specific one +ShadableObjectIntersection RenderCore::closestIntersectionExcluding(Ray ray, ShadableObject* objectExcluded) { + return renderData->shadableBoundedHierarchy->closestIntersectionExcluding(ray, objectExcluded); +} + // calculate the color contribution of a light to an intersection glm::vec3 RenderCore::colorLight(ShadableObjectIntersection intersection, Light* light) { glm::vec3 color(0.0); @@ -171,13 +244,18 @@ glm::vec3 RenderCore::colorLight(ShadableObjectIntersection intersection, Light* lightRay.direction = glm::normalize(lightRay.direction); lightRay.isCameraRay = false; - ShadableObjectIntersection closest = closestIntersection(lightRay); + ShadableObjectIntersection closest; + if(typeid(*(intersection.object)) == typeid(Sphere)) { + closest = closestIntersection(lightRay); + } else { + closest = closestIntersectionExcluding(lightRay, intersection.object); + } if(!closest.exists || closest.distance > distance) { // light ray is unobstructed, calculate contribution // diffuse - color += glm::dot(lightRay.direction, intersection.normal) * intersection.shadableObject->shadableAttributes->diffuse * light->shadableAttributes.diffuse; + color += glm::dot(lightRay.direction, intersection.normal) * intersection.object->shadableAttributes->diffuse * light->shadableAttributes.diffuse; // specular - color += std::pow(std::fmaxf(0, glm::dot(lightRay.direction, glm::reflect(intersection.incident, intersection.normal))), intersection.shadableObject->shadableAttributes->shininess) * intersection.shadableObject->shadableAttributes->specular * light->shadableAttributes.specular; + color += std::pow(std::fmaxf(0, glm::dot(lightRay.direction, glm::reflect(intersection.incident, intersection.normal))), intersection.object->shadableAttributes->shininess) * intersection.object->shadableAttributes->specular * light->shadableAttributes.specular; } return color; } @@ -190,7 +268,7 @@ glm::vec3 RenderCore::colorIntersection(ShadableObjectIntersection intersection, color += colorLight(intersection, renderData->lights[i]); } // ambient - color += intersection.shadableObject->shadableAttributes->ambient; + color += intersection.object->shadableAttributes->ambient; // recursive reflection if(recursionDepth > 0) { Ray reflected; @@ -198,8 +276,9 @@ glm::vec3 RenderCore::colorIntersection(ShadableObjectIntersection intersection, reflected.direction = glm::reflect(intersection.incident, intersection.normal); reflected.isCameraRay = true; ShadableObjectIntersection closest = closestIntersection(reflected); + //ShadableObjectIntersection closest = closestIntersectionThroughFields(reflected, 1000); if(closest.exists) { - color += intersection.shadableObject->shadableAttributes->reflectivity * colorIntersection(closest, recursionDepth - 1); + color += intersection.object->shadableAttributes->reflectivity * colorIntersection(closest, recursionDepth - 1); } } return color; diff --git a/RenderCore.hpp b/RenderCore.hpp index ddabad0..968fc0a 100644 --- a/RenderCore.hpp +++ b/RenderCore.hpp @@ -25,6 +25,8 @@ class RenderCore { // constructor RenderCore(RenderData* renderData); + DistanceMeasure distanceSameEncompassing(glm::vec3 point, std::list<Field*> &fields); + // transforms a pixel coordinate and antialiasing pass number to normalized camera plane coordinates // input: // x -> [0, outputWidth] @@ -35,7 +37,7 @@ class RenderCore { glm::vec2 toNormalizedCoordinates(int x, int y, int antiAliasingPass); // do ray-marching on fields - ShadableObjectIntersection marchFields(std::list<Field*> fields, Ray ray, float step, DistanceMeasure safeZone, int recursionDepth); + ShadableObjectIntersection marchFields(std::list<Field*> &fields, Ray ray, float step, DistanceMeasure safeZoneIntersection, DistanceMeasure safeZoneField, int recursionDepth); // calculate closest intersection between ray and any object, marching through fields ShadableObjectIntersection closestIntersectionThroughFields(Ray ray, int recursionDepth); @@ -43,6 +45,9 @@ class RenderCore { // calculate closest intersection between ray and any object ShadableObjectIntersection closestIntersection(Ray ray); + // calculate closest intersection between ray and all objects excluding a specific one + ShadableObjectIntersection closestIntersectionExcluding(Ray ray, ShadableObject* objectExcluded); + // calculate the color contribution of a light to an intersection glm::vec3 colorLight(ShadableObjectIntersection intersection, Light* light); diff --git a/RenderData.cpp b/RenderData.cpp index 7ce1a09..46a5471 100644 --- a/RenderData.cpp +++ b/RenderData.cpp @@ -339,19 +339,17 @@ void RenderData::loadTest() { fields.push_back(fieldAttractor); */ - Field* fieldAttractor1 = new FieldAttractor(glm::vec3(-1, 0, -1), 2, -0.04); + //Field* fieldAttractor1 = new FieldAttractor(glm::vec3(-1, 0, -1), 2, -0.04); //Field* fieldAttractor2 = new FieldAttractor(glm::vec3(1, 0, -1), 1.3, -0.05); //Field* fieldEmpty = new FieldEmpty(glm::vec3(0), 2); - fields.push_back(fieldAttractor1); + //fields.push_back(fieldAttractor1); //fields.push_back(fieldAttractor2); //fields.push_back(fieldEmpty); //Field* fieldCrossProduct = new FieldCrossProduct(glm::vec3(1, 0, -1), glm::vec3(0, 0, 1), 2, 2); //fields.push_back(fieldCrossProduct); - /* - Field* fieldCrossProduct = new FieldCrossProduct(glm::vec3(0), glm::vec3(0, 1, 0), 1, 0.001); + Field* fieldCrossProduct = new FieldCrossProduct(glm::vec3(0), glm::vec3(0, 1, 0), 2.4, 0.1); fields.push_back(fieldCrossProduct); - */ /* Field* fieldEmpty = new FieldEmpty(glm::vec3(0), 2); @@ -359,13 +357,12 @@ void RenderData::loadTest() { */ // mesh - /* - MeshData* meshData = new MeshData("monkey2.obj"); + MeshData* meshData = new MeshData("monkey3.obj"); meshDatas.push_back(meshData); - //MeshInstance* meshInstance = new MeshInstance(meshData, glm::rotate(glm::mat4(2.0), (float) M_PI_2, glm::vec3(1.0, 0.0, 0.0)), sphereAttributes); - MeshInstance* meshInstance = new MeshInstance(meshData,glm::mat4(1.0), sphereAttributes); + MeshInstance* meshInstance = new MeshInstance(meshData, glm::rotate(glm::mat4(2.0), (float) M_PI_2, glm::vec3(1.0, 0.0, 0.0)), sphereAttributes); + //MeshInstance* meshInstance = new MeshInstance(meshData,glm::mat4(1.0), sphereAttributes); meshInstances.push_back(meshInstance); - */ + //objects.push_back(new Sphere(glm::vec3(0, 0, 0), 1, sphereAttributes)); // sphere floating miror @@ -399,6 +396,44 @@ void RenderData::loadTest() { //camera = new Camera(glm::vec3(0, 0, 2), glm::vec3(0, 0, -1), glm::vec3(0, 1, 0), 80, 1.0, 16.0 / 9.0); } +void RenderData::loadAnim(float cameraAngle) { + ShadableAttributes* sphereAttributes = new ShadableAttributes(); + sphereAttributes->ambient = glm::vec3(0.1); + sphereAttributes->diffuse = glm::vec3(0.8); + sphereAttributes->specular = glm::vec3(0.8); + sphereAttributes->shininess = 1; + sphereAttributes->reflectivity = 0.2; + + // sphere grid + for(int i = -3; i <= 3; i++) { + for(int j = -3; j <= 3; j++) { + objects.push_back(new Sphere(glm::vec3(i * 2, j * 2, -2), 1, sphereAttributes)); + } + } + + + Field* fieldAttractor1 = new FieldAttractor(glm::vec3(-1, 0, -1), 2, -0.04); + Field* fieldAttractor2 = new FieldAttractor(glm::vec3(1, 0, -1), 1.3, -0.05); + fields.push_back(fieldAttractor1); + fields.push_back(fieldAttractor2); + Field* fieldCrossProduct = new FieldCrossProduct(glm::vec3(0), glm::vec3(0, 1, 0), 2.4, 0.1); + fields.push_back(fieldCrossProduct); + + // lights + ShadableAttributes lightAttributes; + lightAttributes.specular = lightAttributes.diffuse = glm::vec3(0.9, 0.0, 0.6); + lights.push_back(new Light(glm::vec3(4, -4, 2), lightAttributes)); + lightAttributes.specular = lightAttributes.diffuse = glm::vec3(0.3, 0.1, 0.9); + lights.push_back(new Light(glm::vec3(-4, 4, 2), lightAttributes)); + lightAttributes.specular = lightAttributes.diffuse = glm::vec3(0.0, 0.9, 0.6); + lights.push_back(new Light(glm::vec3(-4, 4, 20), lightAttributes)); + // camera + camera = new Camera(glm::vec3(glm::rotate(glm::mat4(1.0), cameraAngle, glm::vec3(0, 0, 1)) * glm::vec4(0, -4, 2, 1)), + glm::vec3(glm::rotate(glm::mat4(1.0), cameraAngle, glm::vec3(0, 0, 1)) * glm::vec4(0, 4, -2, 0)), + glm::vec3(0, 0, 1), 80, 1.0, 16.0 / 9.0); + //camera = new Camera(glm::vec3(0, 0, 2), glm::vec3(0, 0, -1), glm::vec3(0, 1, 0), 80, 1.0, 16.0 / 9.0); +} + void RenderData::applyOutputSettingsFromFocalPlane() { applyOutputSettingsFromWidth(2.0 * std::tanf(camera->fieldOfView / 360.0 * M_PI) * camera->aspectRatio * camera->focalLength); } @@ -498,3 +533,19 @@ RenderData::RenderData(std::string workingDirectoryNew, std::string inputFileNam computeShadableBoundedHierarchy(); computeFieldBoundedHierarchy(); } + +RenderData::RenderData(int outputWidthNew, int tileSizeNew, int antiAliasingPassesRootNew, int threadCountNew, int recursionLimitNew, std::string workingDirectoryNew, std::string outputFileNameNew, float cameraAngle) { + workingDirectory = workingDirectoryNew; + outputFileName = outputFileNameNew; + + loadAnim(cameraAngle); + + applyOutputSettingsFromWidth(outputWidthNew); + applyTileSettings(tileSizeNew); + applyAntiAliasingSettings(antiAliasingPassesRootNew); + applyThreadSettings(threadCountNew); + applyRecursionSettings(recursionLimitNew); + expandPrimitives(); + computeShadableBoundedHierarchy(); + computeFieldBoundedHierarchy(); +} diff --git a/RenderData.hpp b/RenderData.hpp index 52461bf..1e251d0 100644 --- a/RenderData.hpp +++ b/RenderData.hpp @@ -29,6 +29,7 @@ class RenderData { private: void loadInputFile(); // creates objects and camera from input file void loadTest(); // creates objects and camera from predefined test setup + void loadAnim(float cameraAngle); // creates objects and camera from predefined anim scene void applyOutputSettingsFromFocalPlane(); // calculates and sets output size from camera focal plane void applyOutputSettingsFromWidth(int outputWidthNew); // calculates and sets output size from arbitrary width void applyOutputSettingsFromHeight(int outputHeightNew); // calculates and sets output size from arbitrary height @@ -72,4 +73,7 @@ class RenderData { // constructor for assignment files RenderData(std::string workingDirectoryNew, std::string inputFileNameNew, std::string outputFileNameNew); + + // constructor for animation. this is hard-coded garbage + RenderData(int outputWidthNew, int tileSizeNew, int antiAliasingPassesRootNew, int threadCountNew, int recursionLimitNew, std::string workingDirectoryNew, std::string outputFileNameNew, float cameraAngle); }; diff --git a/ShadableObjectIntersection.hpp b/ShadableObjectIntersection.hpp index 04407f0..2933198 100644 --- a/ShadableObjectIntersection.hpp +++ b/ShadableObjectIntersection.hpp @@ -25,5 +25,5 @@ struct ShadableObjectIntersection : public Intersection { int boxIntersectionDepth = 0; int debugMarker = 0; - ShadableObject *shadableObject; + ShadableObject *object; }; diff --git a/Sphere.cpp b/Sphere.cpp index 032b1b9..2ca33cd 100644 --- a/Sphere.cpp +++ b/Sphere.cpp @@ -57,7 +57,8 @@ ShadableObjectIntersection Sphere::intersection(Ray ray) { intersection.exists = true; intersection.incident = ray.direction; intersection.distance = t; - intersection.shadableObject = this; + intersection.object = this; + intersection.objectIntersectionDepth = 1; return intersection; } diff --git a/main.cpp b/main.cpp index b14ddac..88f5679 100644 --- a/main.cpp +++ b/main.cpp @@ -25,8 +25,20 @@ int main(int argc, const char * argv[]) { Tester tester = Tester(); tester.doTheTest(); */ - RenderData renderDataExtended(2000, 32, 2, 16, 2, "","Test.bmp"); + RenderData renderDataExtended(1000, 32, 2, 16, 2, "","Test.bmp"); RenderScheduler renderScheduler(&renderDataExtended); renderScheduler.renderAndSaveImage(); + /* + int numSteps = 180; + for(int i = 0; i < numSteps; i++) { + std::string path; + path.append("Frame"); + path.append(std::to_string(i)); + path.append(".bmp"); + RenderData renderData(1920, 32, 2, 16, 2, "", path, glm::radians(360.0 / numSteps * i)); + RenderScheduler renderScheduler(&renderData); + renderScheduler.renderAndSaveImage(); + } + */ return 0; }