general system refactors, updates
This commit is contained in:
@@ -120,7 +120,6 @@ You can use the Renderer with the following functions, all of which are in the g
|
||||
- LoadWorldInfo(string fileName) -- Loads world information from file
|
||||
- DuplicateInstance(Object object) : Object result -- Copies the specified object in the scene as an instanced mesh
|
||||
- SetEnvironmentMap(Texture cubemap)
|
||||
- SetColorGrading(Texture texture2D)
|
||||
- HairParticleSettings(opt int lod0, opt int lod1, opt int lod2)
|
||||
- SetAlphaCompositionEnabled(opt bool enabled)
|
||||
- SetShadowProps2D(int resolution, int count, int softShadowQuality)
|
||||
@@ -454,7 +453,6 @@ The main component which holds information and manages the running of the curren
|
||||
- SetWatermarkDisplay(bool active)
|
||||
- SetFPSDisplay(bool active)
|
||||
- SetCPUDisplay(bool active)
|
||||
- SetColorGradePaletteDisplay(bool active)
|
||||
- [outer]SetProfilerEnabled(bool enabled)
|
||||
|
||||
### RenderableComponent
|
||||
@@ -502,6 +500,7 @@ It inherits functions from Renderable2DComponent, so it can render a 2D overlay.
|
||||
- SetFXAAEnabled(bool value)
|
||||
- SetBloomEnabled(bool value)
|
||||
- SetColorGradingEnabled(bool value)
|
||||
- SetColorGradingTexture(Texture value)
|
||||
- SetEmitterParticlesEnabled(bool value)
|
||||
- SetHairParticlesEnabled(bool value)
|
||||
- SetHairParticlesReflectionEnabled(bool value)
|
||||
@@ -513,7 +512,6 @@ It inherits functions from Renderable2DComponent, so it can render a 2D overlay.
|
||||
- SetDepthOfFieldEnabled(bool value)
|
||||
- SetDepthOfFieldFocus(float value)
|
||||
- SetDepthOfFieldStrength(float value)
|
||||
- SetPreferredThreadingCount(int value)
|
||||
- SetTessellationEnabled(bool value)
|
||||
- SetMSAASampleCount(int count)
|
||||
- SetStereogramEnabled(bool value)
|
||||
|
||||
+212
-27
@@ -32,7 +32,6 @@ Editor::Editor()
|
||||
SAFE_INIT(loader);
|
||||
}
|
||||
|
||||
|
||||
Editor::~Editor()
|
||||
{
|
||||
//SAFE_DELETE(renderComponent);
|
||||
@@ -135,11 +134,61 @@ void ConsumeHistoryOperation(bool undo);
|
||||
|
||||
|
||||
|
||||
struct Picked
|
||||
{
|
||||
Transform* transform;
|
||||
Object* object;
|
||||
Light* light;
|
||||
Decal* decal;
|
||||
EnvironmentProbe* envProbe;
|
||||
ForceField* forceField;
|
||||
Camera* camera;
|
||||
Armature* armature;
|
||||
XMFLOAT3 position, normal;
|
||||
float distance;
|
||||
int subsetIndex;
|
||||
|
||||
Picked()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
// Subset index, position, normal, distance don't distinguish between pickeds!
|
||||
bool operator==(const Picked& other)
|
||||
{
|
||||
return
|
||||
transform == other.transform &&
|
||||
object == other.object &&
|
||||
light == other.light &&
|
||||
decal == other.decal &&
|
||||
envProbe == other.envProbe &&
|
||||
forceField == other.forceField &&
|
||||
camera == other.camera &&
|
||||
armature == other.armature
|
||||
;
|
||||
}
|
||||
void Clear()
|
||||
{
|
||||
distance = FLT_MAX;
|
||||
subsetIndex = -1;
|
||||
SAFE_INIT(transform);
|
||||
SAFE_INIT(object);
|
||||
SAFE_INIT(light);
|
||||
SAFE_INIT(decal);
|
||||
SAFE_INIT(envProbe);
|
||||
SAFE_INIT(forceField);
|
||||
SAFE_INIT(camera);
|
||||
SAFE_INIT(armature);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
wiTranslator* translator = nullptr;
|
||||
bool translator_active = false;
|
||||
list<wiRenderer::Picked*> selected;
|
||||
list<Picked*> selected;
|
||||
std::map<Transform*,Transform*> savedParents;
|
||||
wiRenderer::Picked hovered;
|
||||
Picked hovered;
|
||||
void BeginTranslate()
|
||||
{
|
||||
translator_active = true;
|
||||
@@ -206,9 +255,9 @@ void ClearSelected()
|
||||
selected.clear();
|
||||
savedParents.clear();
|
||||
}
|
||||
void AddSelected(wiRenderer::Picked* picked, bool deselectIfAlreadySelected = false)
|
||||
void AddSelected(Picked* picked, bool deselectIfAlreadySelected = false)
|
||||
{
|
||||
list<wiRenderer::Picked*>::iterator it = selected.begin();
|
||||
list<Picked*>::iterator it = selected.begin();
|
||||
for (; it != selected.end(); ++it)
|
||||
{
|
||||
if ((**it) == *picked)
|
||||
@@ -323,10 +372,6 @@ void EditorComponent::DeleteWindows()
|
||||
SAFE_DELETE(forceFieldWnd);
|
||||
SAFE_DELETE(oceanWnd);
|
||||
}
|
||||
void EditorComponent::UpdateFromPrimarySelection(const wiRenderer::Picked& sel)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void EditorComponent::Initialize()
|
||||
{
|
||||
@@ -860,11 +905,11 @@ void EditorComponent::Load()
|
||||
if (helpLabel == nullptr)
|
||||
{
|
||||
stringstream ss("");
|
||||
ss << "Help: " << endl << "############" << endl << endl;
|
||||
ss << "Help: " << endl << "############" << endl << endl;
|
||||
ss << "Move camera: WASD" << endl;
|
||||
ss << "Look: Middle mouse button / arrow keys" << endl;
|
||||
ss << "Select: Right mouse button" << endl;
|
||||
ss << "Place decal/interact: Left mouse button when nothing is selected" << endl;
|
||||
ss << "Place decal, interact with water: Left mouse button when nothing is selected" << endl;
|
||||
ss << "Camera speed: SHIFT button" << endl;
|
||||
ss << "Camera up: E, down: Q" << endl;
|
||||
ss << "Duplicate entity (with instancing): Ctrl + D" << endl;
|
||||
@@ -877,9 +922,10 @@ void EditorComponent::Load()
|
||||
ss << "Script Console / backlog: HOME button" << endl;
|
||||
ss << endl;
|
||||
ss << "You can find sample models in the models directory. Try to load one." << endl;
|
||||
ss << "You can also import models from .OBJ files." << endl;
|
||||
ss << "You can also import models from .OBJ, .GLTF, .GLB, .WIO files." << endl;
|
||||
ss << "You can also export models from Blender with the io_export_wicked_wi_bin.py script." << endl;
|
||||
ss << "You can find a program configuration file at Editor/config.ini" << endl;
|
||||
ss << "You can find sample LUA scripts in the scripts directory. Try to load one." << endl;
|
||||
ss << "You can find a startup script at Editor/startup.lua (this will be executed on program start)" << endl;
|
||||
ss << endl << endl << "For questions, bug reports, feedback, requests, please open an issue at:" << endl;
|
||||
ss << "https://github.com/turanszkij/WickedEngine" << endl;
|
||||
@@ -1065,7 +1111,146 @@ void EditorComponent::Update(float dt)
|
||||
}
|
||||
}
|
||||
|
||||
hovered = wiRenderer::Pick((long)currentMouse.x, (long)currentMouse.y, rendererWnd->GetPickType());
|
||||
// Begin picking:
|
||||
UINT pickMask = rendererWnd->GetPickType();
|
||||
RAY pickRay = wiRenderer::getPickRay((long)currentMouse.x, (long)currentMouse.y);
|
||||
{
|
||||
hovered.Clear();
|
||||
|
||||
// Try to pick objects-meshes:
|
||||
if (pickMask & PICK_OBJECT)
|
||||
{
|
||||
auto& picked = wiRenderer::RayIntersectWorld(pickRay, pickMask);
|
||||
|
||||
hovered.object = picked.object;
|
||||
hovered.distance = picked.distance;
|
||||
hovered.subsetIndex = picked.subsetIndex;
|
||||
hovered.position = picked.position;
|
||||
hovered.normal = picked.normal;
|
||||
|
||||
hovered.transform = picked.object;
|
||||
}
|
||||
|
||||
for (auto& model : wiRenderer::GetScene().models)
|
||||
{
|
||||
if (pickMask & PICK_LIGHT)
|
||||
{
|
||||
for (auto& light : model->lights)
|
||||
{
|
||||
XMVECTOR disV = XMVector3LinePointDistance(XMLoadFloat3(&pickRay.origin), XMLoadFloat3(&pickRay.origin) + XMLoadFloat3(&pickRay.direction), XMLoadFloat3(&light->translation));
|
||||
float dis = XMVectorGetX(disV);
|
||||
if (dis < wiMath::Distance(light->translation, pickRay.origin) * 0.05f && dis < hovered.distance)
|
||||
{
|
||||
hovered.Clear();
|
||||
hovered.transform = light;
|
||||
hovered.light = light;
|
||||
hovered.distance = dis;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pickMask & PICK_DECAL)
|
||||
{
|
||||
for (auto& decal : model->decals)
|
||||
{
|
||||
XMVECTOR disV = XMVector3LinePointDistance(XMLoadFloat3(&pickRay.origin), XMLoadFloat3(&pickRay.origin) + XMLoadFloat3(&pickRay.direction), XMLoadFloat3(&decal->translation));
|
||||
float dis = XMVectorGetX(disV);
|
||||
if (dis < wiMath::Distance(decal->translation, pickRay.origin) * 0.05f && dis < hovered.distance)
|
||||
{
|
||||
hovered.Clear();
|
||||
hovered.transform = decal;
|
||||
hovered.decal = decal;
|
||||
hovered.distance = dis;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pickMask & PICK_FORCEFIELD)
|
||||
{
|
||||
for (auto& force : model->forces)
|
||||
{
|
||||
XMVECTOR disV = XMVector3LinePointDistance(XMLoadFloat3(&pickRay.origin), XMLoadFloat3(&pickRay.origin) + XMLoadFloat3(&pickRay.direction), XMLoadFloat3(&force->translation));
|
||||
float dis = XMVectorGetX(disV);
|
||||
if (dis < wiMath::Distance(force->translation, pickRay.origin) * 0.05f && dis < hovered.distance)
|
||||
{
|
||||
hovered.Clear();
|
||||
hovered.transform = force;
|
||||
hovered.forceField = force;
|
||||
hovered.distance = dis;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pickMask & PICK_EMITTER)
|
||||
{
|
||||
for (auto& object : model->objects)
|
||||
{
|
||||
if (object->eParticleSystems.empty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
XMVECTOR disV = XMVector3LinePointDistance(XMLoadFloat3(&pickRay.origin), XMLoadFloat3(&pickRay.origin) + XMLoadFloat3(&pickRay.direction), XMLoadFloat3(&object->translation));
|
||||
float dis = XMVectorGetX(disV);
|
||||
if (dis < wiMath::Distance(object->translation, pickRay.origin) * 0.05f && dis < hovered.distance)
|
||||
{
|
||||
hovered.Clear();
|
||||
hovered.transform = object;
|
||||
hovered.object = object;
|
||||
hovered.distance = dis;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (pickMask & PICK_ENVPROBE)
|
||||
{
|
||||
for (auto& x : model->environmentProbes)
|
||||
{
|
||||
if (SPHERE(x->translation, 1).intersects(pickRay))
|
||||
{
|
||||
float dis = wiMath::Distance(x->translation, pickRay.origin);
|
||||
if (dis < hovered.distance)
|
||||
{
|
||||
hovered.Clear();
|
||||
hovered.transform = x;
|
||||
hovered.envProbe = x;
|
||||
hovered.distance = dis;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pickMask & PICK_CAMERA)
|
||||
{
|
||||
for (auto& camera : model->cameras)
|
||||
{
|
||||
XMVECTOR disV = XMVector3LinePointDistance(XMLoadFloat3(&pickRay.origin), XMLoadFloat3(&pickRay.origin) + XMLoadFloat3(&pickRay.direction), XMLoadFloat3(&camera->translation));
|
||||
float dis = XMVectorGetX(disV);
|
||||
if (dis < wiMath::Distance(camera->translation, pickRay.origin) * 0.05f && dis < hovered.distance)
|
||||
{
|
||||
hovered.Clear();
|
||||
hovered.transform = camera;
|
||||
hovered.camera = camera;
|
||||
hovered.distance = dis;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pickMask & PICK_ARMATURE)
|
||||
{
|
||||
for (auto& armature : model->armatures)
|
||||
{
|
||||
XMVECTOR disV = XMVector3LinePointDistance(XMLoadFloat3(&pickRay.origin), XMLoadFloat3(&pickRay.origin) + XMLoadFloat3(&pickRay.direction), XMLoadFloat3(&armature->translation));
|
||||
float dis = XMVectorGetX(disV);
|
||||
if (dis < wiMath::Distance(armature->translation, pickRay.origin) * 0.05f && dis < hovered.distance)
|
||||
{
|
||||
hovered.Clear();
|
||||
hovered.transform = armature;
|
||||
hovered.armature = armature;
|
||||
hovered.distance = dis;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Interact:
|
||||
if (hovered.object != nullptr && selected.empty())
|
||||
@@ -1136,7 +1321,7 @@ void EditorComponent::Update(float dt)
|
||||
{
|
||||
for (auto& x : model->objects)
|
||||
{
|
||||
wiRenderer::Picked* picked = new wiRenderer::Picked;
|
||||
Picked* picked = new Picked;
|
||||
picked->object = x;
|
||||
picked->transform = x;
|
||||
|
||||
@@ -1144,7 +1329,7 @@ void EditorComponent::Update(float dt)
|
||||
}
|
||||
for (auto& x : model->lights)
|
||||
{
|
||||
wiRenderer::Picked* picked = new wiRenderer::Picked;
|
||||
Picked* picked = new Picked;
|
||||
picked->light = x;
|
||||
picked->transform = x;
|
||||
|
||||
@@ -1152,7 +1337,7 @@ void EditorComponent::Update(float dt)
|
||||
}
|
||||
for (auto& x : model->forces)
|
||||
{
|
||||
wiRenderer::Picked* picked = new wiRenderer::Picked;
|
||||
Picked* picked = new Picked;
|
||||
picked->forceField = x;
|
||||
picked->transform = x;
|
||||
|
||||
@@ -1160,7 +1345,7 @@ void EditorComponent::Update(float dt)
|
||||
}
|
||||
for (auto& x : model->armatures)
|
||||
{
|
||||
wiRenderer::Picked* picked = new wiRenderer::Picked;
|
||||
Picked* picked = new Picked;
|
||||
picked->armature = x;
|
||||
picked->transform = x;
|
||||
|
||||
@@ -1168,7 +1353,7 @@ void EditorComponent::Update(float dt)
|
||||
}
|
||||
for (auto& x : model->cameras)
|
||||
{
|
||||
wiRenderer::Picked* picked = new wiRenderer::Picked;
|
||||
Picked* picked = new Picked;
|
||||
picked->camera = x;
|
||||
picked->transform = x;
|
||||
|
||||
@@ -1176,7 +1361,7 @@ void EditorComponent::Update(float dt)
|
||||
}
|
||||
for (auto& x : model->environmentProbes)
|
||||
{
|
||||
wiRenderer::Picked* picked = new wiRenderer::Picked;
|
||||
Picked* picked = new Picked;
|
||||
picked->envProbe = x;
|
||||
picked->transform = x;
|
||||
|
||||
@@ -1184,7 +1369,7 @@ void EditorComponent::Update(float dt)
|
||||
}
|
||||
for (auto& x : model->decals)
|
||||
{
|
||||
wiRenderer::Picked* picked = new wiRenderer::Picked;
|
||||
Picked* picked = new Picked;
|
||||
picked->decal = x;
|
||||
picked->transform = x;
|
||||
|
||||
@@ -1197,7 +1382,7 @@ void EditorComponent::Update(float dt)
|
||||
else if (hovered.transform != nullptr)
|
||||
{
|
||||
// Add the hovered item to the selection:
|
||||
wiRenderer::Picked* picked = new wiRenderer::Picked(hovered);
|
||||
Picked* picked = new Picked(hovered);
|
||||
if (!selected.empty() && wiInputManager::GetInstance()->down(VK_LSHIFT))
|
||||
{
|
||||
AddSelected(picked, true);
|
||||
@@ -1261,7 +1446,7 @@ void EditorComponent::Update(float dt)
|
||||
}
|
||||
else
|
||||
{
|
||||
wiRenderer::Picked* picked = selected.back();
|
||||
Picked* picked = selected.back();
|
||||
|
||||
assert(picked->transform != nullptr);
|
||||
|
||||
@@ -2002,7 +2187,7 @@ void ConsumeHistoryOperation(bool undo)
|
||||
|
||||
// Read selections states from archive:
|
||||
|
||||
list<wiRenderer::Picked*> selectedBEFORE;
|
||||
list<Picked*> selectedBEFORE;
|
||||
size_t selectionCountBEFORE;
|
||||
*archive >> selectionCountBEFORE;
|
||||
for (size_t i = 0; i < selectionCountBEFORE; ++i)
|
||||
@@ -2010,7 +2195,7 @@ void ConsumeHistoryOperation(bool undo)
|
||||
uint64_t id;
|
||||
*archive >> id;
|
||||
|
||||
wiRenderer::Picked* sel = new wiRenderer::Picked;
|
||||
Picked* sel = new Picked;
|
||||
sel->transform = wiRenderer::getTransformByID(id);
|
||||
assert(sel->transform != nullptr);
|
||||
*archive >> sel->position;
|
||||
@@ -2034,7 +2219,7 @@ void ConsumeHistoryOperation(bool undo)
|
||||
savedParentsBEFORE.insert(pair<Transform*, Transform*>(t1, t2));
|
||||
}
|
||||
|
||||
list<wiRenderer::Picked*> selectedAFTER;
|
||||
list<Picked*> selectedAFTER;
|
||||
size_t selectionCountAFTER;
|
||||
*archive >> selectionCountAFTER;
|
||||
for (size_t i = 0; i < selectionCountAFTER; ++i)
|
||||
@@ -2042,7 +2227,7 @@ void ConsumeHistoryOperation(bool undo)
|
||||
uint64_t id;
|
||||
*archive >> id;
|
||||
|
||||
wiRenderer::Picked* sel = new wiRenderer::Picked;
|
||||
Picked* sel = new Picked;
|
||||
sel->transform = wiRenderer::getTransformByID(id);
|
||||
assert(sel->transform != nullptr);
|
||||
*archive >> sel->position;
|
||||
@@ -2069,7 +2254,7 @@ void ConsumeHistoryOperation(bool undo)
|
||||
|
||||
// Restore proper selection state:
|
||||
|
||||
list<wiRenderer::Picked*>* selectedCURRENT = nullptr;
|
||||
list<Picked*>* selectedCURRENT = nullptr;
|
||||
if (undo)
|
||||
{
|
||||
selectedCURRENT = &selectedBEFORE;
|
||||
|
||||
@@ -64,7 +64,6 @@ public:
|
||||
};
|
||||
void ChangeRenderPath(RENDERPATH path);
|
||||
void DeleteWindows();
|
||||
void UpdateFromPrimarySelection(const wiRenderer::Picked& sel);
|
||||
|
||||
void Initialize() override;
|
||||
void Load() override;
|
||||
|
||||
@@ -160,7 +160,8 @@ PostprocessWindow::PostprocessWindow(wiGUI* gui, Renderable3DComponent* comp) :
|
||||
colorGradingButton->SetPos(XMFLOAT2(x + 35, y));
|
||||
colorGradingButton->SetSize(XMFLOAT2(200, 18));
|
||||
colorGradingButton->OnClick([=](wiEventArgs args) {
|
||||
auto x = wiRenderer::GetColorGrading();
|
||||
//auto x = wiRenderer::GetColorGrading();
|
||||
auto x = component->getColorGradingTexture();
|
||||
|
||||
if (x == nullptr)
|
||||
{
|
||||
@@ -184,14 +185,19 @@ PostprocessWindow::PostprocessWindow(wiGUI* gui, Renderable3DComponent* comp) :
|
||||
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
|
||||
if (GetOpenFileNameA(&ofn) == TRUE) {
|
||||
string fileName = ofn.lpstrFile;
|
||||
wiRenderer::SetColorGrading((Texture2D*)wiResourceManager::GetGlobal()->add(fileName));
|
||||
colorGradingButton->SetText(fileName);
|
||||
//wiRenderer::SetColorGrading((Texture2D*)wiResourceManager::GetGlobal()->add(fileName));
|
||||
component->setColorGradingTexture((Texture2D*)wiResourceManager::GetGlobal()->add(fileName));
|
||||
if (component->getColorGradingTexture() != nullptr)
|
||||
{
|
||||
colorGradingButton->SetText(fileName);
|
||||
}
|
||||
}
|
||||
}).detach();
|
||||
}
|
||||
else
|
||||
{
|
||||
wiRenderer::SetColorGrading(nullptr);
|
||||
//wiRenderer::SetColorGrading(nullptr);
|
||||
component->setColorGradingTexture(nullptr);
|
||||
colorGradingButton->SetText("Load Color Grading LUT...");
|
||||
}
|
||||
|
||||
|
||||
@@ -547,14 +547,12 @@ RendererWindow::~RendererWindow()
|
||||
SAFE_DELETE(rendererWindow);
|
||||
}
|
||||
|
||||
int RendererWindow::GetPickType()
|
||||
UINT RendererWindow::GetPickType()
|
||||
{
|
||||
int pickType = PICK_VOID;
|
||||
UINT pickType = PICK_VOID;
|
||||
if (pickTypeObjectCheckBox->GetCheck())
|
||||
{
|
||||
pickType |= PICK_OPAQUE;
|
||||
pickType |= PICK_TRANSPARENT;
|
||||
pickType |= PICK_WATER;
|
||||
pickType |= PICK_OBJECT;
|
||||
}
|
||||
if (pickTypeEnvProbeCheckBox->GetCheck())
|
||||
{
|
||||
|
||||
+14
-1
@@ -7,6 +7,19 @@ class wiCheckBox;
|
||||
class wiSlider;
|
||||
class wiComboBox;
|
||||
|
||||
enum PICKTYPE
|
||||
{
|
||||
PICK_VOID = 0,
|
||||
PICK_OBJECT = RENDERTYPE_OPAQUE | RENDERTYPE_TRANSPARENT | RENDERTYPE_WATER,
|
||||
PICK_LIGHT = 8,
|
||||
PICK_DECAL = 16,
|
||||
PICK_ENVPROBE = 32,
|
||||
PICK_FORCEFIELD = 64,
|
||||
PICK_EMITTER = 128,
|
||||
PICK_CAMERA = 256,
|
||||
PICK_ARMATURE = 512,
|
||||
};
|
||||
|
||||
class RendererWindow
|
||||
{
|
||||
public:
|
||||
@@ -61,6 +74,6 @@ public:
|
||||
|
||||
wiCheckBox* freezeCullingCameraCheckBox;
|
||||
|
||||
int GetPickType();
|
||||
UINT GetPickType();
|
||||
};
|
||||
|
||||
|
||||
@@ -143,9 +143,11 @@ Test model and scene files are now available in the WickedEngine/models director
|
||||
|
||||
### Model import/export:
|
||||
|
||||
The only common model format supported right now is Wavefront OBJ.<br/>
|
||||
The Editor supports the importing of some common model formats (the list will potentially grow): <b>OBJ</b>, <b>GLTF 2.0</b>
|
||||
The Engine itself can open the serialized model format (<b>WIMF</b>) only. The preferred workflow is to import models into the editor, and save them out to <b>WIMF</b>, then any WickedEngine application can open them.
|
||||
|
||||
For advanced model format capabilities, like skeletal animations, particle systems, physics, etc. use the provided Blender exporter python script: io_export_wicked_wi_bin.py <br/>
|
||||
There is an additional model format designed for Blender supporting like skeletal animations, particle systems, physics, etc... Use the provided Blender exporter python script: <b>io_export_wicked_wi_bin.py</b> <br/>
|
||||
The Editor can open <b>WIO</b> files exported from Blender, and save them as <b>WIMF</b> models.
|
||||
|
||||
Notes on exporting:
|
||||
- Names should not contain spaces inside Blender<br/>
|
||||
|
||||
@@ -84,29 +84,12 @@ void DeferredRenderableComponent::Start()
|
||||
}
|
||||
void DeferredRenderableComponent::Render()
|
||||
{
|
||||
if (getThreadingCount() > 1)
|
||||
{
|
||||
for (auto workerThread : workerThreads)
|
||||
{
|
||||
workerThread->wakeup();
|
||||
}
|
||||
|
||||
for (auto workerThread : workerThreads)
|
||||
{
|
||||
workerThread->wait();
|
||||
}
|
||||
|
||||
wiRenderer::GetDevice()->ExecuteDeferredContexts();
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderFrameSetUp(GRAPHICSTHREAD_IMMEDIATE);
|
||||
RenderShadows(GRAPHICSTHREAD_IMMEDIATE);
|
||||
RenderReflections(GRAPHICSTHREAD_IMMEDIATE);
|
||||
RenderScene(GRAPHICSTHREAD_IMMEDIATE);
|
||||
RenderSecondaryScene(rtGBuffer, GetFinalRT(), GRAPHICSTHREAD_IMMEDIATE);
|
||||
RenderComposition(GetFinalRT(), rtGBuffer, GRAPHICSTHREAD_IMMEDIATE);
|
||||
}
|
||||
RenderFrameSetUp(GRAPHICSTHREAD_IMMEDIATE);
|
||||
RenderShadows(GRAPHICSTHREAD_IMMEDIATE);
|
||||
RenderReflections(GRAPHICSTHREAD_IMMEDIATE);
|
||||
RenderScene(GRAPHICSTHREAD_IMMEDIATE);
|
||||
RenderSecondaryScene(rtGBuffer, GetFinalRT(), GRAPHICSTHREAD_IMMEDIATE);
|
||||
RenderComposition(GetFinalRT(), rtGBuffer, GRAPHICSTHREAD_IMMEDIATE);
|
||||
|
||||
Renderable2DComponent::Render();
|
||||
}
|
||||
@@ -146,7 +129,7 @@ void DeferredRenderableComponent::RenderScene(GRAPHICSTHREAD threadID)
|
||||
|
||||
wiRenderer::GetDevice()->UnbindResources(TEXSLOT_ONDEMAND0, TEXSLOT_ONDEMAND_COUNT, threadID);
|
||||
|
||||
wiRenderer::UpdateDepthBuffer(dtDepthCopy.GetTexture(), rtLinearDepth.GetTexture(), threadID);
|
||||
wiRenderer::BindDepthTextures(dtDepthCopy.GetTexture(), rtLinearDepth.GetTexture(), threadID);
|
||||
|
||||
if (getStereogramEnabled())
|
||||
{
|
||||
@@ -160,7 +143,7 @@ void DeferredRenderableComponent::RenderScene(GRAPHICSTHREAD threadID)
|
||||
}
|
||||
rtGBuffer.Deactivate(threadID);
|
||||
|
||||
wiRenderer::UpdateGBuffer(rtGBuffer.GetTexture(0), rtGBuffer.GetTexture(1), rtGBuffer.GetTexture(2), rtGBuffer.GetTexture(3), nullptr, threadID);
|
||||
wiRenderer::BindGBufferTextures(rtGBuffer.GetTexture(0), rtGBuffer.GetTexture(1), rtGBuffer.GetTexture(2), rtGBuffer.GetTexture(3), nullptr, threadID);
|
||||
|
||||
|
||||
|
||||
@@ -294,97 +277,3 @@ wiDepthTarget* DeferredRenderableComponent::GetDepthBuffer()
|
||||
{
|
||||
return rtGBuffer.depth;
|
||||
}
|
||||
|
||||
void DeferredRenderableComponent::setPreferredThreadingCount(unsigned short value)
|
||||
{
|
||||
Renderable3DComponent::setPreferredThreadingCount(value);
|
||||
|
||||
if (!wiRenderer::GetDevice()->CheckCapability(GraphicsDevice::GRAPHICSDEVICE_CAPABILITY_MULTITHREADED_RENDERING))
|
||||
{
|
||||
if (value > 1)
|
||||
wiHelper::messageBox("Multithreaded rendering not supported by your hardware! Falling back to single threading!", "Caution");
|
||||
return;
|
||||
}
|
||||
|
||||
switch (value){
|
||||
case 2:
|
||||
workerThreads.push_back(new wiTaskThread([&]
|
||||
{
|
||||
RenderFrameSetUp(GRAPHICSTHREAD_REFLECTIONS);
|
||||
RenderReflections(GRAPHICSTHREAD_REFLECTIONS);
|
||||
wiRenderer::GetDevice()->FinishCommandList(GRAPHICSTHREAD_REFLECTIONS);
|
||||
}));
|
||||
workerThreads.push_back(new wiTaskThread([&]
|
||||
{
|
||||
wiRenderer::BindPersistentState(GRAPHICSTHREAD_SCENE);
|
||||
wiImage::BindPersistentState(GRAPHICSTHREAD_SCENE);
|
||||
RenderShadows(GRAPHICSTHREAD_SCENE);
|
||||
RenderScene(GRAPHICSTHREAD_SCENE);
|
||||
RenderSecondaryScene(rtGBuffer, GetFinalRT(), GRAPHICSTHREAD_SCENE);
|
||||
RenderComposition(GetFinalRT(), rtGBuffer, GRAPHICSTHREAD_SCENE);
|
||||
wiRenderer::GetDevice()->FinishCommandList(GRAPHICSTHREAD_SCENE);
|
||||
}));
|
||||
break;
|
||||
case 3:
|
||||
workerThreads.push_back(new wiTaskThread([&]
|
||||
{
|
||||
RenderFrameSetUp(GRAPHICSTHREAD_REFLECTIONS);
|
||||
RenderReflections(GRAPHICSTHREAD_REFLECTIONS);
|
||||
wiRenderer::GetDevice()->FinishCommandList(GRAPHICSTHREAD_REFLECTIONS);
|
||||
}));
|
||||
workerThreads.push_back(new wiTaskThread([&]
|
||||
{
|
||||
wiRenderer::BindPersistentState(GRAPHICSTHREAD_SCENE);
|
||||
wiImage::BindPersistentState(GRAPHICSTHREAD_SCENE);
|
||||
RenderShadows(GRAPHICSTHREAD_SCENE);
|
||||
RenderScene(GRAPHICSTHREAD_SCENE);
|
||||
wiRenderer::GetDevice()->FinishCommandList(GRAPHICSTHREAD_SCENE);
|
||||
}));
|
||||
workerThreads.push_back(new wiTaskThread([&]
|
||||
{
|
||||
wiRenderer::BindPersistentState(GRAPHICSTHREAD_MISC1);
|
||||
wiImage::BindPersistentState(GRAPHICSTHREAD_MISC1);
|
||||
wiRenderer::UpdateDepthBuffer(dtDepthCopy.GetTexture(), rtLinearDepth.GetTexture(), GRAPHICSTHREAD_MISC1);
|
||||
wiRenderer::UpdateGBuffer(rtGBuffer.GetTexture(0), rtGBuffer.GetTexture(1), rtGBuffer.GetTexture(2), nullptr, nullptr, GRAPHICSTHREAD_MISC1);
|
||||
RenderSecondaryScene(rtGBuffer, GetFinalRT(), GRAPHICSTHREAD_MISC1);
|
||||
RenderComposition(GetFinalRT(), rtGBuffer, GRAPHICSTHREAD_MISC1);
|
||||
wiRenderer::GetDevice()->FinishCommandList(GRAPHICSTHREAD_MISC1);
|
||||
}));
|
||||
break;
|
||||
case 4:
|
||||
workerThreads.push_back(new wiTaskThread([&]
|
||||
{
|
||||
RenderFrameSetUp(GRAPHICSTHREAD_REFLECTIONS);
|
||||
RenderReflections(GRAPHICSTHREAD_REFLECTIONS);
|
||||
wiRenderer::GetDevice()->FinishCommandList(GRAPHICSTHREAD_REFLECTIONS);
|
||||
}));
|
||||
workerThreads.push_back(new wiTaskThread([&]
|
||||
{
|
||||
wiRenderer::BindPersistentState(GRAPHICSTHREAD_SCENE);
|
||||
wiImage::BindPersistentState(GRAPHICSTHREAD_SCENE);
|
||||
RenderShadows(GRAPHICSTHREAD_SCENE);
|
||||
RenderScene(GRAPHICSTHREAD_SCENE);
|
||||
wiRenderer::GetDevice()->FinishCommandList(GRAPHICSTHREAD_SCENE);
|
||||
}));
|
||||
workerThreads.push_back(new wiTaskThread([&]
|
||||
{
|
||||
wiRenderer::BindPersistentState(GRAPHICSTHREAD_MISC1);
|
||||
wiImage::BindPersistentState(GRAPHICSTHREAD_MISC1);
|
||||
wiRenderer::UpdateDepthBuffer(dtDepthCopy.GetTexture(), rtLinearDepth.GetTexture(), GRAPHICSTHREAD_MISC1);
|
||||
wiRenderer::UpdateGBuffer(rtGBuffer.GetTexture(0), rtGBuffer.GetTexture(1), rtGBuffer.GetTexture(2), nullptr, nullptr, GRAPHICSTHREAD_MISC1);
|
||||
RenderSecondaryScene(rtGBuffer, GetFinalRT(), GRAPHICSTHREAD_MISC1);
|
||||
wiRenderer::GetDevice()->FinishCommandList(GRAPHICSTHREAD_MISC1);
|
||||
}));
|
||||
workerThreads.push_back(new wiTaskThread([&]
|
||||
{
|
||||
wiRenderer::BindPersistentState(GRAPHICSTHREAD_MISC2);
|
||||
wiImage::BindPersistentState(GRAPHICSTHREAD_MISC2);
|
||||
wiRenderer::UpdateDepthBuffer(dtDepthCopy.GetTexture(), rtLinearDepth.GetTexture(), GRAPHICSTHREAD_MISC2);
|
||||
wiRenderer::UpdateGBuffer(rtGBuffer.GetTexture(0), rtGBuffer.GetTexture(1), rtGBuffer.GetTexture(2), nullptr, nullptr, GRAPHICSTHREAD_MISC2);
|
||||
RenderComposition(GetFinalRT(), rtGBuffer, GRAPHICSTHREAD_MISC2);
|
||||
wiRenderer::GetDevice()->FinishCommandList(GRAPHICSTHREAD_MISC2);
|
||||
}));
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,6 @@ public:
|
||||
|
||||
virtual wiDepthTarget* GetDepthBuffer() override;
|
||||
|
||||
virtual void setPreferredThreadingCount(unsigned short value) override;
|
||||
|
||||
virtual void Initialize() override;
|
||||
virtual void Load() override;
|
||||
virtual void Start() override;
|
||||
|
||||
@@ -40,6 +40,7 @@ Luna<DeferredRenderableComponent_BindLua>::FunctionType DeferredRenderableCompon
|
||||
lunamethod(Renderable3DComponent_BindLua, SetFXAAEnabled),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetBloomEnabled),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetColorGradingEnabled),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetColorGradingTexture),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetEmitterParticlesEnabled),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetHairParticlesEnabled),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetHairParticlesReflectionEnabled),
|
||||
@@ -58,7 +59,6 @@ Luna<DeferredRenderableComponent_BindLua>::FunctionType DeferredRenderableCompon
|
||||
lunamethod(Renderable3DComponent_BindLua, SetDepthOfFieldFocus),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetDepthOfFieldStrength),
|
||||
|
||||
lunamethod(Renderable3DComponent_BindLua, SetPreferredThreadingCount),
|
||||
{ NULL, NULL }
|
||||
};
|
||||
Luna<DeferredRenderableComponent_BindLua>::PropertyType DeferredRenderableComponent_BindLua::properties[] = {
|
||||
|
||||
@@ -15,8 +15,6 @@ ForwardRenderableComponent::ForwardRenderableComponent()
|
||||
setSSREnabled(false);
|
||||
setSSAOEnabled(false);
|
||||
setShadowsEnabled(false);
|
||||
|
||||
setPreferredThreadingCount(0);
|
||||
}
|
||||
ForwardRenderableComponent::~ForwardRenderableComponent()
|
||||
{
|
||||
@@ -68,30 +66,12 @@ void ForwardRenderableComponent::Start()
|
||||
}
|
||||
void ForwardRenderableComponent::Render()
|
||||
{
|
||||
if (getThreadingCount() > 1)
|
||||
{
|
||||
|
||||
for (auto workerThread : workerThreads)
|
||||
{
|
||||
workerThread->wakeup();
|
||||
}
|
||||
|
||||
for (auto workerThread : workerThreads)
|
||||
{
|
||||
workerThread->wait();
|
||||
}
|
||||
|
||||
wiRenderer::GetDevice()->ExecuteDeferredContexts();
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderFrameSetUp(GRAPHICSTHREAD_IMMEDIATE);
|
||||
RenderShadows(GRAPHICSTHREAD_IMMEDIATE);
|
||||
RenderReflections(GRAPHICSTHREAD_IMMEDIATE);
|
||||
RenderScene(GRAPHICSTHREAD_IMMEDIATE);
|
||||
RenderSecondaryScene(rtMain, rtMain, GRAPHICSTHREAD_IMMEDIATE);
|
||||
RenderComposition(rtMain, rtMain, GRAPHICSTHREAD_IMMEDIATE);
|
||||
}
|
||||
RenderFrameSetUp(GRAPHICSTHREAD_IMMEDIATE);
|
||||
RenderShadows(GRAPHICSTHREAD_IMMEDIATE);
|
||||
RenderReflections(GRAPHICSTHREAD_IMMEDIATE);
|
||||
RenderScene(GRAPHICSTHREAD_IMMEDIATE);
|
||||
RenderSecondaryScene(rtMain, rtMain, GRAPHICSTHREAD_IMMEDIATE);
|
||||
RenderComposition(rtMain, rtMain, GRAPHICSTHREAD_IMMEDIATE);
|
||||
|
||||
Renderable2DComponent::Render();
|
||||
}
|
||||
@@ -117,7 +97,7 @@ void ForwardRenderableComponent::RenderScene(GRAPHICSTHREAD threadID)
|
||||
wiRenderer::DrawSky(threadID);
|
||||
}
|
||||
rtMain.Deactivate(threadID);
|
||||
wiRenderer::UpdateGBuffer(rtMain.GetTextureResolvedMSAA(threadID, 0), rtMain.GetTextureResolvedMSAA(threadID, 1), nullptr, nullptr, nullptr, threadID);
|
||||
wiRenderer::BindGBufferTextures(rtMain.GetTextureResolvedMSAA(threadID, 0), rtMain.GetTextureResolvedMSAA(threadID, 1), nullptr, nullptr, nullptr, threadID);
|
||||
|
||||
wiRenderer::GetDevice()->TransitionBarrier(dsv, ARRAYSIZE(dsv), RESOURCE_STATE_DEPTH_WRITE, RESOURCE_STATE_COPY_SOURCE, threadID);
|
||||
|
||||
@@ -135,7 +115,7 @@ void ForwardRenderableComponent::RenderScene(GRAPHICSTHREAD threadID)
|
||||
}
|
||||
rtLinearDepth.Deactivate(threadID);
|
||||
|
||||
wiRenderer::UpdateDepthBuffer(dtDepthCopy.GetTextureResolvedMSAA(threadID), rtLinearDepth.GetTexture(), threadID);
|
||||
wiRenderer::BindDepthTextures(dtDepthCopy.GetTextureResolvedMSAA(threadID), rtLinearDepth.GetTexture(), threadID);
|
||||
|
||||
|
||||
if (getSSAOEnabled()) {
|
||||
@@ -190,98 +170,3 @@ wiDepthTarget* ForwardRenderableComponent::GetDepthBuffer()
|
||||
{
|
||||
return rtMain.depth;
|
||||
}
|
||||
|
||||
void ForwardRenderableComponent::setPreferredThreadingCount(unsigned short value)
|
||||
{
|
||||
Renderable3DComponent::setPreferredThreadingCount(value);
|
||||
|
||||
if (!wiRenderer::GetDevice()->CheckCapability(GraphicsDevice::GRAPHICSDEVICE_CAPABILITY_MULTITHREADED_RENDERING))
|
||||
{
|
||||
if (value > 1)
|
||||
wiHelper::messageBox("Multithreaded rendering not supported by your hardware! Falling back to single threading!", "Caution");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
switch (value) {
|
||||
case 2:
|
||||
workerThreads.push_back(new wiTaskThread([&]
|
||||
{
|
||||
RenderFrameSetUp(GRAPHICSTHREAD_REFLECTIONS);
|
||||
RenderReflections(GRAPHICSTHREAD_REFLECTIONS);
|
||||
wiRenderer::GetDevice()->FinishCommandList(GRAPHICSTHREAD_REFLECTIONS);
|
||||
}));
|
||||
workerThreads.push_back(new wiTaskThread([&]
|
||||
{
|
||||
wiRenderer::BindPersistentState(GRAPHICSTHREAD_SCENE);
|
||||
wiImage::BindPersistentState(GRAPHICSTHREAD_SCENE);
|
||||
RenderShadows(GRAPHICSTHREAD_SCENE);
|
||||
RenderScene(GRAPHICSTHREAD_SCENE);
|
||||
RenderSecondaryScene(rtMain, rtMain, GRAPHICSTHREAD_SCENE);
|
||||
RenderComposition(rtMain, rtMain, GRAPHICSTHREAD_SCENE);
|
||||
wiRenderer::GetDevice()->FinishCommandList(GRAPHICSTHREAD_SCENE);
|
||||
}));
|
||||
break;
|
||||
case 3:
|
||||
workerThreads.push_back(new wiTaskThread([&]
|
||||
{
|
||||
RenderFrameSetUp(GRAPHICSTHREAD_REFLECTIONS);
|
||||
RenderReflections(GRAPHICSTHREAD_REFLECTIONS);
|
||||
wiRenderer::GetDevice()->FinishCommandList(GRAPHICSTHREAD_REFLECTIONS);
|
||||
}));
|
||||
workerThreads.push_back(new wiTaskThread([&]
|
||||
{
|
||||
wiRenderer::BindPersistentState(GRAPHICSTHREAD_SCENE);
|
||||
wiImage::BindPersistentState(GRAPHICSTHREAD_SCENE);
|
||||
RenderShadows(GRAPHICSTHREAD_SCENE);
|
||||
RenderScene(GRAPHICSTHREAD_SCENE);
|
||||
wiRenderer::GetDevice()->FinishCommandList(GRAPHICSTHREAD_SCENE);
|
||||
}));
|
||||
workerThreads.push_back(new wiTaskThread([&]
|
||||
{
|
||||
wiRenderer::BindPersistentState(GRAPHICSTHREAD_MISC1);
|
||||
wiImage::BindPersistentState(GRAPHICSTHREAD_MISC1);
|
||||
wiRenderer::UpdateDepthBuffer(dtDepthCopy.GetTexture(), rtLinearDepth.GetTexture(), GRAPHICSTHREAD_MISC1);
|
||||
wiRenderer::UpdateGBuffer(rtMain.GetTexture(0), rtMain.GetTexture(1), rtMain.GetTexture(2), nullptr, nullptr, GRAPHICSTHREAD_MISC1);
|
||||
RenderSecondaryScene(rtMain, rtMain, GRAPHICSTHREAD_MISC1);
|
||||
RenderComposition(rtMain, rtMain, GRAPHICSTHREAD_MISC1);
|
||||
wiRenderer::GetDevice()->FinishCommandList(GRAPHICSTHREAD_MISC1);
|
||||
}));
|
||||
break;
|
||||
case 4:
|
||||
workerThreads.push_back(new wiTaskThread([&]
|
||||
{
|
||||
RenderFrameSetUp(GRAPHICSTHREAD_REFLECTIONS);
|
||||
RenderReflections(GRAPHICSTHREAD_REFLECTIONS);
|
||||
wiRenderer::GetDevice()->FinishCommandList(GRAPHICSTHREAD_REFLECTIONS);
|
||||
}));
|
||||
workerThreads.push_back(new wiTaskThread([&]
|
||||
{
|
||||
wiRenderer::BindPersistentState(GRAPHICSTHREAD_SCENE);
|
||||
wiImage::BindPersistentState(GRAPHICSTHREAD_SCENE);
|
||||
RenderShadows(GRAPHICSTHREAD_SCENE);
|
||||
RenderScene(GRAPHICSTHREAD_SCENE);
|
||||
wiRenderer::GetDevice()->FinishCommandList(GRAPHICSTHREAD_SCENE);
|
||||
}));
|
||||
workerThreads.push_back(new wiTaskThread([&]
|
||||
{
|
||||
wiRenderer::BindPersistentState(GRAPHICSTHREAD_MISC1);
|
||||
wiImage::BindPersistentState(GRAPHICSTHREAD_MISC1);
|
||||
wiRenderer::UpdateDepthBuffer(dtDepthCopy.GetTexture(), rtLinearDepth.GetTexture(), GRAPHICSTHREAD_MISC1);
|
||||
wiRenderer::UpdateGBuffer(rtMain.GetTexture(0), rtMain.GetTexture(1), rtMain.GetTexture(2), nullptr, nullptr, GRAPHICSTHREAD_MISC1);
|
||||
RenderSecondaryScene(rtMain, rtMain, GRAPHICSTHREAD_MISC1);
|
||||
wiRenderer::GetDevice()->FinishCommandList(GRAPHICSTHREAD_MISC1);
|
||||
}));
|
||||
workerThreads.push_back(new wiTaskThread([&]
|
||||
{
|
||||
wiRenderer::BindPersistentState(GRAPHICSTHREAD_MISC2);
|
||||
wiImage::BindPersistentState(GRAPHICSTHREAD_MISC2);
|
||||
wiRenderer::UpdateDepthBuffer(dtDepthCopy.GetTexture(), rtLinearDepth.GetTexture(), GRAPHICSTHREAD_MISC2);
|
||||
wiRenderer::UpdateGBuffer(rtMain.GetTexture(0), rtMain.GetTexture(1), rtMain.GetTexture(2), nullptr, nullptr, GRAPHICSTHREAD_MISC2);
|
||||
RenderComposition(rtMain, rtMain, GRAPHICSTHREAD_MISC2);
|
||||
wiRenderer::GetDevice()->FinishCommandList(GRAPHICSTHREAD_MISC2);
|
||||
}));
|
||||
break;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -18,9 +18,6 @@ public:
|
||||
|
||||
virtual wiDepthTarget* GetDepthBuffer() override;
|
||||
|
||||
|
||||
virtual void setPreferredThreadingCount(unsigned short value) override;
|
||||
|
||||
virtual void Initialize() override;
|
||||
virtual void Load() override;
|
||||
virtual void Start() override;
|
||||
|
||||
@@ -40,6 +40,7 @@ Luna<ForwardRenderableComponent_BindLua>::FunctionType ForwardRenderableComponen
|
||||
lunamethod(Renderable3DComponent_BindLua, SetFXAAEnabled),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetBloomEnabled),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetColorGradingEnabled),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetColorGradingTexture),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetEmitterParticlesEnabled),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetHairParticlesEnabled),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetHairParticlesReflectionEnabled),
|
||||
@@ -58,8 +59,6 @@ Luna<ForwardRenderableComponent_BindLua>::FunctionType ForwardRenderableComponen
|
||||
|
||||
lunamethod(Renderable3DComponent_BindLua, SetDepthOfFieldFocus),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetDepthOfFieldStrength),
|
||||
|
||||
lunamethod(Renderable3DComponent_BindLua, SetPreferredThreadingCount),
|
||||
{ NULL, NULL }
|
||||
};
|
||||
Luna<ForwardRenderableComponent_BindLua>::PropertyType ForwardRenderableComponent_BindLua::properties[] = {
|
||||
|
||||
@@ -38,8 +38,7 @@ MainComponent::MainComponent()
|
||||
setTargetFrameRate(60);
|
||||
setApplicationControlLostThreshold(10);
|
||||
|
||||
infoDisplay = InfoDisplayer();
|
||||
colorGradingPaletteDisplayEnabled = false;
|
||||
infoDisplay = InfoDisplayer();
|
||||
|
||||
fadeManager.Clear();
|
||||
}
|
||||
@@ -282,14 +281,6 @@ void MainComponent::Compose()
|
||||
|
||||
wiProfiler::GetInstance().DrawData(4, 120, GRAPHICSTHREAD_IMMEDIATE);
|
||||
|
||||
// Draw the color grading palette
|
||||
if (colorGradingPaletteDisplayEnabled)
|
||||
{
|
||||
//wiImage::BatchBegin();
|
||||
wiImage::Draw(wiTextureHelper::getInstance()->getColorGradeDefault(), wiImageEffects(0, 0, 256, 16), GRAPHICSTHREAD_IMMEDIATE);
|
||||
wiImage::Draw(wiRenderer::GetColorGrading(), wiImageEffects(screenW-256.f, 0, 256, 16), GRAPHICSTHREAD_IMMEDIATE);
|
||||
}
|
||||
|
||||
wiBackLog::Draw();
|
||||
}
|
||||
|
||||
|
||||
@@ -77,8 +77,5 @@ public:
|
||||
};
|
||||
// display all-time engine information text
|
||||
InfoDisplayer infoDisplay;
|
||||
|
||||
// display the default color grading palette
|
||||
bool colorGradingPaletteDisplayEnabled;
|
||||
};
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ Luna<MainComponent_BindLua>::FunctionType MainComponent_BindLua::methods[] = {
|
||||
lunamethod(MainComponent_BindLua, SetFPSDisplay),
|
||||
lunamethod(MainComponent_BindLua, SetCPUDisplay),
|
||||
lunamethod(MainComponent_BindLua, SetResolutionDisplay),
|
||||
lunamethod(MainComponent_BindLua, SetColorGradePaletteDisplay),
|
||||
{ NULL, NULL }
|
||||
};
|
||||
Luna<MainComponent_BindLua>::PropertyType MainComponent_BindLua::properties[] = {
|
||||
@@ -317,22 +316,6 @@ int MainComponent_BindLua::SetResolutionDisplay(lua_State *L)
|
||||
wiLua::SError(L, "SetResolutionDisplay(bool active) not enough arguments!");
|
||||
return 0;
|
||||
}
|
||||
int MainComponent_BindLua::SetColorGradePaletteDisplay(lua_State* L)
|
||||
{
|
||||
if (component == nullptr)
|
||||
{
|
||||
wiLua::SError(L, "SetColorGradePaletteDisplay() component is empty!");
|
||||
return 0;
|
||||
}
|
||||
int argc = wiLua::SGetArgCount(L);
|
||||
if (argc > 0)
|
||||
{
|
||||
component->colorGradingPaletteDisplayEnabled = wiLua::SGetBool(L, 1);
|
||||
}
|
||||
else
|
||||
wiLua::SError(L, "SetColorGradePaletteDisplay(bool active) not enough arguments!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int SetProfilerEnabled(lua_State* L)
|
||||
|
||||
@@ -25,7 +25,6 @@ public:
|
||||
int SetFPSDisplay(lua_State *L);
|
||||
int SetCPUDisplay(lua_State *L);
|
||||
int SetResolutionDisplay(lua_State *L);
|
||||
int SetColorGradePaletteDisplay(lua_State* L);
|
||||
|
||||
static void Bind();
|
||||
};
|
||||
|
||||
@@ -15,10 +15,6 @@ Renderable3DComponent::Renderable3DComponent() : Renderable2DComponent()
|
||||
}
|
||||
Renderable3DComponent::~Renderable3DComponent()
|
||||
{
|
||||
for (auto& wt : workerThreads)
|
||||
{
|
||||
delete wt;
|
||||
}
|
||||
}
|
||||
|
||||
wiRenderTarget
|
||||
@@ -195,8 +191,6 @@ void Renderable3DComponent::setProperties()
|
||||
setSharpenFilterEnabled(false);
|
||||
|
||||
setMSAASampleCount(1);
|
||||
|
||||
setPreferredThreadingCount(0);
|
||||
}
|
||||
|
||||
void Renderable3DComponent::Initialize()
|
||||
@@ -220,7 +214,6 @@ void Renderable3DComponent::Start()
|
||||
void Renderable3DComponent::FixedUpdate()
|
||||
{
|
||||
wiRenderer::FixedUpdate();
|
||||
wiRenderer::UpdateImages();
|
||||
|
||||
Renderable2DComponent::FixedUpdate();
|
||||
}
|
||||
@@ -443,18 +436,7 @@ void Renderable3DComponent::RenderSecondaryScene(wiRenderTarget& mainRT, wiRende
|
||||
wiRenderer::DrawLensFlares(threadID);
|
||||
}
|
||||
|
||||
wiRenderer::GetDevice()->EventBegin("Debug Geometry", threadID);
|
||||
wiRenderer::DrawDebugGridHelper(wiRenderer::getCamera(), threadID);
|
||||
wiRenderer::DrawDebugVoxels(wiRenderer::getCamera(), threadID);
|
||||
wiRenderer::DrawDebugEnvProbes(wiRenderer::getCamera(), threadID);
|
||||
wiRenderer::DrawDebugBoneLines(wiRenderer::getCamera(), threadID);
|
||||
wiRenderer::DrawDebugLines(wiRenderer::getCamera(), threadID);
|
||||
wiRenderer::DrawDebugBoxes(wiRenderer::getCamera(), threadID);
|
||||
wiRenderer::DrawDebugForceFields(wiRenderer::getCamera(), threadID);
|
||||
wiRenderer::DrawDebugEmitters(wiRenderer::getCamera(), threadID);
|
||||
wiRenderer::DrawDebugCameras(wiRenderer::getCamera(), threadID);
|
||||
wiRenderer::DrawTranslators(wiRenderer::getCamera(), threadID);
|
||||
wiRenderer::GetDevice()->EventEnd(threadID);
|
||||
wiRenderer::DrawDebugWorld(wiRenderer::getCamera(), threadID);
|
||||
}
|
||||
|
||||
if (getEmittedParticlesEnabled())
|
||||
@@ -497,7 +479,7 @@ void Renderable3DComponent::RenderComposition(wiRenderTarget& shadedSceneRT, wiR
|
||||
int current = wiRenderer::GetDevice()->GetFrameCount() % 2 == 0 ? 0 : 1;
|
||||
int history = 1 - current;
|
||||
rtTemporalAA[current].Set(threadID); {
|
||||
wiRenderer::UpdateGBuffer(mainRT.GetTextureResolvedMSAA(threadID, 0), mainRT.GetTextureResolvedMSAA(threadID, 1), nullptr, nullptr, nullptr, threadID);
|
||||
wiRenderer::BindGBufferTextures(mainRT.GetTextureResolvedMSAA(threadID, 0), mainRT.GetTextureResolvedMSAA(threadID, 1), nullptr, nullptr, nullptr, threadID);
|
||||
fx.presentFullScreen = false;
|
||||
fx.process.setTemporalAAResolve(true);
|
||||
fx.setMaskMap(rtTemporalAA[history].GetTexture());
|
||||
@@ -683,9 +665,9 @@ void Renderable3DComponent::RenderColorGradedComposition()
|
||||
if (getColorGradingEnabled())
|
||||
{
|
||||
wiRenderer::GetDevice()->EventBegin("Color Graded Composition", GRAPHICSTHREAD_IMMEDIATE);
|
||||
if (wiRenderer::GetColorGrading() != nullptr){
|
||||
if (colorGradingTex != nullptr){
|
||||
fx.process.setColorGrade(true);
|
||||
fx.setMaskMap(wiRenderer::GetColorGrading());
|
||||
fx.setMaskMap(colorGradingTex);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -709,14 +691,3 @@ void Renderable3DComponent::RenderColorGradedComposition()
|
||||
}
|
||||
wiRenderer::GetDevice()->EventEnd(GRAPHICSTHREAD_IMMEDIATE);
|
||||
}
|
||||
|
||||
|
||||
void Renderable3DComponent::setPreferredThreadingCount(unsigned short value)
|
||||
{
|
||||
for (auto& wt : workerThreads)
|
||||
{
|
||||
delete wt;
|
||||
}
|
||||
|
||||
workerThreads.clear();
|
||||
}
|
||||
@@ -1,10 +1,8 @@
|
||||
#pragma once
|
||||
#include "Renderable2DComponent.h"
|
||||
#include "wiTaskThread.h"
|
||||
#include "wiRenderer.h"
|
||||
#include "wiWaterPlane.h"
|
||||
#include "wiGraphicsDevice.h"
|
||||
#include <atomic>
|
||||
|
||||
class Renderable3DComponent :
|
||||
public Renderable2DComponent
|
||||
@@ -44,6 +42,8 @@ private:
|
||||
bool tessellationEnabled;
|
||||
bool sharpenFilterEnabled;
|
||||
|
||||
wiGraphicsTypes::Texture2D* colorGradingTex = nullptr;
|
||||
|
||||
UINT msaaSampleCount;
|
||||
|
||||
protected:
|
||||
@@ -66,8 +66,6 @@ protected:
|
||||
|
||||
virtual void ResizeBuffers() override;
|
||||
|
||||
std::vector<wiTaskThread*> workerThreads;
|
||||
|
||||
virtual void RenderFrameSetUp(GRAPHICSTHREAD threadID);
|
||||
virtual void RenderReflections(GRAPHICSTHREAD threadID);
|
||||
virtual void RenderShadows(GRAPHICSTHREAD threadID);
|
||||
@@ -113,9 +111,9 @@ public:
|
||||
inline bool getTessellationEnabled() { return tessellationEnabled && wiRenderer::GetDevice()->CheckCapability(wiGraphicsTypes::GraphicsDevice::GRAPHICSDEVICE_CAPABILITY_TESSELLATION); }
|
||||
inline bool getSharpenFilterEnabled() { return sharpenFilterEnabled && getSharpenFilterAmount() > 0; }
|
||||
|
||||
inline UINT getMSAASampleCount() { return msaaSampleCount; }
|
||||
inline wiGraphicsTypes::Texture2D* getColorGradingTexture() { return colorGradingTex; }
|
||||
|
||||
inline unsigned int getThreadingCount(){ return (unsigned int)workerThreads.size(); }
|
||||
inline UINT getMSAASampleCount() { return msaaSampleCount; }
|
||||
|
||||
inline void setLightShaftQuality(float value){ lightShaftQuality = value; }
|
||||
inline void setBloomDownSample(float value){ bloomDownSample = value; }
|
||||
@@ -151,11 +149,10 @@ public:
|
||||
inline void setTessellationEnabled(bool value) { tessellationEnabled = value; }
|
||||
inline void setSharpenFilterEnabled(bool value) { sharpenFilterEnabled = value; }
|
||||
|
||||
inline void setColorGradingTexture(wiGraphicsTypes::Texture2D* tex) { colorGradingTex = tex; }
|
||||
|
||||
inline void setMSAASampleCount(UINT value) { msaaSampleCount = value; ResizeBuffers(); }
|
||||
|
||||
|
||||
virtual void setPreferredThreadingCount(unsigned short value);
|
||||
|
||||
void setProperties();
|
||||
|
||||
Renderable3DComponent();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "Renderable3DComponent_BindLua.h"
|
||||
#include "wiResourceManager_BindLua.h"
|
||||
#include "Texture_BindLua.h"
|
||||
|
||||
const char Renderable3DComponent_BindLua::className[] = "Renderable3DComponent";
|
||||
|
||||
@@ -41,6 +42,7 @@ Luna<Renderable3DComponent_BindLua>::FunctionType Renderable3DComponent_BindLua:
|
||||
lunamethod(Renderable3DComponent_BindLua, SetFXAAEnabled),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetBloomEnabled),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetColorGradingEnabled),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetColorGradingTexture),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetEmitterParticlesEnabled),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetHairParticlesEnabled),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetHairParticlesReflectionEnabled),
|
||||
@@ -59,8 +61,6 @@ Luna<Renderable3DComponent_BindLua>::FunctionType Renderable3DComponent_BindLua:
|
||||
|
||||
lunamethod(Renderable3DComponent_BindLua, SetDepthOfFieldFocus),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetDepthOfFieldStrength),
|
||||
|
||||
lunamethod(Renderable3DComponent_BindLua, SetPreferredThreadingCount),
|
||||
{ NULL, NULL }
|
||||
};
|
||||
Luna<Renderable3DComponent_BindLua>::PropertyType Renderable3DComponent_BindLua::properties[] = {
|
||||
@@ -173,6 +173,24 @@ int Renderable3DComponent_BindLua::SetColorGradingEnabled(lua_State* L)
|
||||
wiLua::SError(L, "SetColorGradingEnabled(bool value) not enough arguments!");
|
||||
return 0;
|
||||
}
|
||||
int Renderable3DComponent_BindLua::SetColorGradingTexture(lua_State* L)
|
||||
{
|
||||
int argc = wiLua::SGetArgCount(L);
|
||||
if (argc > 0)
|
||||
{
|
||||
Texture_BindLua* tex = Luna<Texture_BindLua>::lightcheck(L, 1);
|
||||
if (tex != nullptr)
|
||||
{
|
||||
((Renderable3DComponent*)component)->setColorGradingTexture(tex->texture);
|
||||
}
|
||||
else
|
||||
wiLua::SError(L, "SetColorGradingTexture(Texture texture2D) argument is not a texture!");
|
||||
}
|
||||
else
|
||||
wiLua::SError(L, "SetColorGradingTexture(Texture texture2D) not enough arguments!");
|
||||
|
||||
return 0;
|
||||
}
|
||||
int Renderable3DComponent_BindLua::SetEmitterParticlesEnabled(lua_State* L)
|
||||
{
|
||||
if (component == nullptr)
|
||||
@@ -415,22 +433,6 @@ int Renderable3DComponent_BindLua::SetDepthOfFieldStrength(lua_State* L)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Renderable3DComponent_BindLua::SetPreferredThreadingCount(lua_State* L)
|
||||
{
|
||||
if (component == nullptr)
|
||||
{
|
||||
wiLua::SError(L, "SetPreferredThreadingCount(int value) component is null!");
|
||||
return 0;
|
||||
}
|
||||
if (wiLua::SGetArgCount(L) > 0)
|
||||
{
|
||||
((Renderable3DComponent*)component)->setPreferredThreadingCount((unsigned short)wiLua::SGetInt(L, 1));
|
||||
}
|
||||
else
|
||||
wiLua::SError(L, "SetPreferredThreadingCount(int value) not enough arguments!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Renderable3DComponent_BindLua::Bind()
|
||||
{
|
||||
static bool initialized = false;
|
||||
|
||||
@@ -22,6 +22,7 @@ public:
|
||||
int SetFXAAEnabled(lua_State* L);
|
||||
int SetBloomEnabled(lua_State* L);
|
||||
int SetColorGradingEnabled(lua_State* L);
|
||||
int SetColorGradingTexture(lua_State* L);
|
||||
int SetEmitterParticlesEnabled(lua_State* L);
|
||||
int SetHairParticlesEnabled(lua_State* L);
|
||||
int SetHairParticlesReflectionEnabled(lua_State* L);
|
||||
@@ -41,8 +42,6 @@ public:
|
||||
int SetDepthOfFieldFocus(lua_State* L);
|
||||
int SetDepthOfFieldStrength(lua_State* L);
|
||||
|
||||
int SetPreferredThreadingCount(lua_State* L);
|
||||
|
||||
static void Bind();
|
||||
};
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ void TiledDeferredRenderableComponent::RenderScene(GRAPHICSTHREAD threadID)
|
||||
|
||||
wiRenderer::GetDevice()->UnbindResources(TEXSLOT_ONDEMAND0, TEXSLOT_ONDEMAND_COUNT, threadID);
|
||||
|
||||
wiRenderer::UpdateDepthBuffer(dtDepthCopy.GetTexture(), rtLinearDepth.GetTexture(), threadID);
|
||||
wiRenderer::BindDepthTextures(dtDepthCopy.GetTexture(), rtLinearDepth.GetTexture(), threadID);
|
||||
|
||||
if (getStereogramEnabled())
|
||||
{
|
||||
@@ -73,7 +73,7 @@ void TiledDeferredRenderableComponent::RenderScene(GRAPHICSTHREAD threadID)
|
||||
}
|
||||
rtGBuffer.Deactivate(threadID);
|
||||
|
||||
wiRenderer::UpdateGBuffer(rtGBuffer.GetTexture(0), rtGBuffer.GetTexture(1), rtGBuffer.GetTexture(2), rtGBuffer.GetTexture(3), nullptr, threadID);
|
||||
wiRenderer::BindGBufferTextures(rtGBuffer.GetTexture(0), rtGBuffer.GetTexture(1), rtGBuffer.GetTexture(2), rtGBuffer.GetTexture(3), nullptr, threadID);
|
||||
|
||||
|
||||
wiRenderer::GetDevice()->BindResource(CS, getSSREnabled() ? rtSSR.GetTexture() : wiTextureHelper::getInstance()->getTransparent(), TEXSLOT_RENDERABLECOMPONENT_SSR, threadID);
|
||||
|
||||
@@ -40,6 +40,7 @@ Luna<TiledDeferredRenderableComponent_BindLua>::FunctionType TiledDeferredRender
|
||||
lunamethod(Renderable3DComponent_BindLua, SetFXAAEnabled),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetBloomEnabled),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetColorGradingEnabled),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetColorGradingTexture),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetEmitterParticlesEnabled),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetHairParticlesEnabled),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetHairParticlesReflectionEnabled),
|
||||
@@ -58,8 +59,7 @@ Luna<TiledDeferredRenderableComponent_BindLua>::FunctionType TiledDeferredRender
|
||||
lunamethod(Renderable3DComponent_BindLua, SetDepthOfFieldFocus),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetDepthOfFieldStrength),
|
||||
|
||||
lunamethod(Renderable3DComponent_BindLua, SetPreferredThreadingCount),
|
||||
{ NULL, NULL }
|
||||
{ NULL, NULL }
|
||||
};
|
||||
Luna<TiledDeferredRenderableComponent_BindLua>::PropertyType TiledDeferredRenderableComponent_BindLua::properties[] = {
|
||||
{ NULL, NULL }
|
||||
|
||||
@@ -48,7 +48,7 @@ void TiledForwardRenderableComponent::RenderScene(GRAPHICSTHREAD threadID)
|
||||
}
|
||||
rtLinearDepth.Deactivate(threadID);
|
||||
|
||||
wiRenderer::UpdateDepthBuffer(dtDepthCopy.GetTextureResolvedMSAA(threadID), rtLinearDepth.GetTexture(), threadID);
|
||||
wiRenderer::BindDepthTextures(dtDepthCopy.GetTextureResolvedMSAA(threadID), rtLinearDepth.GetTexture(), threadID);
|
||||
|
||||
wiRenderer::ComputeTiledLightCulling(false, threadID);
|
||||
|
||||
@@ -64,7 +64,7 @@ void TiledForwardRenderableComponent::RenderScene(GRAPHICSTHREAD threadID)
|
||||
wiRenderer::DrawSky(threadID);
|
||||
}
|
||||
rtMain.Deactivate(threadID);
|
||||
wiRenderer::UpdateGBuffer(rtMain.GetTextureResolvedMSAA(threadID, 0), rtMain.GetTextureResolvedMSAA(threadID, 1), nullptr, nullptr, nullptr, threadID);
|
||||
wiRenderer::BindGBufferTextures(rtMain.GetTextureResolvedMSAA(threadID, 0), rtMain.GetTextureResolvedMSAA(threadID, 1), nullptr, nullptr, nullptr, threadID);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ Luna<TiledForwardRenderableComponent_BindLua>::FunctionType TiledForwardRenderab
|
||||
lunamethod(Renderable3DComponent_BindLua, SetFXAAEnabled),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetBloomEnabled),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetColorGradingEnabled),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetColorGradingTexture),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetEmitterParticlesEnabled),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetHairParticlesEnabled),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetHairParticlesReflectionEnabled),
|
||||
@@ -58,7 +59,6 @@ Luna<TiledForwardRenderableComponent_BindLua>::FunctionType TiledForwardRenderab
|
||||
lunamethod(Renderable3DComponent_BindLua, SetDepthOfFieldFocus),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetDepthOfFieldStrength),
|
||||
|
||||
lunamethod(Renderable3DComponent_BindLua, SetPreferredThreadingCount),
|
||||
{ NULL, NULL }
|
||||
};
|
||||
Luna<TiledForwardRenderableComponent_BindLua>::PropertyType TiledForwardRenderableComponent_BindLua::properties[] = {
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#include "wiDirectInput.h"
|
||||
#include "wiXInput.h"
|
||||
#include "wiRawInput.h"
|
||||
#include "wiTaskThread.h"
|
||||
#include "wiMath.h"
|
||||
#include "wiLensFlare.h"
|
||||
#include "wiSound.h"
|
||||
|
||||
@@ -338,7 +338,6 @@
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)wiInputManager.h" />
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)wiInputManager_BindLua.h" />
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)wiLensFlare.h" />
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)wiLines.h" />
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)wiSceneComponents.h" />
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)wiSceneComponents_BindLua.h" />
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)wiLua.h" />
|
||||
@@ -366,7 +365,6 @@
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)wiSprite_BindLua.h" />
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)wiSPTree.h" />
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)wiStartupArguments.h" />
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)wiTaskThread.h" />
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)wiTextureHelper.h" />
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)wiThreadSafeManager.h" />
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)wiTimer.h" />
|
||||
@@ -683,7 +681,6 @@
|
||||
<ClCompile Include="$(MSBuildThisFileDirectory)wiInputManager_BindLua.cpp" />
|
||||
<ClCompile Include="$(MSBuildThisFileDirectory)wiIntersectables.cpp" />
|
||||
<ClCompile Include="$(MSBuildThisFileDirectory)wiLensFlare.cpp" />
|
||||
<ClCompile Include="$(MSBuildThisFileDirectory)wiLines.cpp" />
|
||||
<ClCompile Include="$(MSBuildThisFileDirectory)wiSceneComponents.cpp" />
|
||||
<ClCompile Include="$(MSBuildThisFileDirectory)wiSceneComponents_BindLua.cpp" />
|
||||
<ClCompile Include="$(MSBuildThisFileDirectory)wiLua.cpp" />
|
||||
|
||||
@@ -924,9 +924,6 @@
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)wiRandom.h">
|
||||
<Filter>ENGINE\Helpers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)wiTaskThread.h">
|
||||
<Filter>ENGINE\Helpers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)wiTimer.h">
|
||||
<Filter>ENGINE\Helpers</Filter>
|
||||
</ClInclude>
|
||||
@@ -960,9 +957,6 @@
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)wiCube.h">
|
||||
<Filter>ENGINE\Graphics</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)wiLines.h">
|
||||
<Filter>ENGINE\Graphics</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)wiLuna.h">
|
||||
<Filter>ENGINE\Scripting</Filter>
|
||||
</ClInclude>
|
||||
@@ -1832,9 +1826,6 @@
|
||||
<ClCompile Include="$(MSBuildThisFileDirectory)wiCube.cpp">
|
||||
<Filter>ENGINE\Graphics</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="$(MSBuildThisFileDirectory)wiLines.cpp">
|
||||
<Filter>ENGINE\Graphics</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="$(MSBuildThisFileDirectory)wiLua.cpp">
|
||||
<Filter>ENGINE\Scripting</Filter>
|
||||
</ClCompile>
|
||||
|
||||
+139
-121
@@ -2,6 +2,7 @@
|
||||
#include "wiSceneComponents.h"
|
||||
|
||||
|
||||
#include "btBulletDynamicsCommon.h"
|
||||
|
||||
#include "LinearMath/btHashMap.h"
|
||||
#include "BulletSoftBody/btSoftRigidDynamicsWorld.h"
|
||||
@@ -16,48 +17,63 @@ using namespace wiSceneComponents;
|
||||
|
||||
int PHYSICS::softBodyIterationCount=5;
|
||||
bool PHYSICS::rigidBodyPhysicsEnabled = true, PHYSICS::softBodyPhysicsEnabled = true;
|
||||
bool wiBULLET::grab=false;
|
||||
RAY wiBULLET::grabRay=RAY();
|
||||
|
||||
struct BulletPhysicsWorld
|
||||
{
|
||||
btCollisionConfiguration* collisionConfiguration;
|
||||
btCollisionDispatcher* dispatcher;
|
||||
btBroadphaseInterface* overlappingPairCache;
|
||||
btSequentialImpulseConstraintSolver* solver;
|
||||
btDynamicsWorld* dynamicsWorld;
|
||||
btAlignedObjectArray<btCollisionShape*> collisionShapes;
|
||||
|
||||
btSoftBodySolver* softBodySolver;
|
||||
btSoftBodySolverOutput* softBodySolverOutput;
|
||||
|
||||
btVector3 wind;
|
||||
};
|
||||
|
||||
wiBULLET::wiBULLET()
|
||||
{
|
||||
bulletPhysics = new BulletPhysicsWorld;
|
||||
|
||||
registeredObjects=-1;
|
||||
|
||||
///-----initialization_start-----
|
||||
//softBodySolver = new btDefaultSoftBodySolver();
|
||||
softBodySolver=NULL;
|
||||
bulletPhysics->softBodySolver = nullptr;
|
||||
|
||||
///collision configuration contains default setup for memory, collision setup. Advanced users can create their own configuration.
|
||||
//collisionConfiguration = new btDefaultCollisionConfiguration();
|
||||
collisionConfiguration = new btSoftBodyRigidBodyCollisionConfiguration();
|
||||
bulletPhysics->collisionConfiguration = new btSoftBodyRigidBodyCollisionConfiguration();
|
||||
|
||||
///use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded)
|
||||
dispatcher = new btCollisionDispatcher(collisionConfiguration);
|
||||
bulletPhysics->dispatcher = new btCollisionDispatcher(bulletPhysics->collisionConfiguration);
|
||||
|
||||
///btDbvtBroadphase is a good general purpose broadphase. You can also try out btAxis3Sweep.
|
||||
overlappingPairCache = new btDbvtBroadphase();
|
||||
bulletPhysics->overlappingPairCache = new btDbvtBroadphase();
|
||||
|
||||
///the default constraint solver. For parallel processing you can use a different solver (see Extras/BulletMultiThreaded)
|
||||
solver = new btSequentialImpulseConstraintSolver;
|
||||
bulletPhysics->solver = new btSequentialImpulseConstraintSolver;
|
||||
|
||||
//dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,overlappingPairCache,solver,collisionConfiguration);
|
||||
dynamicsWorld = new btSoftRigidDynamicsWorld(dispatcher,overlappingPairCache,solver,collisionConfiguration,softBodySolver);
|
||||
bulletPhysics->dynamicsWorld = new btSoftRigidDynamicsWorld(bulletPhysics->dispatcher, bulletPhysics->overlappingPairCache, bulletPhysics->solver, bulletPhysics->collisionConfiguration, bulletPhysics->softBodySolver);
|
||||
|
||||
|
||||
dynamicsWorld->getSolverInfo().m_solverMode|=SOLVER_RANDMIZE_ORDER;
|
||||
dynamicsWorld->getDispatchInfo().m_enableSatConvex = true;
|
||||
dynamicsWorld->getSolverInfo().m_splitImpulse=true;
|
||||
bulletPhysics->dynamicsWorld->getSolverInfo().m_solverMode|=SOLVER_RANDMIZE_ORDER;
|
||||
bulletPhysics->dynamicsWorld->getDispatchInfo().m_enableSatConvex = true;
|
||||
bulletPhysics->dynamicsWorld->getSolverInfo().m_splitImpulse=true;
|
||||
|
||||
dynamicsWorld->setGravity(btVector3(0,-11,0));
|
||||
((btSoftRigidDynamicsWorld*)dynamicsWorld)->getWorldInfo().air_density = (btScalar)1.0;
|
||||
((btSoftRigidDynamicsWorld*)dynamicsWorld)->getWorldInfo().water_density = 0;
|
||||
((btSoftRigidDynamicsWorld*)dynamicsWorld)->getWorldInfo().water_offset = 0;
|
||||
((btSoftRigidDynamicsWorld*)dynamicsWorld)->getWorldInfo().water_normal = btVector3(0,0,0);
|
||||
((btSoftRigidDynamicsWorld*)dynamicsWorld)->getWorldInfo().m_gravity.setValue(0,-11,0);
|
||||
((btSoftRigidDynamicsWorld*)dynamicsWorld)->getWorldInfo().m_sparsesdf.Initialize(); //???
|
||||
bulletPhysics->dynamicsWorld->setGravity(btVector3(0,-11,0));
|
||||
((btSoftRigidDynamicsWorld*)bulletPhysics->dynamicsWorld)->getWorldInfo().air_density = (btScalar)1.0;
|
||||
((btSoftRigidDynamicsWorld*)bulletPhysics->dynamicsWorld)->getWorldInfo().water_density = 0;
|
||||
((btSoftRigidDynamicsWorld*)bulletPhysics->dynamicsWorld)->getWorldInfo().water_offset = 0;
|
||||
((btSoftRigidDynamicsWorld*)bulletPhysics->dynamicsWorld)->getWorldInfo().water_normal = btVector3(0,0,0);
|
||||
((btSoftRigidDynamicsWorld*)bulletPhysics->dynamicsWorld)->getWorldInfo().m_gravity.setValue(0,-11,0);
|
||||
((btSoftRigidDynamicsWorld*)bulletPhysics->dynamicsWorld)->getWorldInfo().m_sparsesdf.Initialize(); //???
|
||||
|
||||
dynamicsWorld->setInternalTickCallback(soundTickCallback,this,true);
|
||||
dynamicsWorld->setInternalTickCallback(pickingPreTickCallback,this,true);
|
||||
//dynamicsWorld->setInternalTickCallback(soundTickCallback,this,true);
|
||||
//dynamicsWorld->setInternalTickCallback(pickingPreTickCallback,this,true);
|
||||
|
||||
|
||||
#ifdef BACKLOG
|
||||
@@ -76,29 +92,31 @@ wiBULLET::~wiBULLET()
|
||||
ClearWorld();
|
||||
|
||||
//delete dynamics world
|
||||
delete dynamicsWorld;
|
||||
delete bulletPhysics->dynamicsWorld;
|
||||
|
||||
//delete solver
|
||||
delete solver;
|
||||
delete bulletPhysics->solver;
|
||||
|
||||
//delete broadphase
|
||||
delete overlappingPairCache;
|
||||
delete bulletPhysics->overlappingPairCache;
|
||||
|
||||
//delete dispatcher
|
||||
delete dispatcher;
|
||||
delete bulletPhysics->dispatcher;
|
||||
|
||||
delete collisionConfiguration;
|
||||
delete bulletPhysics->collisionConfiguration;
|
||||
|
||||
//next line is optional: it will be cleared by the destructor when the array goes out of scope
|
||||
collisionShapes.clear();
|
||||
bulletPhysics->collisionShapes.clear();
|
||||
|
||||
///-----cleanup_end-----
|
||||
CleanUp();
|
||||
|
||||
delete bulletPhysics;
|
||||
}
|
||||
|
||||
|
||||
void wiBULLET::addWind(const XMFLOAT3& wind){
|
||||
this->wind = btVector3(btScalar(wind.x),btScalar(wind.y),btScalar(wind.z));
|
||||
this->bulletPhysics->wind = btVector3(btScalar(wind.x),btScalar(wind.y),btScalar(wind.z));
|
||||
}
|
||||
|
||||
|
||||
@@ -107,7 +125,7 @@ void wiBULLET::addBox(const XMFLOAT3& sca, const XMFLOAT4& rot, const XMFLOAT3&
|
||||
|
||||
btCollisionShape* shape = new btBoxShape(btVector3(sca.x,sca.y,sca.z));
|
||||
shape->setMargin(btScalar(0.05));
|
||||
collisionShapes.push_back(shape);
|
||||
bulletPhysics->collisionShapes.push_back(shape);
|
||||
|
||||
btTransform shapeTransform;
|
||||
shapeTransform.setIdentity();
|
||||
@@ -137,7 +155,7 @@ void wiBULLET::addBox(const XMFLOAT3& sca, const XMFLOAT4& rot, const XMFLOAT3&
|
||||
body->setActivationState(DISABLE_DEACTIVATION);
|
||||
|
||||
//add the body to the dynamics world
|
||||
dynamicsWorld->addRigidBody(body);
|
||||
bulletPhysics->dynamicsWorld->addRigidBody(body);
|
||||
|
||||
|
||||
if (body->getMotionState())
|
||||
@@ -218,7 +236,7 @@ void wiBULLET::addSphere(float rad, const XMFLOAT3& pos
|
||||
|
||||
btCollisionShape* shape = new btSphereShape(btScalar(rad));
|
||||
shape->setMargin(btScalar(0.05));
|
||||
collisionShapes.push_back(shape);
|
||||
bulletPhysics->collisionShapes.push_back(shape);
|
||||
|
||||
btTransform shapeTransform;
|
||||
shapeTransform.setIdentity();
|
||||
@@ -247,7 +265,7 @@ void wiBULLET::addSphere(float rad, const XMFLOAT3& pos
|
||||
body->setActivationState(DISABLE_DEACTIVATION);
|
||||
|
||||
//add the body to the dynamics world
|
||||
dynamicsWorld->addRigidBody(body);
|
||||
bulletPhysics->dynamicsWorld->addRigidBody(body);
|
||||
|
||||
|
||||
if (body->getMotionState())
|
||||
@@ -270,7 +288,7 @@ void wiBULLET::addCapsule(float rad, float hei, const XMFLOAT4& rot, const XMFLO
|
||||
|
||||
btCollisionShape* shape = new btCapsuleShape(btScalar(rad),btScalar(hei));
|
||||
shape->setMargin(btScalar(0.05));
|
||||
collisionShapes.push_back(shape);
|
||||
bulletPhysics->collisionShapes.push_back(shape);
|
||||
|
||||
btTransform shapeTransform;
|
||||
shapeTransform.setIdentity();
|
||||
@@ -300,7 +318,7 @@ void wiBULLET::addCapsule(float rad, float hei, const XMFLOAT4& rot, const XMFLO
|
||||
body->setActivationState(DISABLE_DEACTIVATION);
|
||||
|
||||
//add the body to the dynamics world
|
||||
dynamicsWorld->addRigidBody(body);
|
||||
bulletPhysics->dynamicsWorld->addRigidBody(body);
|
||||
|
||||
|
||||
if (body->getMotionState())
|
||||
@@ -326,7 +344,7 @@ void wiBULLET::addConvexHull(const std::vector<XMFLOAT4>& vertices, const XMFLOA
|
||||
shape->setLocalScaling(btVector3(sca.x,sca.y,sca.z));
|
||||
shape->setMargin(btScalar(0.05));
|
||||
|
||||
collisionShapes.push_back(shape);
|
||||
bulletPhysics->collisionShapes.push_back(shape);
|
||||
|
||||
btTransform shapeTransform;
|
||||
shapeTransform.setIdentity();
|
||||
@@ -358,7 +376,7 @@ void wiBULLET::addConvexHull(const std::vector<XMFLOAT4>& vertices, const XMFLOA
|
||||
body->setActivationState(DISABLE_DEACTIVATION);
|
||||
|
||||
//add the body to the dynamics world
|
||||
dynamicsWorld->addRigidBody(body);
|
||||
bulletPhysics->dynamicsWorld->addRigidBody(body);
|
||||
|
||||
|
||||
if (body->getMotionState())
|
||||
@@ -408,7 +426,7 @@ void wiBULLET::addTriangleMesh(const std::vector<XMFLOAT4>& vertices, const std:
|
||||
shape->setMargin(btScalar(0.05));
|
||||
shape->setLocalScaling(btVector3(sca.x,sca.y,sca.z));
|
||||
|
||||
collisionShapes.push_back(shape);
|
||||
bulletPhysics->collisionShapes.push_back(shape);
|
||||
|
||||
btTransform shapeTransform;
|
||||
shapeTransform.setIdentity();
|
||||
@@ -438,7 +456,7 @@ void wiBULLET::addTriangleMesh(const std::vector<XMFLOAT4>& vertices, const std:
|
||||
body->setActivationState( DISABLE_DEACTIVATION );
|
||||
|
||||
//add the body to the dynamics world
|
||||
dynamicsWorld->addRigidBody(body);
|
||||
bulletPhysics->dynamicsWorld->addRigidBody(body);
|
||||
|
||||
|
||||
if (body->getMotionState())
|
||||
@@ -477,7 +495,7 @@ void wiBULLET::addSoftBodyTriangleMesh(const Mesh* mesh, const XMFLOAT3& sca, co
|
||||
|
||||
|
||||
btSoftBody* softBody = btSoftBodyHelpers::CreateFromTriMesh(
|
||||
((btSoftRigidDynamicsWorld*)dynamicsWorld)->getWorldInfo()
|
||||
((btSoftRigidDynamicsWorld*)bulletPhysics->dynamicsWorld)->getWorldInfo()
|
||||
,&btVerts[0]
|
||||
,&btInd[0]
|
||||
,tCount
|
||||
@@ -556,13 +574,13 @@ void wiBULLET::addSoftBodyTriangleMesh(const Mesh* mesh, const XMFLOAT3& sca, co
|
||||
|
||||
softBody->getCollisionShape()->setMargin(btScalar(0.2));
|
||||
|
||||
softBody->setWindVelocity(wind);
|
||||
softBody->setWindVelocity(bulletPhysics->wind);
|
||||
|
||||
softBody->setPose(true,true);
|
||||
|
||||
softBody->setActivationState(DISABLE_DEACTIVATION);
|
||||
|
||||
((btSoftRigidDynamicsWorld*)dynamicsWorld)->addSoftBody(softBody);
|
||||
((btSoftRigidDynamicsWorld*)bulletPhysics->dynamicsWorld)->addSoftBody(softBody);
|
||||
|
||||
transforms.push_back(new PhysicsTransform);
|
||||
}
|
||||
@@ -574,7 +592,7 @@ void wiBULLET::connectVerticesToSoftBody(Mesh* const mesh, int objectI){
|
||||
if (!softBodyPhysicsEnabled)
|
||||
return;
|
||||
|
||||
btCollisionObject* obj = dynamicsWorld->getCollisionObjectArray()[objectI];
|
||||
btCollisionObject* obj = bulletPhysics->dynamicsWorld->getCollisionObjectArray()[objectI];
|
||||
btSoftBody* softBody = btSoftBody::upcast(obj);
|
||||
|
||||
|
||||
@@ -583,7 +601,7 @@ void wiBULLET::connectVerticesToSoftBody(Mesh* const mesh, int objectI){
|
||||
softBody->getAabb(min, max);
|
||||
mesh->aabb.create(XMFLOAT3(min.x(), min.y(), min.z()), XMFLOAT3(max.x(), max.y(), max.z()));
|
||||
|
||||
softBody->setWindVelocity(wind);
|
||||
softBody->setWindVelocity(bulletPhysics->wind);
|
||||
|
||||
btSoftBody::tNodeArray& nodes(softBody->m_nodes);
|
||||
|
||||
@@ -608,7 +626,7 @@ void wiBULLET::connectSoftBodyToVertices(const Mesh* const mesh, int objectI){
|
||||
return;
|
||||
|
||||
if(!firstRunWorld){
|
||||
btCollisionObject* obj = dynamicsWorld->getCollisionObjectArray()[objectI];
|
||||
btCollisionObject* obj = bulletPhysics->dynamicsWorld->getCollisionObjectArray()[objectI];
|
||||
btSoftBody* softBody = btSoftBody::upcast(obj);
|
||||
|
||||
if(softBody){
|
||||
@@ -634,7 +652,7 @@ void wiBULLET::transformBody(const XMFLOAT4& rot, const XMFLOAT3& pos, int objec
|
||||
return;
|
||||
}
|
||||
|
||||
btCollisionObject* obj = dynamicsWorld->getCollisionObjectArray()[objectI];
|
||||
btCollisionObject* obj = bulletPhysics->dynamicsWorld->getCollisionObjectArray()[objectI];
|
||||
btRigidBody* rigidBody = btRigidBody::upcast(obj);
|
||||
if(rigidBody){
|
||||
btTransform transform;
|
||||
@@ -647,7 +665,7 @@ void wiBULLET::transformBody(const XMFLOAT4& rot, const XMFLOAT3& pos, int objec
|
||||
|
||||
PHYSICS::PhysicsTransform* wiBULLET::getObject(int index){
|
||||
|
||||
btCollisionObject* obj = dynamicsWorld->getCollisionObjectArray()[index];
|
||||
btCollisionObject* obj = bulletPhysics->dynamicsWorld->getCollisionObjectArray()[index];
|
||||
btTransform trans;
|
||||
|
||||
btRigidBody* body = btRigidBody::upcast(obj);
|
||||
@@ -776,7 +794,7 @@ void wiBULLET::removeObject(Object* object)
|
||||
|
||||
void wiBULLET::Update(float dt){
|
||||
if (rigidBodyPhysicsEnabled || softBodyPhysicsEnabled)
|
||||
dynamicsWorld->stepSimulation(dt, 6);
|
||||
bulletPhysics->dynamicsWorld->stepSimulation(dt, 6);
|
||||
}
|
||||
void wiBULLET::MarkForRead(){
|
||||
|
||||
@@ -791,16 +809,16 @@ void wiBULLET::UnMarkForWrite(){
|
||||
|
||||
}
|
||||
void wiBULLET::ClearWorld(){
|
||||
for(int i=dynamicsWorld->getNumCollisionObjects()-1;i>=0;i--)
|
||||
for(int i= bulletPhysics->dynamicsWorld->getNumCollisionObjects()-1;i>=0;i--)
|
||||
{
|
||||
deleteObject(i);
|
||||
}
|
||||
|
||||
//delete collision shapes
|
||||
for (int j=0;j<collisionShapes.size();j++)
|
||||
for (int j=0;j<bulletPhysics->collisionShapes.size();j++)
|
||||
{
|
||||
btCollisionShape* shape = collisionShapes[j];
|
||||
collisionShapes[j] = 0;
|
||||
btCollisionShape* shape = bulletPhysics->collisionShapes[j];
|
||||
bulletPhysics->collisionShapes[j] = 0;
|
||||
delete shape;
|
||||
}
|
||||
|
||||
@@ -818,101 +836,101 @@ void wiBULLET::CleanUp(){
|
||||
|
||||
void wiBULLET::deleteObject(int id)
|
||||
{
|
||||
btCollisionObject* obj = dynamicsWorld->getCollisionObjectArray()[id];
|
||||
btCollisionObject* obj = bulletPhysics->dynamicsWorld->getCollisionObjectArray()[id];
|
||||
btRigidBody* body = btRigidBody::upcast(obj);
|
||||
|
||||
if (body && body->getMotionState())
|
||||
{
|
||||
delete body->getMotionState();
|
||||
}
|
||||
while (dynamicsWorld->getNumConstraints())
|
||||
while (bulletPhysics->dynamicsWorld->getNumConstraints())
|
||||
{
|
||||
btTypedConstraint* pc = dynamicsWorld->getConstraint(0);
|
||||
dynamicsWorld->removeConstraint(pc);
|
||||
btTypedConstraint* pc = bulletPhysics->dynamicsWorld->getConstraint(0);
|
||||
bulletPhysics->dynamicsWorld->removeConstraint(pc);
|
||||
delete pc;
|
||||
}
|
||||
|
||||
btSoftBody* softBody = btSoftBody::upcast(obj);
|
||||
if (softBody)
|
||||
{
|
||||
((btSoftRigidDynamicsWorld*)dynamicsWorld)->removeSoftBody(softBody);
|
||||
((btSoftRigidDynamicsWorld*)bulletPhysics->dynamicsWorld)->removeSoftBody(softBody);
|
||||
}
|
||||
else
|
||||
{
|
||||
btRigidBody* body = btRigidBody::upcast(obj);
|
||||
if (body)
|
||||
dynamicsWorld->removeRigidBody(body);
|
||||
bulletPhysics->dynamicsWorld->removeRigidBody(body);
|
||||
else
|
||||
dynamicsWorld->removeCollisionObject(obj);
|
||||
bulletPhysics->dynamicsWorld->removeCollisionObject(obj);
|
||||
}
|
||||
delete obj;
|
||||
|
||||
registeredObjects--;
|
||||
}
|
||||
|
||||
|
||||
void wiBULLET::soundTickCallback(btDynamicsWorld *world, btScalar timeStep) {
|
||||
int numManifolds = world->getDispatcher()->getNumManifolds();
|
||||
for (int i=0;i<numManifolds;i++)
|
||||
{
|
||||
|
||||
btPersistentManifold* contactManifold = world->getDispatcher()->getManifoldByIndexInternal(i);
|
||||
btCollisionObject* obA = (btCollisionObject*)(contactManifold->getBody0());
|
||||
btCollisionObject* obB = (btCollisionObject*)(contactManifold->getBody1());
|
||||
|
||||
int numContacts = contactManifold->getNumContacts();
|
||||
for (int j=0;j<numContacts;j++)
|
||||
{
|
||||
btManifoldPoint& pt = contactManifold->getContactPoint(j);
|
||||
if (pt.getDistance()<0.f)
|
||||
{
|
||||
if(pt.getAppliedImpulse()>10.f){
|
||||
//TODO: play some sound
|
||||
}
|
||||
const btVector3& ptA = pt.getPositionWorldOnA();
|
||||
const btVector3& ptB = pt.getPositionWorldOnB();
|
||||
const btVector3& normalOnB = pt.m_normalWorldOnB;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void wiBULLET::pickingPreTickCallback (btDynamicsWorld *world, btScalar timeStep)
|
||||
{
|
||||
// world->getWorldUserInfo();
|
||||
//
|
||||
// if(grab)
|
||||
// {
|
||||
// /*const int x=softDemo->m_lastmousepos[0];
|
||||
// const int y=softDemo->m_lastmousepos[1];
|
||||
// const btVector3 rayFrom=softDemo->getCameraPosition();
|
||||
// const btVector3 rayTo=softDemo->getRayTo(x,y);
|
||||
// const btVector3 rayDir=(rayTo-rayFrom).normalized();
|
||||
// const btVector3 N=(softDemo->getCameraTargetPosition()-softDemo->getCameraPosition()).normalized();
|
||||
// const btScalar O=btDot(softDemo->m_impact,N);*/
|
||||
// const btVector3 rayFrom=btVector3(grabRay.origin.x,grabRay.origin.y,grabRay.origin.z);
|
||||
// const btVector3 rayDir=btVector3(grabRay.direction.x,grabRay.direction.y,grabRay.direction.z);
|
||||
// //const btScalar den=btDot(N,rayDir);
|
||||
// //if((den*den)>0)
|
||||
///* {
|
||||
// const btScalar num=O-btDot(N,rayFrom);
|
||||
// const btScalar hit=num/den;
|
||||
// if((hit>0)&&(hit<1500))
|
||||
// {
|
||||
// softDemo->m_goal=rayFrom+rayDir*hit;
|
||||
// }
|
||||
// }*/
|
||||
// btVector3 delta=softDemo->m_goal-softDemo->m_node->m_x;
|
||||
// static const btScalar maxdrag=10;
|
||||
// if(delta.length2()>(maxdrag*maxdrag))
|
||||
// {
|
||||
// delta=delta.normalized()*maxdrag;
|
||||
// }
|
||||
// softDemo->m_node->m_v+=delta/timeStep;
|
||||
// }
|
||||
//void wiBULLET::soundTickCallback(btDynamicsWorld *world, btScalar timeStep) {
|
||||
// int numManifolds = world->getDispatcher()->getNumManifolds();
|
||||
// for (int i=0;i<numManifolds;i++)
|
||||
// {
|
||||
//
|
||||
}
|
||||
void wiBULLET::setGrab(bool value, const RAY& ray){
|
||||
grab=value;
|
||||
grabRay=ray;
|
||||
}
|
||||
// btPersistentManifold* contactManifold = world->getDispatcher()->getManifoldByIndexInternal(i);
|
||||
// btCollisionObject* obA = (btCollisionObject*)(contactManifold->getBody0());
|
||||
// btCollisionObject* obB = (btCollisionObject*)(contactManifold->getBody1());
|
||||
//
|
||||
// int numContacts = contactManifold->getNumContacts();
|
||||
// for (int j=0;j<numContacts;j++)
|
||||
// {
|
||||
// btManifoldPoint& pt = contactManifold->getContactPoint(j);
|
||||
// if (pt.getDistance()<0.f)
|
||||
// {
|
||||
// if(pt.getAppliedImpulse()>10.f){
|
||||
// //TODO: play some sound
|
||||
// }
|
||||
// const btVector3& ptA = pt.getPositionWorldOnA();
|
||||
// const btVector3& ptB = pt.getPositionWorldOnB();
|
||||
// const btVector3& normalOnB = pt.m_normalWorldOnB;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//void wiBULLET::pickingPreTickCallback (btDynamicsWorld *world, btScalar timeStep)
|
||||
//{
|
||||
//// world->getWorldUserInfo();
|
||||
////
|
||||
//// if(grab)
|
||||
//// {
|
||||
//// /*const int x=softDemo->m_lastmousepos[0];
|
||||
//// const int y=softDemo->m_lastmousepos[1];
|
||||
//// const btVector3 rayFrom=softDemo->getCameraPosition();
|
||||
//// const btVector3 rayTo=softDemo->getRayTo(x,y);
|
||||
//// const btVector3 rayDir=(rayTo-rayFrom).normalized();
|
||||
//// const btVector3 N=(softDemo->getCameraTargetPosition()-softDemo->getCameraPosition()).normalized();
|
||||
//// const btScalar O=btDot(softDemo->m_impact,N);*/
|
||||
//// const btVector3 rayFrom=btVector3(grabRay.origin.x,grabRay.origin.y,grabRay.origin.z);
|
||||
//// const btVector3 rayDir=btVector3(grabRay.direction.x,grabRay.direction.y,grabRay.direction.z);
|
||||
//// //const btScalar den=btDot(N,rayDir);
|
||||
//// //if((den*den)>0)
|
||||
/////* {
|
||||
//// const btScalar num=O-btDot(N,rayFrom);
|
||||
//// const btScalar hit=num/den;
|
||||
//// if((hit>0)&&(hit<1500))
|
||||
//// {
|
||||
//// softDemo->m_goal=rayFrom+rayDir*hit;
|
||||
//// }
|
||||
//// }*/
|
||||
//// btVector3 delta=softDemo->m_goal-softDemo->m_node->m_x;
|
||||
//// static const btScalar maxdrag=10;
|
||||
//// if(delta.length2()>(maxdrag*maxdrag))
|
||||
//// {
|
||||
//// delta=delta.normalized()*maxdrag;
|
||||
//// }
|
||||
//// softDemo->m_node->m_v+=delta/timeStep;
|
||||
//// }
|
||||
////
|
||||
//}
|
||||
//void wiBULLET::setGrab(bool value, const RAY& ray){
|
||||
// grab=value;
|
||||
// grabRay=ray;
|
||||
//}
|
||||
|
||||
+2
-29
@@ -1,36 +1,14 @@
|
||||
#pragma once
|
||||
#include "wiPHYSICS.h"
|
||||
|
||||
#include "BULLET/btBulletDynamicsCommon.h"
|
||||
|
||||
class btCollisionConfiguration;
|
||||
class btCollisionDispatcher;
|
||||
class btBroadphaseInterface;
|
||||
class btSequentialImpulseConstraintSolver;
|
||||
class btDynamicsWorld;
|
||||
class btCollisionShape;
|
||||
class btSoftBodySolver;
|
||||
class btSoftBodySolverOutput;
|
||||
struct BulletPhysicsWorld;
|
||||
|
||||
struct RAY;
|
||||
|
||||
class wiBULLET:public PHYSICS
|
||||
{
|
||||
private:
|
||||
btCollisionConfiguration* collisionConfiguration;
|
||||
btCollisionDispatcher* dispatcher;
|
||||
btBroadphaseInterface* overlappingPairCache;
|
||||
btSequentialImpulseConstraintSolver* solver;
|
||||
btDynamicsWorld* dynamicsWorld;
|
||||
btAlignedObjectArray<btCollisionShape*> collisionShapes;
|
||||
|
||||
btSoftBodySolver* softBodySolver;
|
||||
btSoftBodySolverOutput* softBodySolverOutput;
|
||||
|
||||
btVector3 wind;
|
||||
|
||||
static bool grab;
|
||||
static RAY grabRay;
|
||||
BulletPhysicsWorld * bulletPhysics = nullptr;
|
||||
|
||||
void deleteObject(int id);
|
||||
public:
|
||||
@@ -72,10 +50,5 @@ public:
|
||||
void ClearWorld();
|
||||
void CleanUp();
|
||||
|
||||
void setGrab(bool val, const RAY& ray);
|
||||
static void pickingPreTickCallback (btDynamicsWorld *world, btScalar timeStep);
|
||||
static void soundTickCallback(btDynamicsWorld *world, btScalar timeStep);
|
||||
|
||||
ALIGN_16
|
||||
};
|
||||
|
||||
|
||||
@@ -19,27 +19,6 @@ enum RENDERTYPE
|
||||
RENDERTYPE_OPAQUE = 1,
|
||||
RENDERTYPE_TRANSPARENT = 2,
|
||||
RENDERTYPE_WATER = 4,
|
||||
RENDERTYPE_LIGHT = 8,
|
||||
RENDERTYPE_DECAL = 16,
|
||||
RENDERTYPE_ENVPROBE = 32,
|
||||
RENDERTYPE_FORCEFIELD = 64,
|
||||
RENDERTYPE_EMITTER = 128,
|
||||
RENDERTYPE_CAMERA = 256,
|
||||
RENDERTYPE_ARMATURE = 512,
|
||||
};
|
||||
enum PICKTYPE
|
||||
{
|
||||
PICK_VOID = RENDERTYPE_VOID,
|
||||
PICK_OPAQUE = RENDERTYPE_OPAQUE,
|
||||
PICK_TRANSPARENT = RENDERTYPE_TRANSPARENT,
|
||||
PICK_WATER = RENDERTYPE_WATER,
|
||||
PICK_LIGHT = RENDERTYPE_LIGHT,
|
||||
PICK_DECAL = RENDERTYPE_DECAL,
|
||||
PICK_ENVPROBE = RENDERTYPE_ENVPROBE,
|
||||
PICK_FORCEFIELD = RENDERTYPE_FORCEFIELD,
|
||||
PICK_EMITTER = RENDERTYPE_EMITTER,
|
||||
PICK_CAMERA = RENDERTYPE_CAMERA,
|
||||
PICK_ARMATURE = RENDERTYPE_ARMATURE,
|
||||
};
|
||||
|
||||
enum SHADERTYPE
|
||||
|
||||
+23
-22
@@ -69,12 +69,12 @@ void Frustum::ConstructFrustum(float screenDepth, XMFLOAT4X4 projectionMatrix, c
|
||||
|
||||
}
|
||||
|
||||
bool Frustum::CheckPoint(const XMFLOAT3& point)
|
||||
bool Frustum::CheckPoint(const XMFLOAT3& point) const
|
||||
{
|
||||
XMVECTOR p = XMLoadFloat3(&point);
|
||||
for(short i=0; i<6; i++)
|
||||
for (short i = 0; i < 6; i++)
|
||||
{
|
||||
if(XMVectorGetX( XMPlaneDotCoord(XMLoadFloat4(&m_planesNorm[i]), p) ) < 0.0f)
|
||||
if (XMVectorGetX(XMPlaneDotCoord(XMLoadFloat4(&m_planesNorm[i]), p)) < 0.0f)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -82,13 +82,13 @@ bool Frustum::CheckPoint(const XMFLOAT3& point)
|
||||
|
||||
return true;
|
||||
}
|
||||
bool Frustum::CheckSphere(const XMFLOAT3& center, float radius)
|
||||
bool Frustum::CheckSphere(const XMFLOAT3& center, float radius) const
|
||||
{
|
||||
int i;
|
||||
XMVECTOR c = XMLoadFloat3(¢er);
|
||||
for(i=0; i<6; i++)
|
||||
for (i = 0; i < 6; i++)
|
||||
{
|
||||
if(XMVectorGetX( XMPlaneDotCoord(XMLoadFloat4(&m_planesNorm[i]), c) ) < -radius)
|
||||
if (XMVectorGetX(XMPlaneDotCoord(XMLoadFloat4(&m_planesNorm[i]), c)) < -radius)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -96,37 +96,38 @@ bool Frustum::CheckSphere(const XMFLOAT3& center, float radius)
|
||||
|
||||
return true;
|
||||
}
|
||||
int Frustum::CheckBox(const AABB& box)
|
||||
int Frustum::CheckBox(const AABB& box) const
|
||||
{
|
||||
int iTotalIn = 0;
|
||||
for(int p = 0; p < 6; ++p)
|
||||
for (int p = 0; p < 6; ++p)
|
||||
{
|
||||
|
||||
|
||||
int iInCount = 8;
|
||||
int iPtIn = 1;
|
||||
|
||||
for(int i = 0; i < 8; ++i) {
|
||||
if(XMVectorGetX( XMPlaneDotCoord(XMLoadFloat4(&m_planesNorm[p]), XMLoadFloat3(&box.corners[i])) ) < 0.0f)
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
if (XMVectorGetX(XMPlaneDotCoord(XMLoadFloat4(&m_planesNorm[p]), XMLoadFloat3(&box.corners[i]))) < 0.0f)
|
||||
{
|
||||
iPtIn=0;
|
||||
iPtIn = 0;
|
||||
--iInCount;
|
||||
}
|
||||
}
|
||||
if(iInCount == 0)
|
||||
if (iInCount == 0)
|
||||
return(false);
|
||||
iTotalIn += iPtIn;
|
||||
}
|
||||
if(iTotalIn == 6)
|
||||
if (iTotalIn == 6)
|
||||
return(BOX_FRUSTUM_INSIDE);
|
||||
return(BOX_FRUSTUM_INTERSECTS);
|
||||
}
|
||||
|
||||
const XMFLOAT4& Frustum::getLeftPlane() { return m_planesNorm[2]; }
|
||||
const XMFLOAT4& Frustum::getRightPlane() { return m_planesNorm[3]; }
|
||||
const XMFLOAT4& Frustum::getTopPlane() { return m_planesNorm[4]; }
|
||||
const XMFLOAT4& Frustum::getBottomPlane() { return m_planesNorm[5]; }
|
||||
const XMFLOAT4& Frustum::getFarPlane(){return m_planesNorm[1];}
|
||||
const XMFLOAT4& Frustum::getNearPlane(){return m_planesNorm[0];}
|
||||
XMFLOAT3 Frustum::getCamPos(){
|
||||
return XMFLOAT3(-view._41,-view._42,-view._43);
|
||||
const XMFLOAT4& Frustum::getLeftPlane() const { return m_planesNorm[2]; }
|
||||
const XMFLOAT4& Frustum::getRightPlane() const { return m_planesNorm[3]; }
|
||||
const XMFLOAT4& Frustum::getTopPlane() const { return m_planesNorm[4]; }
|
||||
const XMFLOAT4& Frustum::getBottomPlane() const { return m_planesNorm[5]; }
|
||||
const XMFLOAT4& Frustum::getFarPlane() const { return m_planesNorm[1]; }
|
||||
const XMFLOAT4& Frustum::getNearPlane() const { return m_planesNorm[0]; }
|
||||
XMFLOAT3 Frustum::getCamPos() const
|
||||
{
|
||||
return XMFLOAT3(-view._41, -view._42, -view._43);
|
||||
}
|
||||
|
||||
+10
-10
@@ -15,19 +15,19 @@ public:
|
||||
|
||||
void ConstructFrustum(float screenDepth, XMFLOAT4X4 projectionMatrix, const XMFLOAT4X4& viewMatrix, const XMMATRIX& world = XMMatrixIdentity());
|
||||
|
||||
bool CheckPoint(const XMFLOAT3&);
|
||||
bool CheckSphere(const XMFLOAT3&, float);
|
||||
bool CheckPoint(const XMFLOAT3&) const;
|
||||
bool CheckSphere(const XMFLOAT3&, float) const;
|
||||
|
||||
#define BOX_FRUSTUM_INTERSECTS 1
|
||||
#define BOX_FRUSTUM_INSIDE 2
|
||||
int CheckBox(const AABB& box);
|
||||
int CheckBox(const AABB& box) const;
|
||||
|
||||
const XMFLOAT4& getLeftPlane();
|
||||
const XMFLOAT4& getRightPlane();
|
||||
const XMFLOAT4& getTopPlane();
|
||||
const XMFLOAT4& getBottomPlane();
|
||||
const XMFLOAT4& getFarPlane();
|
||||
const XMFLOAT4& getNearPlane();
|
||||
XMFLOAT3 getCamPos();
|
||||
const XMFLOAT4& getLeftPlane() const;
|
||||
const XMFLOAT4& getRightPlane() const;
|
||||
const XMFLOAT4& getTopPlane() const;
|
||||
const XMFLOAT4& getBottomPlane() const;
|
||||
const XMFLOAT4& getFarPlane() const;
|
||||
const XMFLOAT4& getNearPlane() const;
|
||||
XMFLOAT3 getCamPos() const;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,126 +0,0 @@
|
||||
#include "wiLines.h"
|
||||
#include "wiRenderer.h"
|
||||
|
||||
using namespace wiGraphicsTypes;
|
||||
|
||||
Lines::Lines()
|
||||
{
|
||||
desc = Description();
|
||||
desc.length=1;
|
||||
parentArmature=0;
|
||||
parentBone=0;
|
||||
SetUpVertices();
|
||||
}
|
||||
|
||||
Lines::Lines(float newLen, const XMFLOAT4& newColor, int newParentArmature, int newParentBone)
|
||||
{
|
||||
desc = Description();
|
||||
desc.length = newLen;
|
||||
desc.color = newColor;
|
||||
parentArmature = newParentArmature;
|
||||
parentBone = newParentBone;
|
||||
SetUpVertices();
|
||||
}
|
||||
|
||||
Lines::Lines(const XMFLOAT3& a, const XMFLOAT3& b, const XMFLOAT4& c)
|
||||
{
|
||||
desc = Description();
|
||||
desc.length = 0;
|
||||
desc.color = c;
|
||||
parentArmature = 0;
|
||||
parentBone = 0;
|
||||
|
||||
//Vertex* verts = new Vertex[2];
|
||||
|
||||
//verts[0].pos = XMFLOAT3(a.x,a.y,a.z);
|
||||
//verts[1].pos = XMFLOAT3(b.x,b.y,b.z);
|
||||
|
||||
XMFLOAT4 verts[] = {
|
||||
XMFLOAT4(a.x,a.y,a.z,1), XMFLOAT4(1,1,1,1),
|
||||
XMFLOAT4(b.x,b.y,b.z,1), XMFLOAT4(1,1,1,1),
|
||||
};
|
||||
|
||||
GPUBufferDesc bd;
|
||||
ZeroMemory( &bd, sizeof(bd) );
|
||||
bd.Usage = USAGE_DEFAULT;
|
||||
bd.ByteWidth = sizeof(verts);
|
||||
bd.BindFlags = BIND_VERTEX_BUFFER;
|
||||
bd.CPUAccessFlags = 0;
|
||||
SubresourceData InitData;
|
||||
ZeroMemory( &InitData, sizeof(InitData) );
|
||||
InitData.pSysMem = verts;
|
||||
wiRenderer::GetDevice()->CreateBuffer( &bd, &InitData, &vertexBuffer );
|
||||
|
||||
//if(verts){
|
||||
// delete[](verts);
|
||||
// verts=NULL;
|
||||
//}
|
||||
}
|
||||
Lines::~Lines()
|
||||
{
|
||||
CleanUp();
|
||||
}
|
||||
|
||||
void Lines::CleanUp()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Lines::SetUpVertices()
|
||||
{
|
||||
//Vertex* verts = new Vertex[2];
|
||||
|
||||
//verts[0].pos = XMFLOAT3(0,0,0);
|
||||
//verts[1].pos = XMFLOAT3(0,0,desc.length);
|
||||
|
||||
//GPUBufferDesc bd;
|
||||
//ZeroMemory( &bd, sizeof(bd) );
|
||||
//bd.Usage = USAGE_DEFAULT;
|
||||
//bd.ByteWidth = sizeof( Vertex ) * 2;
|
||||
//bd.BindFlags = BIND_VERTEX_BUFFER;
|
||||
//bd.CPUAccessFlags = 0;
|
||||
//SubresourceData InitData;
|
||||
//ZeroMemory( &InitData, sizeof(InitData) );
|
||||
//InitData.pSysMem = verts;
|
||||
//wiRenderer::GetDevice()->CreateBuffer( &bd, &InitData, &vertexBuffer );
|
||||
|
||||
//if(verts){
|
||||
// delete[](verts);
|
||||
// verts=NULL;
|
||||
//}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//Vertex* verts = new Vertex[2];
|
||||
|
||||
//verts[0].pos = XMFLOAT3(a.x,a.y,a.z);
|
||||
//verts[1].pos = XMFLOAT3(b.x,b.y,b.z);
|
||||
|
||||
XMFLOAT4 verts[] = {
|
||||
XMFLOAT4(0,0,0,1), XMFLOAT4(1,1,1,1),
|
||||
XMFLOAT4(0,0,desc.length,1), XMFLOAT4(1,1,1,1),
|
||||
};
|
||||
|
||||
GPUBufferDesc bd;
|
||||
ZeroMemory(&bd, sizeof(bd));
|
||||
bd.Usage = USAGE_DEFAULT;
|
||||
bd.ByteWidth = sizeof(verts);
|
||||
bd.BindFlags = BIND_VERTEX_BUFFER;
|
||||
bd.CPUAccessFlags = 0;
|
||||
SubresourceData InitData;
|
||||
ZeroMemory(&InitData, sizeof(InitData));
|
||||
InitData.pSysMem = verts;
|
||||
wiRenderer::GetDevice()->CreateBuffer(&bd, &InitData, &vertexBuffer);
|
||||
|
||||
//if(verts){
|
||||
// delete[](verts);
|
||||
// verts=NULL;
|
||||
//}
|
||||
}
|
||||
|
||||
void Lines::Transform(const XMFLOAT4X4& mat)
|
||||
{
|
||||
desc.transform=mat;
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
#pragma once
|
||||
#include "CommonInclude.h"
|
||||
#include "wiGraphicsAPI.h"
|
||||
|
||||
class Lines
|
||||
{
|
||||
private:
|
||||
struct Description{
|
||||
XMFLOAT4X4 transform;
|
||||
float length;
|
||||
XMFLOAT4 color;
|
||||
|
||||
Description(){
|
||||
length=0;
|
||||
color=XMFLOAT4(1,1,1,1);
|
||||
transform=XMFLOAT4X4(
|
||||
1,0,0,0,
|
||||
0,1,0,0,
|
||||
0,0,1,0,
|
||||
0,0,0,1
|
||||
);
|
||||
};
|
||||
};
|
||||
void SetUpVertices();
|
||||
public:
|
||||
Lines();
|
||||
Lines(float newLen, const XMFLOAT4& newColor, int newParentArmature, int newParentBone);
|
||||
Lines(const XMFLOAT3& a, const XMFLOAT3& b, const XMFLOAT4& c);
|
||||
~Lines();
|
||||
void CleanUp();
|
||||
void Transform(const XMFLOAT4X4& mat);
|
||||
|
||||
Description desc;
|
||||
int parentArmature,parentBone;
|
||||
|
||||
wiGraphicsTypes::GPUBuffer vertexBuffer;
|
||||
|
||||
ALIGN_16
|
||||
};
|
||||
|
||||
+465
-788
File diff suppressed because it is too large
Load Diff
+27
-114
@@ -253,30 +253,18 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
static void SetUpBoneLines();
|
||||
static void UpdateBoneLines();
|
||||
static void SetUpCubes();
|
||||
static void UpdateCubes();
|
||||
|
||||
|
||||
|
||||
static bool wireRender, debugSpheres, debugBoneLines, debugPartitionTree, debugEnvProbes, debugEmitters, debugForceFields, debugCameras, gridHelper, voxelHelper, advancedLightCulling, advancedRefractions;
|
||||
static bool ldsSkinningEnabled;
|
||||
static bool requestReflectionRendering;
|
||||
|
||||
|
||||
static wiGraphicsTypes::Texture2D* enviroMap,*colorGrading;
|
||||
static wiGraphicsTypes::Texture2D* enviroMap;
|
||||
static void LoadBuffers();
|
||||
static void LoadShaders();
|
||||
static void SetUpStates();
|
||||
static int vertexCount;
|
||||
static int visibleCount;
|
||||
|
||||
|
||||
static void addVertexCount(const int& toadd){vertexCount+=toadd;}
|
||||
|
||||
|
||||
static float GameSpeed, overrideGameSpeed;
|
||||
static float GameSpeed;
|
||||
|
||||
static wiSceneComponents::Scene* scene;
|
||||
|
||||
@@ -316,8 +304,6 @@ protected:
|
||||
public:
|
||||
static std::string SHADERPATH;
|
||||
|
||||
wiRenderer();
|
||||
void CleanUp();
|
||||
static void SetUpStaticComponents();
|
||||
static void CleanUpStatic();
|
||||
|
||||
@@ -327,8 +313,6 @@ public:
|
||||
static void UpdateRenderData(GRAPHICSTHREAD threadID);
|
||||
static void OcclusionCulling_Render(GRAPHICSTHREAD threadID);
|
||||
static void OcclusionCulling_Read();
|
||||
static void UpdateImages();
|
||||
static void ManageImages();
|
||||
static void PutDecal(wiSceneComponents::Decal* decal);
|
||||
static void PutWaterRipple(const std::string& image, const XMFLOAT3& pos);
|
||||
static void ManageWaterRipples();
|
||||
@@ -399,8 +383,6 @@ public:
|
||||
static void SetAdvancedRefractionsEnabled(bool value) { advancedRefractions = value; }
|
||||
static bool GetAdvancedRefractionsEnabled(); // also needs additional driver support for now...
|
||||
static bool IsRequestedReflectionRendering() { return requestReflectionRendering; }
|
||||
static wiGraphicsTypes::Texture2D* GetColorGrading(){return colorGrading;};
|
||||
static void SetColorGrading(wiGraphicsTypes::Texture2D* tex){colorGrading=tex;};
|
||||
static void SetEnviromentMap(wiGraphicsTypes::Texture2D* tex){ enviroMap = tex; }
|
||||
static wiGraphicsTypes::Texture2D* GetEnviromentMap(){ return enviroMap; }
|
||||
static wiGraphicsTypes::Texture2D* GetLuminance(wiGraphicsTypes::Texture2D* sourceImage, GRAPHICSTHREAD threadID);
|
||||
@@ -460,8 +442,8 @@ public:
|
||||
static void SetClipPlane(const XMFLOAT4& clipPlane, GRAPHICSTHREAD threadID);
|
||||
static void SetAlphaRef(float alphaRef, GRAPHICSTHREAD threadID);
|
||||
static void ResetAlphaRef(GRAPHICSTHREAD threadID) { SetAlphaRef(0.75f, threadID); }
|
||||
static void UpdateGBuffer(wiGraphicsTypes::Texture2D* slot0, wiGraphicsTypes::Texture2D* slot1, wiGraphicsTypes::Texture2D* slot2, wiGraphicsTypes::Texture2D* slot3, wiGraphicsTypes::Texture2D* slot4, GRAPHICSTHREAD threadID);
|
||||
static void UpdateDepthBuffer(wiGraphicsTypes::Texture2D* depth, wiGraphicsTypes::Texture2D* linearDepth, GRAPHICSTHREAD threadID);
|
||||
static void BindGBufferTextures(wiGraphicsTypes::Texture2D* slot0, wiGraphicsTypes::Texture2D* slot1, wiGraphicsTypes::Texture2D* slot2, wiGraphicsTypes::Texture2D* slot3, wiGraphicsTypes::Texture2D* slot4, GRAPHICSTHREAD threadID);
|
||||
static void BindDepthTextures(wiGraphicsTypes::Texture2D* depth, wiGraphicsTypes::Texture2D* linearDepth, GRAPHICSTHREAD threadID);
|
||||
|
||||
static void RenderMeshes(const XMFLOAT3& eye, const CulledCollection& culledRenderer, SHADERTYPE shaderType, UINT renderTypeFlags, GRAPHICSTHREAD threadID,
|
||||
bool tessellation = false, bool occlusionCulling = false, uint32_t layerMask = 0xFFFFFFFF);
|
||||
@@ -470,23 +452,9 @@ public:
|
||||
static void DrawWorld(wiSceneComponents::Camera* camera, bool tessellation, GRAPHICSTHREAD threadID, SHADERTYPE shaderType, bool grass, bool occlusionCulling, uint32_t layerMask = 0xFFFFFFFF);
|
||||
static void DrawForShadowMap(GRAPHICSTHREAD threadID, uint32_t layerMask = 0xFFFFFFFF);
|
||||
static void DrawWorldTransparent(wiSceneComponents::Camera* camera, SHADERTYPE shaderType, GRAPHICSTHREAD threadID, bool grass, bool occlusionCulling, uint32_t layerMask = 0xFFFFFFFF);
|
||||
void DrawDebugSpheres(wiSceneComponents::Camera* camera, GRAPHICSTHREAD threadID);
|
||||
static void DrawDebugBoneLines(wiSceneComponents::Camera* camera, GRAPHICSTHREAD threadID);
|
||||
static void DrawDebugLines(wiSceneComponents::Camera* camera, GRAPHICSTHREAD threadID);
|
||||
static void DrawDebugBoxes(wiSceneComponents::Camera* camera, GRAPHICSTHREAD threadID);
|
||||
static void DrawTranslators(wiSceneComponents::Camera* camera, GRAPHICSTHREAD threadID);
|
||||
static void DrawDebugEnvProbes(wiSceneComponents::Camera* camera, GRAPHICSTHREAD threadID);
|
||||
static void DrawDebugGridHelper(wiSceneComponents::Camera* camera, GRAPHICSTHREAD threadID);
|
||||
static void DrawDebugVoxels(wiSceneComponents::Camera* camera, GRAPHICSTHREAD threadID);
|
||||
static void DrawDebugEmitters(wiSceneComponents::Camera* camera, GRAPHICSTHREAD threadID);
|
||||
static void DrawDebugForceFields(wiSceneComponents::Camera* camera, GRAPHICSTHREAD threadID);
|
||||
static void DrawDebugCameras(wiSceneComponents::Camera* camera, GRAPHICSTHREAD threadID);
|
||||
static void DrawDebugWorld(wiSceneComponents::Camera* camera, GRAPHICSTHREAD threadID);
|
||||
static void DrawSoftParticles(wiSceneComponents::Camera* camera, bool distortion, GRAPHICSTHREAD threadID);
|
||||
static void DrawTrails(GRAPHICSTHREAD threadID, wiGraphicsTypes::Texture2D* refracRes);
|
||||
static void DrawImagesAdd(GRAPHICSTHREAD threadID, wiGraphicsTypes::Texture2D* refracRes);
|
||||
//alpha-opaque
|
||||
static void DrawImages(GRAPHICSTHREAD threadID, wiGraphicsTypes::Texture2D* refracRes);
|
||||
static void DrawImagesNormals(GRAPHICSTHREAD threadID, wiGraphicsTypes::Texture2D* refracRes);
|
||||
static void DrawLights(wiSceneComponents::Camera* camera, GRAPHICSTHREAD threadID);
|
||||
static void DrawLightVisualizers(wiSceneComponents::Camera* camera, GRAPHICSTHREAD threadID);
|
||||
static void DrawVolumeLights(wiSceneComponents::Camera* camera, GRAPHICSTHREAD threadID);
|
||||
@@ -533,95 +501,35 @@ public:
|
||||
static XMVECTOR GetSunPosition();
|
||||
static XMFLOAT4 GetSunColor();
|
||||
static int GetSunArrayIndex();
|
||||
static int getVertexCount(){return vertexCount;}
|
||||
static void resetVertexCount(){vertexCount=0;}
|
||||
static int getVisibleObjectCount(){return visibleCount;}
|
||||
static void resetVisibleObjectCount(){visibleCount=0;}
|
||||
|
||||
static wiSPTree* spTree;
|
||||
static wiSPTree* spTree_lights;
|
||||
|
||||
// The scene holds all models, world information and wind information
|
||||
// The scene holds all models, and world information
|
||||
static wiSceneComponents::Scene& GetScene();
|
||||
|
||||
static std::vector<Lines*> boneLines;
|
||||
static std::vector<Lines*> linesTemp;
|
||||
static std::vector<Cube> cubes;
|
||||
|
||||
static std::unordered_set<wiSceneComponents::Object*> objectsWithTrails;
|
||||
static std::unordered_set<wiEmittedParticle*> emitterSystems;
|
||||
|
||||
static std::deque<wiSprite*> images;
|
||||
static std::deque<wiSprite*> waterRipples;
|
||||
static void ClearWorld();
|
||||
|
||||
|
||||
static wiRenderTarget normalMapRT, imagesRT, imagesRTAdd;
|
||||
|
||||
static wiSceneComponents::Camera* cam, *refCam, *prevFrameCam;
|
||||
static wiSceneComponents::Camera* getCamera(){ return cam; }
|
||||
static wiSceneComponents::Camera* getRefCamera(){ return refCam; }
|
||||
|
||||
std::string DIRECTORY;
|
||||
|
||||
struct Picked
|
||||
{
|
||||
wiSceneComponents::Transform* transform;
|
||||
wiSceneComponents::Object* object;
|
||||
wiSceneComponents::Light* light;
|
||||
wiSceneComponents::Decal* decal;
|
||||
wiSceneComponents::EnvironmentProbe* envProbe;
|
||||
wiSceneComponents::ForceField* forceField;
|
||||
wiSceneComponents::Camera* camera;
|
||||
wiSceneComponents::Armature* armature;
|
||||
XMFLOAT3 position,normal;
|
||||
float distance;
|
||||
int subsetIndex;
|
||||
|
||||
Picked()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
// Subset index, position, normal, distance don't distinguish between pickeds!
|
||||
bool operator==(const Picked& other)
|
||||
{
|
||||
return
|
||||
transform == other.transform &&
|
||||
object == other.object &&
|
||||
light == other.light &&
|
||||
decal == other.decal &&
|
||||
envProbe == other.envProbe &&
|
||||
forceField == other.forceField &&
|
||||
camera == other.camera &&
|
||||
armature == other.armature
|
||||
;
|
||||
}
|
||||
void Clear()
|
||||
{
|
||||
distance = 0;
|
||||
subsetIndex = -1;
|
||||
SAFE_INIT(transform);
|
||||
SAFE_INIT(object);
|
||||
SAFE_INIT(light);
|
||||
SAFE_INIT(decal);
|
||||
SAFE_INIT(envProbe);
|
||||
SAFE_INIT(forceField);
|
||||
SAFE_INIT(camera);
|
||||
SAFE_INIT(armature);
|
||||
}
|
||||
};
|
||||
|
||||
// Pick closest object in the world
|
||||
// pickType: PICKTYPE enum values concatenated with | operator
|
||||
// layer : concatenated string of layers to check against, empty string : all layers will be checked
|
||||
// layerDisable : concatenated string of layers to NOT check against
|
||||
static Picked Pick(long cursorX, long cursorY, int pickType = PICK_OPAQUE, uint32_t layerMask = 0xFFFFFFFF);
|
||||
static Picked Pick(RAY& ray, int pickType = PICK_OPAQUE, uint32_t layerMask = 0xFFFFFFFF);
|
||||
static RAY getPickRay(long cursorX, long cursorY);
|
||||
static void RayIntersectMeshes(const RAY& ray, const CulledList& culledObjects, std::vector<Picked>& points,
|
||||
int pickType = PICK_OPAQUE, bool dynamicObjects = true, bool onlyVisible = false, uint32_t layerMask = 0xFFFFFFFF);
|
||||
static void CalculateVertexAO(wiSceneComponents::Object* object);
|
||||
|
||||
struct RayIntersectWorldResult
|
||||
{
|
||||
wiSceneComponents::Object* object = nullptr;
|
||||
XMFLOAT3 position = XMFLOAT3(0, 0, 0);
|
||||
XMFLOAT3 normal = XMFLOAT3(0, 0, 0);
|
||||
float distance = FLT_MAX;
|
||||
int subsetIndex = -1;
|
||||
};
|
||||
static RayIntersectWorldResult RayIntersectWorld(const RAY& ray, UINT renderTypeMask = RENDERTYPE_OPAQUE, uint32_t layerMask = 0xFFFFFFFF, bool dynamicObjects = true, bool onlyVisible = false);
|
||||
|
||||
|
||||
static PHYSICS* physicsEngine;
|
||||
static void SynchronizeWithPhysicsEngine(float dt = 1.0f / 60.0f);
|
||||
@@ -646,17 +554,22 @@ public:
|
||||
// Add box to render in next frame
|
||||
static void AddRenderableBox(const XMFLOAT4X4& boxMatrix, const XMFLOAT4& color = XMFLOAT4(1,1,1,1));
|
||||
|
||||
struct RenderableLine
|
||||
{
|
||||
XMFLOAT3 start = XMFLOAT3(0, 0, 0);
|
||||
XMFLOAT3 end = XMFLOAT3(0, 0, 0);
|
||||
XMFLOAT4 color = XMFLOAT4(1, 1, 1, 1);
|
||||
};
|
||||
static std::vector<RenderableLine> renderableLines;
|
||||
static void AddRenderableLine(const RenderableLine& line);
|
||||
|
||||
static void AddDeferredMIPGen(wiGraphicsTypes::Texture2D* tex);
|
||||
|
||||
// Add model to the scene
|
||||
|
||||
static void AddModel(wiSceneComponents::Model* value);
|
||||
// Add Object Instance
|
||||
static void Add(wiSceneComponents::Object* value);
|
||||
// Add Light Instance
|
||||
static void Add(wiSceneComponents::Light* value);
|
||||
// Add Force Field Instance
|
||||
static void Add(wiSceneComponents::ForceField* value);
|
||||
// Add Camera Instance
|
||||
static void Add(wiSceneComponents::Camera* value);
|
||||
|
||||
// Remove from the scene
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include "wiRenderer_BindLua.h"
|
||||
#include "wiRenderer.h"
|
||||
#include "wiLines.h"
|
||||
#include "wiSceneComponents.h"
|
||||
#include "wiHelper.h"
|
||||
#include "wiSceneComponents_BindLua.h"
|
||||
@@ -405,23 +404,6 @@ namespace wiRenderer_BindLua
|
||||
wiLua::SError(L, "SetEnvironmentMap(Texture cubemap) not enough arguments!");
|
||||
return 0;
|
||||
}
|
||||
int SetColorGrading(lua_State* L)
|
||||
{
|
||||
int argc = wiLua::SGetArgCount(L);
|
||||
if (argc > 0)
|
||||
{
|
||||
Texture_BindLua* tex = Luna<Texture_BindLua>::lightcheck(L, 1);
|
||||
if (tex != nullptr)
|
||||
{
|
||||
wiRenderer::SetColorGrading(tex->texture);
|
||||
}
|
||||
else
|
||||
wiLua::SError(L, "SetColorGrading(Texture texture2D) argument is not a texture!");
|
||||
}
|
||||
else
|
||||
wiLua::SError(L, "SetColorGrading(Texture texture2D) not enough arguments!");
|
||||
return 0;
|
||||
}
|
||||
int HairParticleSettings(lua_State* L)
|
||||
{
|
||||
int argc = wiLua::SGetArgCount(L);
|
||||
@@ -587,18 +569,18 @@ namespace wiRenderer_BindLua
|
||||
Ray_BindLua* ray = Luna<Ray_BindLua>::lightcheck(L, 1);
|
||||
if (ray != nullptr)
|
||||
{
|
||||
int pickType = PICKTYPE::PICK_OPAQUE;
|
||||
UINT renderTypeMask = RENDERTYPE_OPAQUE;
|
||||
uint32_t layerMask = 0xFFFFFFFF;
|
||||
if (argc > 1)
|
||||
{
|
||||
pickType = wiLua::SGetInt(L, 2);
|
||||
renderTypeMask = (UINT)wiLua::SGetInt(L, 2);
|
||||
if (argc > 2)
|
||||
{
|
||||
int mask = wiLua::SGetInt(L, 3);
|
||||
layerMask = *reinterpret_cast<uint32_t*>(&mask);
|
||||
}
|
||||
}
|
||||
wiRenderer::Picked pick = wiRenderer::Pick(ray->ray, pickType, layerMask);
|
||||
auto& pick = wiRenderer::RayIntersectWorld(ray->ray, renderTypeMask, layerMask);
|
||||
Luna<Object_BindLua>::push(L, new Object_BindLua(pick.object));
|
||||
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMLoadFloat3(&pick.position)));
|
||||
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMLoadFloat3(&pick.normal)));
|
||||
@@ -609,35 +591,35 @@ namespace wiRenderer_BindLua
|
||||
return 0;
|
||||
}
|
||||
int DrawLine(lua_State* L)
|
||||
{
|
||||
int argc = wiLua::SGetArgCount(L);
|
||||
if (argc > 1)
|
||||
{
|
||||
int argc = wiLua::SGetArgCount(L);
|
||||
if (argc > 1)
|
||||
Vector_BindLua* a = Luna<Vector_BindLua>::lightcheck(L, 1);
|
||||
Vector_BindLua* b = Luna<Vector_BindLua>::lightcheck(L, 2);
|
||||
if (a && b)
|
||||
{
|
||||
Vector_BindLua* a = Luna<Vector_BindLua>::lightcheck(L, 1);
|
||||
Vector_BindLua* b = Luna<Vector_BindLua>::lightcheck(L, 2);
|
||||
if (a && b)
|
||||
wiRenderer::RenderableLine line;
|
||||
XMStoreFloat3(&line.start, a->vector);
|
||||
XMStoreFloat3(&line.end, b->vector);
|
||||
if (argc > 2)
|
||||
{
|
||||
XMFLOAT3 xa, xb;
|
||||
XMFLOAT4 xc = XMFLOAT4(1, 1, 1, 1);
|
||||
XMStoreFloat3(&xa, a->vector);
|
||||
XMStoreFloat3(&xb, b->vector);
|
||||
if (argc > 2)
|
||||
{
|
||||
Vector_BindLua* c = Luna<Vector_BindLua>::lightcheck(L, 3);
|
||||
if (c)
|
||||
XMStoreFloat4(&xc, c->vector);
|
||||
else
|
||||
wiLua::SError(L, "DrawLine(Vector origin,end, opt Vector color) one or more arguments are not vectors!");
|
||||
}
|
||||
wiRenderer::linesTemp.push_back(new Lines(xa, xb, xc));
|
||||
Vector_BindLua* c = Luna<Vector_BindLua>::lightcheck(L, 3);
|
||||
if (c)
|
||||
XMStoreFloat4(&line.color, c->vector);
|
||||
else
|
||||
wiLua::SError(L, "DrawLine(Vector origin,end, opt Vector color) one or more arguments are not vectors!");
|
||||
}
|
||||
else
|
||||
wiLua::SError(L, "DrawLine(Vector origin,end, opt Vector color) one or more arguments are not vectors!");
|
||||
wiRenderer::AddRenderableLine(line);
|
||||
}
|
||||
else
|
||||
wiLua::SError(L, "DrawLine(Vector origin,end, opt Vector color) not enough arguments!");
|
||||
return 0;
|
||||
wiLua::SError(L, "DrawLine(Vector origin,end, opt Vector color) one or more arguments are not vectors!");
|
||||
}
|
||||
else
|
||||
wiLua::SError(L, "DrawLine(Vector origin,end, opt Vector color) not enough arguments!");
|
||||
|
||||
return 0;
|
||||
}
|
||||
int PutWaterRipple(lua_State* L)
|
||||
{
|
||||
int argc = wiLua::SGetArgCount(L);
|
||||
@@ -756,7 +738,6 @@ namespace wiRenderer_BindLua
|
||||
wiLua::GetGlobal()->RegisterFunc("LoadWorldInfo", LoadWorldInfo);
|
||||
wiLua::GetGlobal()->RegisterFunc("DuplicateInstance", DuplicateInstance);
|
||||
wiLua::GetGlobal()->RegisterFunc("SetEnvironmentMap", SetEnvironmentMap);
|
||||
wiLua::GetGlobal()->RegisterFunc("SetColorGrading", SetColorGrading);
|
||||
wiLua::GetGlobal()->RegisterFunc("HairParticleSettings", HairParticleSettings);
|
||||
wiLua::GetGlobal()->RegisterFunc("SetAlphaCompositionEnabled", SetAlphaCompositionEnabled);
|
||||
wiLua::GetGlobal()->RegisterFunc("SetShadowProps2D", SetShadowProps2D);
|
||||
@@ -783,13 +764,6 @@ namespace wiRenderer_BindLua
|
||||
wiLua::GetGlobal()->RunText("PICK_OPAQUE = 1");
|
||||
wiLua::GetGlobal()->RunText("PICK_TRANSPARENT = 2");
|
||||
wiLua::GetGlobal()->RunText("PICK_WATER = 4");
|
||||
wiLua::GetGlobal()->RunText("PICK_LIGHT = 8");
|
||||
wiLua::GetGlobal()->RunText("PICK_DECAL = 16");
|
||||
wiLua::GetGlobal()->RunText("PICK_ENVPROBE = 32");
|
||||
wiLua::GetGlobal()->RunText("PICK_FORCEFIELD = 64");
|
||||
wiLua::GetGlobal()->RunText("PICK_EMITTER = 128");
|
||||
wiLua::GetGlobal()->RunText("PICK_CAMERA = 256");
|
||||
wiLua::GetGlobal()->RunText("PICK_ARMATURE = 512");
|
||||
|
||||
|
||||
wiLua::GetGlobal()->RegisterFunc("ClearWorld", ClearWorld);
|
||||
|
||||
@@ -128,7 +128,7 @@ void wiSPTree::Sort(const XMFLOAT3& origin, CulledList& objects, SortType sortTy
|
||||
}
|
||||
}
|
||||
|
||||
void wiSPTree::getVisible(Frustum& frustum, CulledList& objects, SortType sortType, CullStrictness type, Node* node)
|
||||
void wiSPTree::getVisible(const Frustum& frustum, CulledList& objects, SortType sortType, CullStrictness type, Node* node)
|
||||
{
|
||||
if (node == nullptr)
|
||||
{
|
||||
@@ -170,7 +170,7 @@ void wiSPTree::getVisible(Frustum& frustum, CulledList& objects, SortType sortTy
|
||||
Sort(frustum.getCamPos(), objects, sortType);
|
||||
}
|
||||
}
|
||||
void wiSPTree::getVisible(AABB& frustum, CulledList& objects, SortType sortType, CullStrictness type, Node* node)
|
||||
void wiSPTree::getVisible(const AABB& frustum, CulledList& objects, SortType sortType, CullStrictness type, Node* node)
|
||||
{
|
||||
if (node == nullptr)
|
||||
{
|
||||
@@ -211,7 +211,7 @@ void wiSPTree::getVisible(AABB& frustum, CulledList& objects, SortType sortType,
|
||||
Sort(frustum.getCenter(), objects, sortType);
|
||||
}
|
||||
}
|
||||
void wiSPTree::getVisible(SPHERE& frustum, CulledList& objects, SortType sortType, CullStrictness type, Node* node)
|
||||
void wiSPTree::getVisible(const SPHERE& frustum, CulledList& objects, SortType sortType, CullStrictness type, Node* node)
|
||||
{
|
||||
if (node == nullptr)
|
||||
{
|
||||
@@ -247,7 +247,7 @@ void wiSPTree::getVisible(SPHERE& frustum, CulledList& objects, SortType sortTyp
|
||||
Sort(frustum.center, objects, sortType);
|
||||
}
|
||||
}
|
||||
void wiSPTree::getVisible(RAY& frustum, CulledList& objects, SortType sortType, CullStrictness type, Node* node)
|
||||
void wiSPTree::getVisible(const RAY& frustum, CulledList& objects, SortType sortType, CullStrictness type, Node* node)
|
||||
{
|
||||
if (node == nullptr)
|
||||
{
|
||||
|
||||
@@ -71,10 +71,10 @@ public:
|
||||
static void Sort(const XMFLOAT3& origin, CulledList& objects, SortType sortType = SP_TREE_SORT_UNIQUE);
|
||||
|
||||
void AddObjects(Node* node, const std::vector<wiSceneComponents::Cullable*>& newObjects);
|
||||
void getVisible(Frustum& frustum, CulledList& objects, SortType sortType = SP_TREE_SORT_UNIQUE, CullStrictness type = SP_TREE_STRICT_CULL, Node* node = nullptr);
|
||||
void getVisible(AABB& frustum, CulledList& objects, SortType sortType = SP_TREE_SORT_UNIQUE, CullStrictness type = SP_TREE_STRICT_CULL, Node* node = nullptr);
|
||||
void getVisible(SPHERE& frustum, CulledList& objects, SortType sortType = SP_TREE_SORT_UNIQUE, CullStrictness type = SP_TREE_STRICT_CULL, Node* node = nullptr);
|
||||
void getVisible(RAY& frustum, CulledList& objects, SortType sortType = SP_TREE_SORT_UNIQUE, CullStrictness type = SP_TREE_STRICT_CULL, Node* node = nullptr);
|
||||
void getVisible(const Frustum& frustum, CulledList& objects, SortType sortType = SP_TREE_SORT_UNIQUE, CullStrictness type = SP_TREE_STRICT_CULL, Node* node = nullptr);
|
||||
void getVisible(const AABB& frustum, CulledList& objects, SortType sortType = SP_TREE_SORT_UNIQUE, CullStrictness type = SP_TREE_STRICT_CULL, Node* node = nullptr);
|
||||
void getVisible(const SPHERE& frustum, CulledList& objects, SortType sortType = SP_TREE_SORT_UNIQUE, CullStrictness type = SP_TREE_STRICT_CULL, Node* node = nullptr);
|
||||
void getVisible(const RAY& frustum, CulledList& objects, SortType sortType = SP_TREE_SORT_UNIQUE, CullStrictness type = SP_TREE_STRICT_CULL, Node* node = nullptr);
|
||||
void getAll(CulledList& objects, Node* node = nullptr);
|
||||
// Updates the tree. Returns null if successful, returns a new tree if the tree is resized. The old tree can be thrown away then.
|
||||
wiSPTree* updateTree(Node* node = nullptr);
|
||||
|
||||
@@ -1458,35 +1458,42 @@ void Model::FinishLoading()
|
||||
{
|
||||
if (x->parent == nullptr)
|
||||
{
|
||||
for (Transform* y : transforms)
|
||||
if (x->boneParent.empty())
|
||||
{
|
||||
if (x != y && !x->parentName.empty() && !x->parentName.compare(y->name))
|
||||
// Normal parenting:
|
||||
if (!x->parentName.empty())
|
||||
{
|
||||
Transform* parent = y;
|
||||
string parentName = parent->name;
|
||||
if (!x->boneParent.empty())
|
||||
for (Transform* y : transforms)
|
||||
{
|
||||
Armature* armature = dynamic_cast<Armature*>(y);
|
||||
if (armature != nullptr)
|
||||
if (x != y && !x->parentName.compare(y->name))
|
||||
{
|
||||
for (Bone* bone : armature->boneCollection)
|
||||
{
|
||||
if (!bone->name.compare(x->boneParent))
|
||||
{
|
||||
parent = bone;
|
||||
break;
|
||||
}
|
||||
}
|
||||
XMFLOAT4X4 saved_parent_rest_inv = x->parent_inv_rest;
|
||||
x->attachTo(y);
|
||||
x->parent_inv_rest = saved_parent_rest_inv;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Match parent
|
||||
XMFLOAT4X4 saved_parent_rest_inv = x->parent_inv_rest;
|
||||
x->attachTo(parent);
|
||||
x->parent_inv_rest = saved_parent_rest_inv;
|
||||
x->parentName = parentName; // this will ensure that the bone parenting is always resolved as armature->bone
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Bone parenting:
|
||||
for (Armature* armature : armatures)
|
||||
{
|
||||
if (armature != x)
|
||||
{
|
||||
Bone* y = armature->GetBone(x->boneParent);
|
||||
if (y != nullptr)
|
||||
{
|
||||
XMFLOAT4X4 saved_parent_rest_inv = x->parent_inv_rest;
|
||||
x->attachTo(y);
|
||||
x->parent_inv_rest = saved_parent_rest_inv;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// If it has still no parent, then attach to this model!
|
||||
@@ -1861,11 +1868,6 @@ void Model::Serialize(wiArchive& archive)
|
||||
#pragma endregion
|
||||
|
||||
#pragma region BONE
|
||||
XMMATRIX Bone::getMatrix(int getTranslation, int getRotation, int getScale)
|
||||
{
|
||||
|
||||
return XMMatrixTranslation(0,0,length)*XMLoadFloat4x4(&world);
|
||||
}
|
||||
void Bone::UpdateTransform()
|
||||
{
|
||||
//Transform::UpdateTransform();
|
||||
@@ -2105,24 +2107,40 @@ void Armature::UpdateTransform()
|
||||
{
|
||||
Transform::UpdateTransform();
|
||||
|
||||
XMMATRIX worldMatrix = getMatrix();
|
||||
XMMATRIX remapMat = XMLoadFloat4x4(&skinningRemap);
|
||||
|
||||
// Update bone tree from root:
|
||||
for (Bone* root : rootbones)
|
||||
{
|
||||
// Update tree for skinning:
|
||||
// Note that skinning is not using the armature transform, it will be calculated in armature local space
|
||||
// This is needed because we want to skin meshes, then reuse the meshes for multiple objects without additional deform
|
||||
RecursiveBoneTransform(this, root, remapMat);
|
||||
}
|
||||
|
||||
// Update tree for bone attaching:
|
||||
XMMATRIX worldMatrix = getMatrix();
|
||||
for (Bone* bone : boneCollection)
|
||||
{
|
||||
// Update each bone for attaching:
|
||||
// The Skinning (RecursiveBoneTrasform) was operating in armature local space, but for bone attachments without deform,
|
||||
// we need the matrices in world space
|
||||
XMMATRIX boneMatrix = XMLoadFloat4x4(&root->world);
|
||||
XMMATRIX boneMatrix = XMLoadFloat4x4(&bone->world);
|
||||
boneMatrix = boneMatrix * worldMatrix;
|
||||
XMStoreFloat4x4(&root->world, boneMatrix);
|
||||
root->UpdateTransform();
|
||||
|
||||
// Save individual components for prev-frame:
|
||||
bone->worldPrev = bone->world;
|
||||
bone->translationPrev = bone->translation;
|
||||
bone->rotationPrev = bone->rotation;
|
||||
bone->scalePrev = bone->scale;
|
||||
|
||||
// Update individual components:
|
||||
XMVECTOR v[3];
|
||||
XMMatrixDecompose(&v[0], &v[1], &v[2], boneMatrix);
|
||||
XMStoreFloat3(&bone->scale, v[0]);
|
||||
XMStoreFloat4(&bone->rotation, v[1]);
|
||||
XMStoreFloat3(&bone->translation, v[2]);
|
||||
XMStoreFloat4x4(&bone->world, boneMatrix);
|
||||
|
||||
// Any attachments should be updated too:
|
||||
bone->UpdateTransform();
|
||||
}
|
||||
}
|
||||
void Armature::UpdateArmature()
|
||||
@@ -2225,14 +2243,6 @@ void Armature::RecursiveBoneTransform(Armature* armature, Bone* bone, const XMMA
|
||||
}
|
||||
}
|
||||
|
||||
bone->worldPrev = bone->world;
|
||||
bone->translationPrev = bone->translation;
|
||||
bone->rotationPrev = bone->rotation;
|
||||
bone->scalePrev = bone->scale;
|
||||
XMStoreFloat3(&bone->translation, finalTrans);
|
||||
XMStoreFloat4(&bone->rotation, finalRotat);
|
||||
XMStoreFloat3(&bone->scale, finalScala);
|
||||
|
||||
// Bone local T-pose matrix (relative to PARENT):
|
||||
XMMATRIX rest = XMLoadFloat4x4(&bone->world_rest);
|
||||
|
||||
|
||||
@@ -661,8 +661,7 @@ struct Bone : public Transform
|
||||
connected = false;
|
||||
}
|
||||
|
||||
XMMATRIX getMatrix(int getTranslation = 1, int getRotation = 1, int getScale = 1);
|
||||
virtual void UpdateTransform();
|
||||
virtual void UpdateTransform() override;
|
||||
void Serialize(wiArchive& archive);
|
||||
};
|
||||
struct AnimationLayer
|
||||
@@ -950,6 +949,9 @@ struct WorldInfo{
|
||||
float cloudiness;
|
||||
float cloudScale;
|
||||
float cloudSpeed;
|
||||
XMFLOAT3 windDirection;
|
||||
float windRandomness;
|
||||
float windWaveSize;
|
||||
|
||||
WorldInfo(){
|
||||
horizon = XMFLOAT3(0.0f, 0.0f, 0.0f);
|
||||
@@ -960,14 +962,11 @@ struct WorldInfo{
|
||||
cloudiness = 0.0f;
|
||||
cloudScale = 0.0003f;
|
||||
cloudSpeed = 0.1f;
|
||||
windDirection = XMFLOAT3(0, 0, 0);
|
||||
windRandomness = 5;
|
||||
windWaveSize = 1;
|
||||
}
|
||||
};
|
||||
struct Wind{
|
||||
XMFLOAT3 direction;
|
||||
float randomness;
|
||||
float waveSize;
|
||||
Wind():direction(XMFLOAT3(0,0,0)),randomness(5),waveSize(1){}
|
||||
};
|
||||
struct Camera : public Transform, public ModelChild
|
||||
{
|
||||
XMFLOAT4X4 View, Projection, VP;
|
||||
@@ -1222,7 +1221,6 @@ struct Scene
|
||||
// First is always the world node
|
||||
std::vector<Model*> models;
|
||||
WorldInfo worldInfo;
|
||||
Wind wind;
|
||||
|
||||
Scene();
|
||||
~Scene();
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "CommonInclude.h"
|
||||
|
||||
class wiTaskThread {
|
||||
public:
|
||||
wiTaskThread(std::function<void()> task)
|
||||
: m_task(std::move(task)),
|
||||
m_wakeup(false),
|
||||
m_stop(false),
|
||||
m_thread(&wiTaskThread::taskFunc, this)
|
||||
{}
|
||||
~wiTaskThread() { stop(); join(); }
|
||||
|
||||
void wakeup() {
|
||||
auto lock = std::unique_lock<std::mutex>(m_wakemutex);
|
||||
m_wakeup = true;
|
||||
m_wakecond.notify_one();
|
||||
}
|
||||
void wait() {
|
||||
auto lock = std::unique_lock<std::mutex>(m_waitmutex);
|
||||
while (m_wakeup)
|
||||
m_waitcond.wait(lock);
|
||||
}
|
||||
|
||||
void stop() {
|
||||
auto lock = std::unique_lock<std::mutex>(m_wakemutex);
|
||||
m_stop = true;
|
||||
m_wakecond.notify_one();
|
||||
}
|
||||
void join() {
|
||||
m_thread.join();
|
||||
}
|
||||
|
||||
private:
|
||||
std::function<void ()> m_task;
|
||||
|
||||
bool m_wakeup;
|
||||
bool m_stop;
|
||||
std::mutex m_wakemutex;
|
||||
std::condition_variable m_wakecond;
|
||||
|
||||
std::mutex m_waitmutex;
|
||||
std::condition_variable m_waitcond;
|
||||
|
||||
std::thread m_thread;
|
||||
|
||||
void taskFunc() {
|
||||
while (true) {
|
||||
{
|
||||
auto lock = std::unique_lock<std::mutex>(m_wakemutex);
|
||||
while (!m_wakeup && !m_stop)
|
||||
m_wakecond.wait(lock);
|
||||
if (m_stop) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
try { m_task(); } catch (...) {}
|
||||
|
||||
{
|
||||
auto lock = std::unique_lock<std::mutex>(m_waitmutex);
|
||||
m_wakeup = false;
|
||||
m_waitcond.notify_all();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
@@ -9,7 +9,7 @@ namespace wiVersion
|
||||
// minor features, major updates
|
||||
const int minor = 20;
|
||||
// minor bug fixes, alterations, refactors, updates
|
||||
const int revision = 0;
|
||||
const int revision = 1;
|
||||
|
||||
|
||||
long GetVersion()
|
||||
|
||||
Binary file not shown.
@@ -308,6 +308,13 @@ runProcess(function()
|
||||
--intersection
|
||||
DrawAxis(player.p,0.5)
|
||||
|
||||
-- Head bone
|
||||
DrawAxis(player.skeleton.GetBone("testa").GetPosition(),1.0)
|
||||
-- Left hand bone
|
||||
DrawAxis(player.skeleton.GetBone("mano_L").GetPosition(),1.0)
|
||||
-- Right hand bone
|
||||
DrawAxis(player.skeleton.GetBone("mano_R").GetPosition(),1.0)
|
||||
|
||||
|
||||
-- Wait for the engine to render the scene
|
||||
render()
|
||||
|
||||
Reference in New Issue
Block a user