It's mostly genetics, then within that scope environment and other factors play a role....
this assumes it got sufficent light and resources for proper flower growth. check out a regional DLI map... you should find them per month for your area. it'll estimate how much light it gets per day, assuming it's not losing many ours to obstacles blocking light. if so, that has to be factored too. Supposedly 21-22DLI is a rough estimate for a minimum for a pot plant to add mass, or grow. At some point above that more light will mostly increase yield, but i'd bet intially incremental improvements would also help with density a bit.
excessive warmth ro humidity will not turn super dense nugs to larf... they may not be as tight as otherwise, of course. if you are doing things well, the context will be 95% genetics in this regard. that's the easier way to say it.
so if it was relatively healthy, and got enough light... it's as dense as you could have made it. there's no magic switch to significanlty change the fate of a plant in this regard..
i've heard some ppl physically squich the buds down a bit, but i wouldn't recommend such a thing. no point in putting lipstick on a pig. larfy buds can be good. you just might spend a bit more time removing twigs to avoid a lumber taste.