asdf
This commit is contained in:
+69
-31
@@ -17,7 +17,17 @@ FaceApp::FaceApp(/* args */)
|
||||
|
||||
FaceApp::~FaceApp()
|
||||
{
|
||||
if (worker_.joinable()) {
|
||||
if(worker_.joinable())
|
||||
{
|
||||
worker_.join();
|
||||
}
|
||||
}
|
||||
|
||||
void FaceApp::Stop()
|
||||
{
|
||||
_running = false;
|
||||
if(worker_.joinable())
|
||||
{
|
||||
worker_.join();
|
||||
}
|
||||
}
|
||||
@@ -595,7 +605,7 @@ void FaceApp::setup_descriptor_set()
|
||||
|
||||
void FaceApp::update_descriptor_set(vector<Texture>& texs, vector<VkDescriptorSet>& descriptSet)
|
||||
{
|
||||
for (int i = 0; i < kTextureMax; ++i)
|
||||
for (int i = 0; i < texs.size(); ++i)
|
||||
{
|
||||
if (texs[i].image == VK_NULL_HANDLE)
|
||||
{
|
||||
@@ -731,7 +741,7 @@ void FaceApp::render(VkCommandBuffer commandBuffer, long long frameTime)
|
||||
#ifdef _WIN32
|
||||
vkCmdDrawIndexed(commandBuffer, obj_indices.size(), 1, 0, 0, 0);
|
||||
#else
|
||||
if (getCurrentTimeMillis() - last_update_time < 2000)
|
||||
//if (getCurrentTimeMillis() - last_update_time < 2000)
|
||||
{
|
||||
vkCmdDrawIndexed(commandBuffer, obj_indices.size(), 1, 0, 0, 0);
|
||||
}
|
||||
@@ -767,9 +777,10 @@ void FaceApp::createVmaAllocator()
|
||||
void FaceApp::initVulkan()
|
||||
{
|
||||
Application::initVulkan();
|
||||
|
||||
createVmaAllocator();
|
||||
LoadOBJ("face_picture_3dmax.obj", obj_vertices, obj_indices);
|
||||
m_texs_left.resize(kTextureMax);
|
||||
//m_texs_left.resize(kTextureMax);
|
||||
//m_texs_right.resize(kTextureMax);
|
||||
if (kThick)
|
||||
{
|
||||
@@ -807,8 +818,8 @@ void FaceApp::initVulkan()
|
||||
last_update_time = getCurrentTimeMillis();
|
||||
|
||||
//changeMotion(_initArg.motion);
|
||||
_running = true;
|
||||
faceAppInited = true;
|
||||
Start();
|
||||
|
||||
#if _WIN32
|
||||
std::vector<float> floatArray;
|
||||
std::string& str = HardCodeData::Get().face_result_point_str;
|
||||
@@ -823,6 +834,11 @@ void FaceApp::initVulkan()
|
||||
#endif
|
||||
}
|
||||
|
||||
void FaceApp::Start()
|
||||
{
|
||||
_running = true;
|
||||
}
|
||||
|
||||
void FaceApp::update_uniform_buffers()
|
||||
{
|
||||
uint32_t width = 480;
|
||||
@@ -892,6 +908,9 @@ void FaceApp::uploadVertexData() {
|
||||
|
||||
void FaceApp::update_face_vertex_buffer(float* pos, int pointCount)
|
||||
{
|
||||
if (pointCount == 0x33435342) {
|
||||
return;
|
||||
}
|
||||
if(!isInited())
|
||||
{
|
||||
return;
|
||||
@@ -1437,10 +1456,14 @@ string FaceApp::preLoadMotionList(string motion_list_str, Callback callback)
|
||||
}
|
||||
_isLoadMotion = true;
|
||||
_callback_loadfinish = callback;
|
||||
_loadMotions.clear();
|
||||
_curLoadMotionList.clear();
|
||||
json j = json::parse(motion_list_str);
|
||||
MotionList motion_list = j.get<MotionList>();
|
||||
_loadMotions = motion_list.motions;
|
||||
_curLoadMotionList = motion_list.motions;
|
||||
if (worker_.joinable())
|
||||
{
|
||||
worker_.join();
|
||||
}
|
||||
worker_ = std::thread(&FaceApp::loadMotionThread, this);
|
||||
return "ok";
|
||||
}
|
||||
@@ -1452,37 +1475,59 @@ void FaceApp::loadMotionThread()
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(50));
|
||||
}
|
||||
|
||||
vector<Texture>* load_text = nullptr;
|
||||
//vector<Texture>* load_text = nullptr;
|
||||
//if (cur_left)
|
||||
//{
|
||||
// load_text = &m_texs_right;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
load_text = &m_texs_left;
|
||||
// load_text = &m_texs_left;
|
||||
//}
|
||||
|
||||
vector<Texture>& pre_texs = *load_text;
|
||||
for (int i = 0; i < _loadMotions.size(); ++i)
|
||||
{
|
||||
if (pre_texs[i].image == VK_NULL_HANDLE)
|
||||
//vector<Texture>& pre_texs = *load_text;
|
||||
for (auto m : _curLoadMotionList) {
|
||||
string name = m.name;
|
||||
if (motion_list_map.find(name) != motion_list_map.end())
|
||||
{
|
||||
loadTexture(dummy_data, dummy_data.size(), dummy_w, dummy_h, pre_texs[i], true, commandPool, "");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
m_texs_left.push_back(Texture());
|
||||
Texture& newTex = m_texs_left[m_texs_left.size() - 1];
|
||||
loadTexture(dummy_data, dummy_data.size(), dummy_w, dummy_h, newTex, true, commandPool, "");
|
||||
#ifdef _WIN32
|
||||
string path = "pic";
|
||||
string path_name = path + "/" + _loadMotions[i].name + "ex.png";
|
||||
loadTextureExample(UTF8ToWideString(path_name), pre_texs[i], true, commandPool_ex);
|
||||
string path_name = path + "/" + name + "ex.png";
|
||||
loadTextureExample(UTF8ToWideString(path_name), newTex, true, commandPool_ex);
|
||||
#else
|
||||
string path = "pic";
|
||||
string path_name = path + "/" + _loadMotions[i].name + "ex.png";
|
||||
loadTexture(path_name, pre_texs[i], true, commandPool_ex);
|
||||
string path_name = path + "/" + name + "ex.png";
|
||||
loadTexture(path_name, newTex, true, commandPool_ex);
|
||||
#endif // _WIN32
|
||||
|
||||
motion_list_map[_loadMotions[i].name] = i;
|
||||
motion_list_map[name] = m_texs_left.size() - 1;
|
||||
_loadMotionMap[name] = m;
|
||||
}
|
||||
|
||||
// for (int i = 0; i < _loadMotions.size(); ++i)
|
||||
// {
|
||||
// if (pre_texs[i].image == VK_NULL_HANDLE)
|
||||
// {
|
||||
// loadTexture(dummy_data, dummy_data.size(), dummy_w, dummy_h, pre_texs[i], true, commandPool, "");
|
||||
// }
|
||||
//
|
||||
//
|
||||
//#ifdef _WIN32
|
||||
// string path = "pic";
|
||||
// string path_name = path + "/" + _loadMotions[i].name + "ex.png";
|
||||
// loadTextureExample(UTF8ToWideString(path_name), pre_texs[i], true, commandPool_ex);
|
||||
//#else
|
||||
// string path = "pic";
|
||||
// string path_name = path + "/" + _loadMotions[i].name + "ex.png";
|
||||
// loadTexture(path_name, pre_texs[i], true, commandPool_ex);
|
||||
//#endif // _WIN32
|
||||
//
|
||||
// motion_list_map[_loadMotions[i].name] = i;
|
||||
// }
|
||||
update_descriptor_set(m_texs_left, m_descriptor_sets_left);
|
||||
_isLoadMotion = false;
|
||||
_callback_loadfinish();
|
||||
@@ -1491,14 +1536,7 @@ void FaceApp::loadMotionThread()
|
||||
|
||||
Motion FaceApp::getMotionByName(string name)
|
||||
{
|
||||
for (auto m : _loadMotions)
|
||||
{
|
||||
if (m.name == name)
|
||||
{
|
||||
return m;
|
||||
}
|
||||
}
|
||||
return Motion();
|
||||
return _loadMotionMap[name];
|
||||
}
|
||||
|
||||
void FaceApp::changeMotionList(vector<string> motions, AnimationFinishedCallback callback, bool loop)
|
||||
|
||||
Reference in New Issue
Block a user