Skip to content

Commit

Permalink
1.1.0harmattan20
Browse files Browse the repository at this point in the history
ShowSurface/HideSurface
  • Loading branch information
glKarin committed Nov 18, 2022
1 parent fd74d06 commit 483a144
Show file tree
Hide file tree
Showing 10 changed files with 112 additions and 3 deletions.
4 changes: 2 additions & 2 deletions doom3/neo/quake4/Entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4395,7 +4395,7 @@ void idEntity::ShowSurface ( const char* surface ) {
return;
}

#if 0 //k: not implament
#if 1 //k: implement
renderEntity.suppressSurfaceMask &= (~renderEntity.hModel->GetSurfaceMask ( surface ));
#endif
}
Expand All @@ -4419,7 +4419,7 @@ void idEntity::HideSurface ( const char* surface ) {
return;
}

#if 0 //k: not implament
#if 1 //k: implement
renderEntity.suppressSurfaceMask |= renderEntity.hModel->GetSurfaceMask ( surface ) ;
#endif
}
Expand Down
13 changes: 13 additions & 0 deletions doom3/neo/renderer/Interaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,11 @@ otherwise it will be marked as deferred.
The results of this are cached and valid until the light or entity change.
====================
*/
#ifdef _RAVEN
void idInteraction::CreateInteraction(const idRenderModel *model, int suppressSurfaceMask)
#else
void idInteraction::CreateInteraction(const idRenderModel *model)
#endif
{
const idMaterial *lightShader = lightDef->lightShader;
const idMaterial *shader;
Expand Down Expand Up @@ -912,6 +916,11 @@ void idInteraction::CreateInteraction(const idRenderModel *model)

// check each surface in the model
for (int c = 0 ; c < model->NumSurfaces() ; c++) {
#ifdef _RAVEN //k: for ShowSurface/HideSurface, shader mask is not 0 will skip make shadow and interaction
if(SUPPRESS_SURFACE_MASK_CHECK(suppressSurfaceMask, c))
continue;
#endif

const modelSurface_t *surf;
srfTriangles_t *tri;

Expand Down Expand Up @@ -1147,7 +1156,11 @@ void idInteraction::AddActiveInteraction(void)

// actually create the interaction if needed, building light and shadow surfaces as needed
if (IsDeferred()) {
#ifdef _RAVEN
CreateInteraction(model, entityDef->parms.suppressSurfaceMask);
#else
CreateInteraction(model);
#endif
}

R_GlobalPointToLocal(vEntity->modelMatrix, lightDef->globalLightOrigin, localLightOrigin);
Expand Down
4 changes: 4 additions & 0 deletions doom3/neo/renderer/Interaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,11 @@ class idInteraction

private:
// actually create the interaction
#ifdef _RAVEN //k: for renderEntity_s::suppressSurfaceMask
void CreateInteraction(const idRenderModel *model, int suppressSurfaceMask = 0);
#else
void CreateInteraction(const idRenderModel *model);
#endif

// unlink from entity and light lists
void Unlink(void);
Expand Down
20 changes: 20 additions & 0 deletions doom3/neo/renderer/Model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2556,3 +2556,23 @@ void rvRenderModelBSE::FinishSurfaces(bool useMikktspace) {
}
#endif

#ifdef _RAVEN //k: for ShowSurface/HideSurface, static model using surfaces index as mask: 1 << index, name is shader material name
int idRenderModelStatic::GetSurfaceMask(const char *name) const
{
int i;
const modelSurface_t *surf;
if(!name || !name[0])
return 0;
for(i = 0; i < surfaces.Num(); i++)
{
if(i > 31) //k: greate than int bits, it should be happened, but if happen, return 0 for do nothing
break;
surf = &surfaces[i];
if(!surf || !surf->shader)
continue;
if(!idStr::Icmp(name, surf->shader->GetName()))
return SUPPRESS_SURFACE_MASK(i);
}
return 0;
}
#endif
5 changes: 5 additions & 0 deletions doom3/neo/renderer/Model.h
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,11 @@ class idRenderModel
// Writing to and reading from a demo file.
virtual void ReadFromDemoFile(class idDemoFile *f) = 0;
virtual void WriteToDemoFile(class idDemoFile *f) = 0;
#ifdef _RAVEN
// RAVEN BEGIN
// bdube: surface flag manipulation
virtual int GetSurfaceMask ( const char* surface ) const = 0;;
#endif
};

#endif /* !__MODEL_H__ */
7 changes: 7 additions & 0 deletions doom3/neo/renderer/Model_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ class idRenderModelStatic : public idRenderModel
bool DeleteSurfaceWithId(int id);
void DeleteSurfacesWithNegativeId(void);
bool FindSurfaceWithId(int id, int &surfaceNum);
#ifdef _RAVEN //k: for ShowSurface/HideSurface, static model using surfaces index as mask: 1 << index, name is shader material name
virtual int GetSurfaceMask(const char *name) const;
#endif

public:
idList<modelSurface_t> surfaces;
Expand Down Expand Up @@ -185,6 +188,9 @@ class idRenderModelMD5 : public idRenderModelStatic
virtual const char *GetJointName(jointHandle_t handle) const;
virtual const idJointQuat *GetDefaultPose(void) const;
virtual int NearestJoint(int surfaceNum, int a, int b, int c) const;
#ifdef _RAVEN //k: for ShowSurface/HideSurface, md5 model using mesh index as mask: 1 << index, name is shader material name
virtual int GetSurfaceMask(const char *name) const;
#endif

private:
idList<idMD5Joint> joints;
Expand All @@ -197,6 +203,7 @@ class idRenderModelMD5 : public idRenderModelStatic
void ParseJoint(idLexer &parser, idMD5Joint *joint, idJointQuat *defaultPose);

#ifdef _RAVEN //k: for GUI view of dynamic model in idRenderWorld::GuiTrace
idList<idStr> surfaceShaderList;
public:
idRenderModelStatic *staticModel;
#endif
Expand Down
30 changes: 30 additions & 0 deletions doom3/neo/renderer/Model_md5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,13 @@ idRenderModel *idRenderModelMD5::InstantiateDynamicModel(const struct renderEnti

#ifdef _RAVEN //k: for GUI view of dynamic model in idRenderWorld::GuiTrace
this->staticModel = staticModel;

surfaceShaderList.Clear();
for(i = 0; i < staticModel->surfaces.Num(); i++)
{
const modelSurface_t *surf = &staticModel->surfaces[i];
surfaceShaderList.Append(surf && surf->shader ? surf->shader->GetName() : "");
}
#endif

return staticModel;
Expand Down Expand Up @@ -1062,3 +1069,26 @@ int idRenderModelMD5::Memory() const

return total;
}

#ifdef _RAVEN //k: for ShowSurface/HideSurface, md5 model using mesh index as mask: 1 << index, name is shader material name
int idRenderModelMD5::GetSurfaceMask(const char *name) const
{
int i;
idMD5Mesh *mesh;

if(!name || !name[0] || meshes.Num() == 0)
return 0;

for (mesh = meshes.Ptr(), i = 0; i < meshes.Num(); i++, mesh++)
{
if(i > 31) //k: greate than int bits, it should be happened, but if happen, return 0 for do nothing
break;
const idMaterial *shader = mesh->shader;
if(!shader)
continue;
if(!idStr::Icmp(name, shader->GetName()))
return SUPPRESS_SURFACE_MASK(i);
}
return 0;
}
#endif
6 changes: 5 additions & 1 deletion doom3/neo/renderer/tr_light.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1282,6 +1282,11 @@ static void R_AddAmbientDrawsurfs(viewEntity_t *vEntity)
for (i = 0 ; i < total ; i++) {
const modelSurface_t *surf = model->Surface(i);

#ifdef _RAVEN //k: for ShowSurface/HideSurface, shader mask is not 0 will skip render
if(SUPPRESS_SURFACE_MASK_CHECK(def->parms.suppressSurfaceMask, i))
continue;
#endif

// for debugging, only show a single surface at a time
if (r_singleSurface.GetInteger() >= 0 && i != r_singleSurface.GetInteger()) {
continue;
Expand Down Expand Up @@ -1410,7 +1415,6 @@ void R_AddModelSurfaces(void)
// go through each entity that is either visible to the view, or to
// any light that intersects the view (for shadows)
for (vEntity = tr.viewDef->viewEntitys; vEntity; vEntity = vEntity->next) {

if (r_useEntityScissors.GetBool()) {
// calculate the screen area covered by the entity
idScreenRect scissorRect = R_CalcEntityScissorRectangle(vEntity);
Expand Down
5 changes: 5 additions & 0 deletions doom3/neo/renderer/tr_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -1829,4 +1829,9 @@ extern idCVar harm_r_maxAllocStackMemory; // declare in tr_trisurf.cpp

#endif

#ifdef _RAVEN //k: macros for renderEffect_s::suppressSurfaceMask
#define SUPPRESS_SURFACE_MASK(x) (1 << (x))
#define SUPPRESS_SURFACE_MASK_CHECK(t, x) ((t) & SUPPRESS_SURFACE_MASK(x))
#endif

#endif /* !__TR_LOCAL_H__ */
21 changes: 21 additions & 0 deletions doom3/neo/ui/DeviceContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ idCVar gui_mediumFontLimit("gui_mediumFontLimit", "0.60", CVAR_GUI | CVAR_ARCHIV

idList<fontInfoEx_t> idDeviceContext::fonts;

#ifdef _RAVEN //k: I am not find Quake4 default font named "", so using cvar to control
const char *harm_gui_defaultFontArgs[] = {
"chain",
"lowpixel",
"marine",
"profont",
"r_strogg",
"strogg",
NULL };
static idCVar harm_gui_defaultFont("harm_gui_defaultFont", harm_gui_defaultFontArgs[0], CVAR_ARCHIVE | CVAR_GUI, "[Harmattan]: Setup default GUI font. It will be available in next running.", harm_gui_defaultFontArgs, idCmdSystem::ArgCompletion_String<harm_gui_defaultFontArgs>);
#endif
int idDeviceContext::FindFont(const char *name)
{
int c = fonts.Num();
Expand All @@ -60,6 +71,16 @@ int idDeviceContext::FindFont(const char *name)

// If the font was not found, try to register it
idStr fileName = name;
#ifdef _RAVEN //k: Quake4 default font
if(!idStr::Icmp(fileName, "fonts"))
{
fileName = "fonts/";
const char *defFontName = harm_gui_defaultFont.GetString();
if(!defFontName || !defFontName[0])
defFontName = harm_gui_defaultFontArgs[0];
fileName += defFontName;
}
#endif
fileName.Replace("fonts", va("fonts/%s", fontLang.c_str()));

fontInfoEx_t fontInfo;
Expand Down

0 comments on commit 483a144

Please sign in to comment.