本文整理汇总了C++中Vector4f::Dot方法的典型用法代码示例。如果您正苦于以下问题:C++ Vector4f::Dot方法的具体用法?C++ Vector4f::Dot怎么用?C++ Vector4f::Dot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector4f
的用法示例。
在下文中一共展示了Vector4f::Dot方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FrustumCull
void Renderer::FrustumCull(const Scene * scene, const Vector3f& camera_position,
const Array<SceneObject*> & scene_objects,
Array<RenderData*> & render_data_vector, const Matrix4f &vp_matrix,
const OESShader * oesShader) {
for (auto it = scene_objects.Begin(); it != scene_objects.End(); ++it) {
SceneObject *scene_object = (*it);
RenderData* render_data = scene_object->GetRenderData();
if (render_data == nullptr || render_data->GetMaterial() == nullptr) {
continue;
}
// Check for frustum culling flag
if (!scene->GetFrustumCulling()) {
//No occlusion or frustum tests enabled
render_data_vector.PushBack(render_data);
continue;
}
// Frustum culling setup
Mesh* currentMesh = render_data->GetMesh();
if (currentMesh == nullptr) {
continue;
}
BoundingBoxInfo bounding_box_info = currentMesh->GetBoundingBoxInfo();
Matrix4f modelMatrixTmp = render_data->GetOwnerObject()->GetMatrixWorld();
Matrix4f mvpMatrixTmp(vp_matrix * modelMatrixTmp);
// Frustum
float frustum[6][4];
// Matrix to array
float mvp_matrix_array[16] = { 0.0 };
const float *mat_to_array = (const float*)mvpMatrixTmp.Transposed().M[0]; // TODO this is originally glm::mat4 so transposed
memcpy(mvp_matrix_array, mat_to_array, sizeof(float) * 16);
// Build the frustum
BuildFrustum(frustum, mvp_matrix_array);
// Check for being inside or outside frustum
bool is_inside = IsCubeInFrustum(frustum, bounding_box_info);
// Only push those scene objects that are inside of the frustum
if (!is_inside) {
scene_object->SetInFrustum(false);
continue;
}
// Transform the bounding sphere
const BoundingSphereInfo sphereInfo = currentMesh->GetBoundingSphereInfo();
Vector4f sphere_center(sphereInfo.center, 1.0f);
Vector4f transformed_sphere_center = mvpMatrixTmp.Transform(sphere_center);
// Calculate distance from camera
Vector4f position(camera_position, 1.0f);
Vector4f difference = transformed_sphere_center - position;
float distance = difference.Dot(difference);
// this distance will be used when sorting transparent objects
render_data->SetCameraDistance(distance);
// Check if this is the correct LOD level
if (!scene_object->InLODRange(distance)) {
// not in range, don't add it to the list
continue;
}
scene_object->SetInFrustum();
bool visible = scene_object->IsVisible();
//If visibility flag was set by an earlier occlusion query,
//turn visibility on for the object
if (visible) {
render_data_vector.PushBack(render_data);
}
if (render_data->GetMaterial() == nullptr
|| !scene->GetOcclusionCulling()) {
continue;
}
}
}